Catalyzer Scripting API  8.3
GL Studio Editor Catalyzer Scripting API
PythonCatalyzerModuleImpl Class Reference

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...
 

Detailed Description

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.

Member Function Documentation

◆ Catalyzer_DoMagnify()

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.


Parameters
catalyzerInstanceThe instance of the attached Catalyzer object
Returns
None

◆ Catalyzer_DoPostReaction()

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


Parameters
catalyzerInstanceThe instance of the attached Catalyzer object
Returns
None

◆ Catalyzer_DoPreReaction()

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


Parameters
catalyzerInstanceThe instance of the attached Catalyzer object
Returns
None

◆ Catalyzer_DoReaction()

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


Parameters
catalyzerInstanceThe instance of the attached Catalyzer object
Returns
None

◆ Catalyzer_GetPreferredIcon()

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


Parameters
None
Returns
A file path to a .png file for use as an icon

◆ Catalyzer_GetPreferredTypeName()

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


Parameters
catalyzerInstanceThe instance of the attached Catalyzer object
Returns
A string that the Catalyzer should use as it's Type Name in the Editor (or "" if no preferred type)

◆ Catalyzer_GetPropertiesList()

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:

  • Internal Name - The internal variable name of the property. This should be valid c++ identifier.
  • PropType - How to display the property in the editor. The table below lists the supported options with examples of how they will look.
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" } )
  • Display Name - The user friendly name the property should show in the editor for easy identification.
  • Group Name - The name of the property group that the property should be located under in the Object Properties tab. __name__ can be used to make the group the name of the script.
  • Description - A user friendly description of what the property does and how to properly use it.
  • Default Value - The value of the property when it is first created.
  • Enumeration list (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


Parameters
None
Returns
A list of properties that should be added to the object.

◆ Catalyzer_GetRecommendedRefreshMode()

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


Parameters
None
Returns
An enum representing the refresh mode the script prefers

◆ Catalyzer_OnPropertyChanged()

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


Parameters
catalyzerInstanceThe instanced of the attached Catalyzer object
propertyNameThe internal name of the property that was changed
Returns
None

◆ Catalyzer_OnScriptAssigned()

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


Parameters
catalyzerInstanceThe instance of the attached Catalyzer object
Returns
None

◆ Catalyzer_OnScriptUnassigned()

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


Parameters
catalyzerInstanceThe instance of the attached Catalyzer object
Returns
None

The documentation for this class was generated from the following file: