|
Catalyzer Scripting API
8.3
GL Studio Editor Catalyzer Scripting API
|
This class is responsible for the Catalyzer Scripting API. More...
Inheritance diagram for PythonCatalyzerModuleImpl:Public Member Functions | |
| list | Catalyzer_GetPropertiesList () |
| Gets a list of properties that should be added to the object. More... | |
| str | Catalyzer_GetPreferredTypeName () |
| Gets a string that the Catalyzer should use as it's Type Name in the Editor when passing the instance as a parameter. More... | |
| int | Catalyzer_GetRecommendedRefreshMode () |
| Returns an enum representing the refresh mode the script prefers. More... | |
| bool | Catalyzer_DoPreReaction () |
| DoPreReaction functions are run on all scripts in order before the Reaction function. More... | |
| bool | Catalyzer_DoReaction () |
| This function is where the bulk of the work for a Catalyzer should be done. More... | |
| bool | Catalyzer_DoPostReaction () |
| This function runs after the reaction function scripts have executed. More... | |
| None | Catalyzer_OnPropertyChanged () |
| This function reacts whenever a property is changed. More... | |
| None | Catalyzer_OnScriptAssigned () |
| This functionality is called when a script is added to a Catalyzer as well as when the Catalyzer is recreated through undo and the file is opened. More... | |
| None | Catalyzer_OnScriptUnassigned () |
| This functionality is called when a script is removed from a Catalyzer as well as when the Catalyzer is deleted and the file is closed. More... | |
| None | Catalyzer_DoMagnify () |
| This function is called when the Magnify icon is selected. More... | |
| str | Catalyzer_GetPreferredIcon () |
| Gets the file path to a .png file for use as an icon. More... | |
This class is responsible for the Catalyzer Scripting API.
The following functions are used in Catalyzer scripts to provide functionality. These are all Python function and thus have access to the full Python API. Every function is optional.
Catalyzer scripts should modify the Catalyzer instance passed to it at all times and refrain from modifying the document as much as possible.
| None Catalyzer_DoMagnify | ( | ) |
This function is called when the Magnify icon is selected.
This function is called when the Magnify icon is clicked in the editor, with the first script to have it defined being the only one to get it. This function allows the user to have quick access to necessary files in a Catalyzer, a quick refresh button, or any other python functionality. Recommended to be overridden alongside Catalyzer_GetPreferredIcon to show that something other than the default action will be triggered.
Example:
def Catalyzer_DoMagnify( catalyzerInstance ):
psdFileName = catalyzerInstance.GetAttributeValuestr( "PSDFile" )
if os.path.exists( psdFileName ):
os.system('start ' + psdFileName)
Default: Clicking the Magnify icon will open the first script assigned to the Catalyzer.
| catalyzerInstance | The instance of the attached Catalyzer object |
| bool Catalyzer_DoPostReaction | ( | ) |
This function runs after the reaction function scripts have executed.
DoPostReaction functions are run on all scripts in order after the Reaction function. This function should be used for functionality you want to run after every other scripts Reaction function such as locking all child objects to prevent the user from modifying them.
Example:
def Catalyzer_DoPostReaction( catalyzerInstance ):
vertArray = VertexArray.VertexArray()
vertArray.Insert( Vertex.Vertex( -20, -20, 0 ) )
vertArray.Insert( Vertex.Vertex( 20, -20, 0 ) )
vertArray.Insert( Vertex.Vertex( 20, 20, 0 ) )
vertArray.Insert( Vertex.Vertex( -20, 20, 0 ) )
poly = GLPolygon.GLPolygon( vertArray, Vector.Vector(0,0,0) )
poly.SetName( "myPostPoly" )
self.InsertObject( poly, True )
Default: The Catalyzer will run no functionality after running reactions
| catalyzerInstance | The instance of the attached Catalyzer object |
| bool Catalyzer_DoPreReaction | ( | ) |
DoPreReaction functions are run on all scripts in order before the Reaction function.
This function should be used for functionality you want to run before every other scripts Reaction function such as setting up environment variables.
Example:
def Catalyzer_DoPreReaction( catalyzerInstance ):
vertArray = VertexArray.VertexArray()
vertArray.Insert( Vertex.Vertex( -20, -20, 0 ) )
vertArray.Insert( Vertex.Vertex( 20, -20, 0 ) )
vertArray.Insert( Vertex.Vertex( 20, 20, 0 ) )
vertArray.Insert( Vertex.Vertex( -20, 20, 0 ) )
poly = GLPolygon.GLPolygon( vertArray, Vector.Vector(0,0,0) )
poly.SetName( "myPrePoly" )
self.InsertObject( poly, True )
Default: The Catalyzer will run no functionality before running reactions
| catalyzerInstance | The instance of the attached Catalyzer object |
| bool Catalyzer_DoReaction | ( | ) |
This function is where the bulk of the work for a Catalyzer should be done.
This is where all of the objects that will make up its children should be created and inserted into the catalyzerInstance.
Example:
def Catalyzer_DoReaction( catalyzerInstance ):
vertArray = VertexArray.VertexArray()
vertArray.Insert( Vertex.Vertex( -20, -20, 0 ) )
vertArray.Insert( Vertex.Vertex( 20, -20, 0 ) )
vertArray.Insert( Vertex.Vertex( 20, 20, 0 ) )
vertArray.Insert( Vertex.Vertex( -20, 20, 0 ) )
poly = GLPolygon.GLPolygon( vertArray, Vector.Vector(0,0,0) )
poly.SetName( "myPoly" )
self.InsertObject( poly, True )
Default: The Catalyzer will run no functionality after running reactions
| catalyzerInstance | The instance of the attached Catalyzer object |
| str Catalyzer_GetPreferredIcon | ( | ) |
Gets the file path to a .png file for use as an icon.
This function lets the script replace the Magnify icon next to the Catalyzer Type Name in the editor to any valid .png file. Recommended to be overridden alongside Catalyzer_DoMagnify as a different icon usually means different functionality.
Example:
def Catalyzer_GetPreferredIcon():
pathToIcon = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../Icons/Photoshop_Icon.png")
if os.path.isfile( pathToIcon ):
return pathToIcon
return None
Default: The default Magnify icon will be used
| None |
| str Catalyzer_GetPreferredTypeName | ( | ) |
Gets a string that the Catalyzer should use as it's Type Name in the Editor when passing the instance as a parameter.
This function allows the script to replace the Type Name used in the editor from Catalyzer to any nonempty ascii string. This can provide an eaiser time reading what a Catalyzer is supposed to be without having to go to the scripts attached to it. The first type name returned will be one used, regardless of the value returned by other scripts.
Example:
def Catalyzer_GetPreferredTypeName():
return "LocalRef"
Default: The Catalyzer's Type Name will remain Catalyzer in the editor
| catalyzerInstance | The instance of the attached Catalyzer object |
| list Catalyzer_GetPropertiesList | ( | ) |
Gets a list of properties that should be added to the object.
Catalyzer scripts are able to add properties to the editor, allowing parameters to be controlled by end users in the editor. These properties will be obtainable in the Catalyzer script through the Resources API and will NOT be generated. In order to have the properties be parsed properly they must be stored in a list and each one must contain the following data:
| Name | Description |
|---|---|
boolean | A checkbox will be used allowing for easy True and False values |
int32 | A text field will be used to accept signed integer values |
float32 | A text field will be used to accept floating point values |
uint32 | A text field will be used to accept integer values |
child_index | A dropdown will be used to select a child object. Only valid on objects that inherit from Group |
color4ub | A color picker will be used to allow selection of an RGBA color |
vec2f | Two text field will be used to accept floating point values and returned as a vector of floats |
vec3f | Three text field will be used to accept floating point values and returned as a vector of floats |
ascii | A text field will be used to accept ascii values |
utf8_filepath | A text field will be used to accept UTF8 File paths as well as a 'Browse' button to open a file dialog |
utf8_multiline | A text field will be used to accept UTF8 string that can be expanded to accept multi-lined values |
texture_index | A texture selection button will be present and will return the index of the selected texture |
enum_list | A list of enumeration values. The values are provided name-value pairs are provided in a Python dictionary, e.g., ( { "name":"NONE", "value":"0" }, { "name":"MIN", "value":"1" }, { "name":"MAX", "value":"2" }, { "name":"PROGRESS", "value":"3" } ) |
__name__ can be used to make the group the name of the script.enum_list only): The enumeration names and values.Example:
def Catalyzer_GetPropertiesList():
return [( "ReferencedObjects", "ascii", "Referenced Objects", __name__, "All the object to copy into the catalyzer seperated by spaces", "" ), ]
Default: The Catalyzer will add no properties to the editor
| None |
| int Catalyzer_GetRecommendedRefreshMode | ( | ) |
Returns an enum representing the refresh mode the script prefers.
This function lets the script state a refresh mode that should be used when it's Refresh Mode is set to Script Controlled. If any script returns that it wishes to be refreshed always every script will be refreshed always regardless of their return value for this function.
Example:
def Catalyzer_GetRecommendedRefreshMode():
return Catalyzer.REFRESH_ALWAYS
Default: The Catalyzer will use the EXPLICIT refresh mode
| None |
| None Catalyzer_OnPropertyChanged | ( | ) |
This function reacts whenever a property is changed.
Example:
def Catalyzer_OnPropertyChanged( catalyzerInstance, propertyName ):
if "PSDFile" == propertyName:
CatalyzerSourceChangeMonitor.Start( catalyzerInstance, "PSDFile" )
Default: The script will not react to any properties being changed
| catalyzerInstance | The instanced of the attached Catalyzer object |
| propertyName | The internal name of the property that was changed |
| None Catalyzer_OnScriptAssigned | ( | ) |
This functionality is called when a script is added to a Catalyzer as well as when the Catalyzer is recreated through undo and the file is opened.
Functionality that you wish to start when the script is first added to the object should be placed in this function.
Example:
def Catalyzer_OnScriptAssigned( catalyzerInstance ):
CatalyzerSourceChangeMonitor.Start( catalyzerInstance, "PSDFile" )
Default: No functionality will be run when the script is added to the Catalyzer
| catalyzerInstance | The instance of the attached Catalyzer object |
| None Catalyzer_OnScriptUnassigned | ( | ) |
This functionality is called when a script is removed from a Catalyzer as well as when the Catalyzer is deleted and the file is closed.
Functionality that you wish to stop when the script is no longer needed should be placed in this function.
Example:
def Catalyzer_OnScriptUnassigned( catalyzerInstance ):
CatalyzerSourceChangeMonitor.Stop( catalyzerInstance, "PSDFile" )
Default: No functionality will be run when the script is added to the Catalyzer
| catalyzerInstance | The instance of the attached Catalyzer object |