It is currently 24 May 2013, 17:49

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: custom materials on get>materials list
PostPosted: 26 May 2012, 21:48 
Offline
User avatar

Joined: 09 Jun 2009, 15:45
Posts: 812
Hey guys, i was wondering if anyone know a method to add a custom material to the default menù in Softimage, "Get> material" list.
Tryin in all the ways i could think of but no success. This would be handy :)

Thanks a lot

Max


Top
 Profile  
 
 Post subject: Re: custom materials on get>materials list
PostPosted: 26 May 2012, 22:57 
Offline
Administrator
User avatar

Joined: 04 Jun 2009, 12:15
Posts: 3213
If I recall correctly (can't check right now):
Quote:
Create a Preset of the Material node
Create a Custom Command using the Wizard
In this Wizard set the menu option to "siMenuTbGetMaterialID"
Generate Code
In the Custom Command Definition use Application.ApplyShader to apply the preset.
Save Command

I do hope I've recalled this correctly :-s

_________________
Broken, not stirred...


Top
 Profile  
 
 Post subject: Re: custom materials on get>materials list
PostPosted: 27 May 2012, 11:32 
Offline
User avatar

Joined: 09 Jul 2009, 08:59
Posts: 737
Location: Close to The Hague, Netherlands
Still tinkering with your material presets I assume? ;)

_________________
Photography & Video Reference/Tracking Cubes - http://www.refcube.biz | Softimage tutorials blog: http://www.rowu-media.nl/rwmblog/category/tutorials


Top
 Profile  
 
 Post subject: Re: custom materials on get>materials list
PostPosted: 27 May 2012, 14:01 
Offline
User avatar

Joined: 09 Jun 2009, 15:45
Posts: 812
Rork wrote:
Still tinkering with your material presets I assume? ;)


I'm studying metals and found a way to achieve them in a realistic way (ala maxwell), wanted to add those in the menù, but still a bit of time before they are ready.

Create a Preset of the Material node
Create a Custom Command using the Wizard
In this Wizard set the menu option to "siMenuTbGetMaterialID"
Generate Code
In the Custom Command Definition use Application.ApplyShader to apply the preset.
Save Command

Tryin to figure out what this all means! i suck when it comes to coding and strings :)

Thanks!


Top
 Profile  
 
 Post subject: Re: custom materials on get>materials list
PostPosted: 27 May 2012, 19:51 
Offline
Administrator
User avatar

Joined: 04 Jun 2009, 12:15
Posts: 3213
I admit it was an attempt at a very concise description of the procedure...
If you don't understand parts of it, feel free to ask for further explanation, obviously... ;)

_________________
Broken, not stirred...


Top
 Profile  
 
 Post subject: Re: custom materials on get>materials list
PostPosted: 14 Jun 2012, 14:20 
Offline
User avatar

Joined: 09 Jun 2009, 15:45
Posts: 812
Hey Hirazi, i followed your procedure but it is not working.
How it can read where the preset it stored? You said first to save a preset of the shader i want in the menù. But i save it in a precise folder.
Now what is the command or how can i make it read that particular shader?

I'm a bit confused.
Also "In the Custom Command Definition use Application.ApplyShader to apply the preset." dont get where to put this.

If you could explain a little bit more i would appreciate it :)

thanks


Top
 Profile  
 
 Post subject: Re: custom materials on get>materials list
PostPosted: 14 Jun 2012, 17:47 
Offline
Administrator
User avatar

Joined: 04 Jun 2009, 12:15
Posts: 3213
While rechecking this I noticed something is amiss. Probably the fact, but I'm guessing here, that ApplyShader isn't the right command to begin with (seems to only work with Factory presets, but I will probably be mistaken, as I am under stress, see next sentence). Must investigate, but my PC just crashed: I will get back to you!
:-s

edit: When writing the previous instructions,
I probably just modified a factory preset, with which it worked...
:ymblushing:

PS It appears LoadPreset is a safer bet. I've sent you a PM

_________________
Broken, not stirred...


Top
 Profile  
 
 Post subject: Re: custom materials on get>materials list
PostPosted: 15 Jun 2012, 08:09 
Offline
User avatar

Joined: 09 Jun 2009, 15:45
Posts: 812
Alrigh, i managed to add the shader to the menù, and it works fine, the only weird thing that happens is once i apply it to an object it pops up the Phong PPG instead of its own PPG. Anyone have any clue how to solve this?

Here is the code i used. It works and it applies the shader, but it pops up wrong PPg.

Code:
# mia_material
# Initial code generated by Softimage SDK Wizard
# Executed Fri Jun 15 03:26:17 UTC+0200 2012 by Max
#
# Tip: To add a command to this plug-in, right-click in the
# script editor and choose Tools > Add Command.
import win32com.client
from win32com.client import constants

null = None
false = 0
true = 1

def XSILoadPlugin( in_reg ):
   in_reg.Author = "Max"
   in_reg.Name = "mia_material"
   in_reg.Major = 1
   in_reg.Minor = 0

   in_reg.RegisterCommand("Mia_Material","Mia_Material")
   in_reg.RegisterMenu(constants.siMenuTbGetMaterialID,"Mia_Material_Menu",false,false)
   #RegistrationInsertionPoint - do not remove this line

   return true

def XSIUnloadPlugin( in_reg ):
   strPluginName = in_reg.Name
   Application.LogMessage(str(strPluginName) + str(" has been unloaded."),constants.siVerbose)
   return true

def Mia_Material_Init( in_ctxt ):
   oCmd = in_ctxt.Source
   oCmd.Description = ""
   oCmd.ReturnValue = true

   return true

def Mia_Material_Execute(  ):

   Application.LogMessage("Mia_Material_Execute called",constants.siVerbose)
   #
def Mia_Material_Execute(  ):

   Application.LogMessage("Mia_Material_Execute called",constants.siVerbose)
   Application.ApplyShader("", "", "", "", "siLetLocalMaterialsOverlap")
   sel = Application.Selection(0).Material
   Application.LoadPreset("C:\\Users\\Max\\Autodesk\\Softimage_2013\\Data\\DSPresets\\Shaders\\Material\\mental images\\mia_Material.Preset", str(sel))
   return true
   
def Mia_Material_Menu_Init( in_ctxt ):
   oMenu = in_ctxt.Source
   oMenu.AddCommandItem("Mia_Material","Mia_Material")
   return true



Thanks everyone, and thx Hirazi


Top
 Profile  
 
 Post subject: Re: custom materials on get>materials list
PostPosted: 15 Jun 2012, 10:32 
Offline
Administrator
User avatar

Joined: 04 Jun 2009, 12:15
Posts: 3213
At the beginning of your "Mia_Material_Execute" code block try adding the following line:
Code:
Application.SetValue("preferences.Interaction.autoinspect", false, null)

This however should suppress all PPGs, so if you would want to a PPG for the specific new Preset you'd probably have to do an InspectObj on it specifically...
:-?
Belated edit: add this additional line (after the "LoadPreset" line),
that should suffice to inspect the suppressed PPG again:
Code:
Application.InspectObj(sel)

_________________
Broken, not stirred...


Top
 Profile  
 
 Post subject: Re: custom materials on get>materials list
PostPosted: 16 Jun 2012, 10:20 
Offline
User avatar

Joined: 09 Jun 2009, 15:45
Posts: 812
thanks a lot Hirazi, that worked perfect!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group