custom materials on get>materials list

Discussions regarding Materials, Material-Compounds or Shaders, etc.
User avatar
Maximus
Posts: 1121
Joined: 09 Jun 2009, 13:45

custom materials on get>materials list

Post by Maximus » 26 May 2012, 19:48

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

User avatar
Hirazi Blue
Administrator
Posts: 5113
Joined: 04 Jun 2009, 10:15

Re: custom materials on get>materials list

Post by Hirazi Blue » 26 May 2012, 20:57

If I recall correctly (can't check right now):
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
Stay safe, sane & healthy!

User avatar
Rork
Posts: 1359
Joined: 09 Jul 2009, 06:59
Location: Close to The Hague, Netherlands

Re: custom materials on get>materials list

Post by Rork » 27 May 2012, 09:32

Still tinkering with your material presets I assume? ;)
SI UI tutorials: Toolbar http://goo.gl/iYOL0l | Custom Layout http://goo.gl/6iP5xQ | RenderManager View http://goo.gl/b4ZkjQ
So long, and thanks for all the Fish!!

User avatar
Maximus
Posts: 1121
Joined: 09 Jun 2009, 13:45

Re: custom materials on get>materials list

Post by Maximus » 27 May 2012, 12:01

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!

User avatar
Hirazi Blue
Administrator
Posts: 5113
Joined: 04 Jun 2009, 10:15

Re: custom materials on get>materials list

Post by Hirazi Blue » 27 May 2012, 17:51

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... ;)
Stay safe, sane & healthy!

User avatar
Maximus
Posts: 1121
Joined: 09 Jun 2009, 13:45

Re: custom materials on get>materials list

Post by Maximus » 14 Jun 2012, 12:20

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

User avatar
Hirazi Blue
Administrator
Posts: 5113
Joined: 04 Jun 2009, 10:15

Re: custom materials on get>materials list

Post by Hirazi Blue » 14 Jun 2012, 15:47

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
Stay safe, sane & healthy!

User avatar
Maximus
Posts: 1121
Joined: 09 Jun 2009, 13:45

Re: custom materials on get>materials list

Post by Maximus » 15 Jun 2012, 06:09

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: Select all

# 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

User avatar
Hirazi Blue
Administrator
Posts: 5113
Joined: 04 Jun 2009, 10:15

Re: custom materials on get>materials list

Post by Hirazi Blue » 15 Jun 2012, 08:32

At the beginning of your "Mia_Material_Execute" code block try adding the following line:

Code: Select all

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: Select all

Application.InspectObj(sel)
Stay safe, sane & healthy!

User avatar
Maximus
Posts: 1121
Joined: 09 Jun 2009, 13:45

Re: custom materials on get>materials list

Post by Maximus » 16 Jun 2012, 08:20

thanks a lot Hirazi, that worked perfect!