New Python methods in 2013


A few people have asked me about the new “Python-specific” methods added in the Softimage 2013 SDK.

Basically, these new “Python-specific” methods are wrappers for the existing methods. What the new, Python-specific versions do is make sure you get back an object that supports all the advertised methods and properties of the class hierarchy.

For example, Menu is a subclass of MenuItem, and Menu adds new methods like AddCommandItem().

Menu.AddItem() returns a Menu object that supports all the MenuItem methods and properties, but doesn’t support the Menu methods and properties, such as Menu.AddCommandItem().

Menu.AddItem2() , on the other hand, returns an object that supports all the MenuItem and Menu methods and properties.

I blogged about the Menu.AddItem() problem awhile back.

Python-specific methods

  • Clip.AddProperty2 – Creates and adds a UserDataBlob or CustomProperty to a Clip object. This method is specific to the python language.
  • Layout.CreateViewFromDefinitionFile2 – Creates a new View object given the path to its definition on disk. This method is similar to Layout.CreateViewFromDefinitionFile but specific to the python language.
  • Layout.FindView2 – Finds an existing View object given a name in this layout. This method is similar to Layout.FindView but specific to the python language.
  • Menu.AddItem2 – Adds a menu item at to end of the menu. This method is similar to Menu.AddItem but specific to the python language.
  • Menu.AddCommandItem2 – Adds a menu item at the end of the menu and attaches a command. This method is similar to Menu.AddCommandItem but specific to the python language.
  • Menu.AddCallbackItem2 – Adds a menu item to the end of the menu and attaches a callback function. This method is similar to Menu.AddCallbackItem but specific to the python language.
  • ICENode.GetPortFromName2 – Returns the ICENodePort object that matches a specific port name. This method is similar to ICENode.GetPortFromName but specific to the python language.
  • ICENode.GetPortFromIndex2 – Returns the ICENodePort object specified by a port index, group index and group instance index. This method is similar to ICENode.GetPortFromIndex but specific to the python language.
  • Operator.GetPort3 – Returns the specified Port object for the operator. This method is similar to Operator.GetPort2 but specific to the python language.
  • Override.AddParameterEntry2 – Adds a new entry to override the input parameter and returns the new overriding parameter. This method is similar to Override.AddParameterEntry but specific to the python language.
  • Primitive.GetGeometry3 – Returns a Geometry object containing the object’s geometry. This method is similar to Primitive.GetGeometry2 but specific to the python language.
  • SceneItem.GetPropertyFromName2 – Returns a property, given its scripting name. This method is similar to SceneItem.GetPropertyFromName but specific to the python language.
  • SceneItem.GetLocalPropertyFromName2 – Returns a local property, given its scripting name. This method is similar to SceneItem.GetLocalPropertyFromName but specific to the python language.
  • ShaderArrayParamDef.ItemDef2 – Returns the underlying ShaderParamDef or ShaderStructParamDef object for this array item. This method is similar to ShaderArrayParamDef.ItemDef but specific to the Python language.
  • ShaderArrayParameter.Item2 – Returns the specified ShaderParameter item in this array. This method is similar to ShaderArrayParameter.Item but specific to the Python language.
  • ShaderParamDefContainer.AddParamDef2 – This method is similar to ShaderParamDefContainer.AddParamDef but specific to the Python language.
  • ShaderParamDefContainer.GetParamDefByName2 – Returns the ShaderParamDef that matches the specified name from this container. This method is similar to ShaderParamDefContainer.GetParamDefByName but specific to the Python language.
  • ShaderParameter.Definition2 – Returns the shader parameter definition as a ShaderParamDef object. This method is similar to ShaderParameter.Definition but specific to the Python language.
  • View.FindView2 – Finds an existing View object given a name. This method is similar to View.FindView but specific to the Python language.
  • X3DObject.GetActivePrimitive3 – Returns the 3D object’s active Primitive for a given frame. This method is similar to X3DObject.GetActivePrimitive2 but specific to the Python language.
  • XSIApplication.ActiveProject3 – Returns or sets the active XSIProject object. This method is similar to XSIApplication.ActiveProject2 but specific to the Python language.
  • XSIApplication.GetObjectFromID2 – Returns the object matching the specified ID. This method is similar to XSIApplication.GetObjectFromID but specific to the python language.
  • XSIFactory.CreateObjectFromPreset2 – Creates an object from a preset and optional preset family name. This method is similar to XSIFactory.CreateObjectFromPreset but specific to the Python language.

6 thoughts on “New Python methods in 2013

  1. GetPortFromName2 crashes Softimage if port does not exist

    For example create a cube and apply ICETree with Set Topology node:

    si = Application
    oICENode = si.Dictionary.GetObject(“cube.polymsh.ICETree.Set_Topology”)
    oPort = oICENode.GetPortFromName2(“Cookie”)

    • And it’s actually crashes if port exist. In this case string:

      COMPOUND = “Apply Collapse Edge”
      PORT = “String Array”

      from win32com.client import constants as c

      si = Application
      count = si.Selection.Count

      for i in range(count) :

      if PORT :
      obj = si.Dictionary.GetObject(si.Selection(i).FullName.rsplit(“.”, 1)[0])
      elements = ‘, ‘.join(str(e) for e in si.Selection(i).SubComponent.ElementArray)
      else : obj = si.Selection(i)

      oICETree = si.ApplyOp(“ICETree”, obj)
      si.AddICECompoundNode(COMPOUND, oICETree)
      compound = str(oICETree)+”.”+COMPOUND.replace(” “, “_”)
      si.ConnectICENodes(str(oICETree)+”.port1″, compound+”.Execute”)

      if PORT :
      oICENode = si.Dictionary.GetObject(compound)
      if PORT.replace(” “, “_”) in [i.Name for i in oICENode.InputPorts] :
      oPort = oICENode.GetPortFromName2(PORT)
      if oPort.DataType == c.siICENodeDataString :
      si.SetValue(compound+”.”+PORT+”_string”, elements)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s