In the old days, if you didn’t like some default shader parameter setting, you had to edit a SPDL file and generate a new preset. As of 2011, you can use the ObjectModel (OM) to dynamically update the shader definition.
For example, if you run this Python snippet in the script editor, then the next time you create an Environment shader, it will have some different defaults:
- Environment Mode will default to Cylinder
- Transformation will have a connection icon
- Background Intensity will default to 0.5
from siutils import si # Application from siutils import log # LogMessage from siutils import disp # win32com.client.Dispatch from siutils import C # win32com.client.constants # Get ShaderDef for the Environment shader sProgID = "Softimage.sib_environment.1.0" oDef = si.GetShaderDef( "Softimage.sib_environment.1.0" ) # Get ShaderParamDef for the Tranformation parameter oTransform = oDef.InputParamDefs.GetParamDefByName( "transform" ) # Make it texturable so it has a connection icon oTransform.Texturable = True # Make Cylinder the default Environment mode oParam = oDef.InputParamDefs.GetParamDefByName( "mode" ) oParam.DefaultValue = 1 # Change the default background intensity to 0.5 oParam = oDef.InputParamDefs.GetParamDefByName( "background_intensity" ) oParam.DefaultValue = 0.5
So, that’s how you update a shader definition. Now, all you have to do is stick that code into a siOnCreateShaderDef event plugin, and every time you create an Environment shader, it will have the defaults you want
import win32com.client from win32com.client import constants null = None false = 0 true = 1 def XSILoadPlugin( in_reg ): in_reg.Author = "blairs" in_reg.Name = "ShaderDef Plug-in" in_reg.Major = 1 in_reg.Minor = 0 in_reg.RegisterEvent("CreateShaderDef",constants.siOnCreateShaderDef) return true def XSIUnloadPlugin( in_reg ): strPluginName = in_reg.Name return true # Callback for the CreateShaderDef event. def CreateShaderDef_OnEvent( in_ctxt ): oDef = in_ctxt.GetAttribute("ShaderDef") sProgID = str(in_ctxt.GetAttribute("ProgID")) if "Softimage.sib_environment.1.0" in sProgID: oDef.InputParamDefs.GetParamDefByName( "transform" ).Texturable = True # Return value is ignored as this event can not be aborted. return true
Tip: Use the SDK Explorer (CTRL+SHIFT+4) to get the ProgID of a shader.
I think the spdl had benefits – one time group wise edit that does not kill the startup time, or potential lots of scrips all over the place.
Is there any way to still go the old route? Thanks.
You can still edit SPDLs in the factory location, but that is not recommended.
YOu can use workgroups to organize plugins, addons, and compounds. The advantage of a workgroup is that you don’t have to edit files in the factory installation folder.