Getting Python to Recognize Softimage Constants (Enums)


One of the idiosyncrasies of using Python with Softimage is that you need to import the Softimage constants (including enums) typelib as a custom Python module, then refer to each constant (or enum) as a member of the constants module. This example demonstrates how to use constants in a Python script:

# Import the Softimage constants module
from win32com.client import constants

root = Application.ActiveSceneRoot
kids = root.Children

# Then prefix the placeholder word constants to the Softimage constant or enum
nulls = kids.Filter( "", constants.siNullPrimitiveFamily )
for n in nulls :
   Application.LogMessage( n, constants.siComment )
# The above snippet returns:

If you dislike typing, you can use a small keyword or letter as a reference to the constants instead:

from win32com.client import constants as c
Application.LogMessage( n, c.siComment )