Softimage 2013 Python shortcuts gotcha


Softimage 2013 includes some changes to the Python shortcuts:

from siutils import si
si = si()					# win32com.client.Dispatch('XSI.Application')
from siutils import log		# LogMessage
from siutils import disp	# win32com.client.Dispatch
from siutils import C		# win32com.client.constants

The big difference is that si shortcut is now a function that returns the Application object. We had to make this change to fix some weird memory leak (the si object was out of scope in the module where it was created, and the Python parser could not properly delete it upon exit).

Here’s a suggested workaround from the Dev team to maintain backward-compatibility:

# ---python code begin ---
from siutils import si

if Application.Version().split('.')[0]>= "11":
	si = si()					# win32com.client.Dispatch('XSI.Application')

from siutils import log		# LogMessage
from siutils import disp	# win32com.client.Dispatch
from siutils import C		# win32com.client.constants
# --- python code end ---

The if block executes only if the current Softimage version is later than 11, which corresponds to 2013 or later.

hat tip: SS