[Tip] Decluttering your XSI browser Add-on Paths


If you’ve got a lot of add-ons, you probably have a bit of clutter in the browser Paths menu. Like this:
clutter_addon_paths
You can get rid of all those add-ons by cleaning out the Addons/InstalledAddons folders in your User and Workgroup locations. Softimage checks those folders (at startup) to build the list of add-ons for the Paths menu.

Don’t worry; removing the .xsiaddon files from the InstalledAddons folder doesn’t uninstall the addons.

Loading order of workgroup plugins and addons


I recently had reason to investigate the order in which things are loaded from workgroups, and here’s what I found:

  • Workgroup plugins are loaded first.
    Softimage goes through all the workgroups, in the order they are listed in the Plug-in Manager, and loads all plugins that are not in an add-on.

  • Workgroup addons are loaded second.
    Again, Softimage goes through all the workgroups in list order, loading add-on plugins.

What was my motive for looking into this? A plugin that was trying to get the OriginPath of a plugin in the SItoA addon. That was never going to work, because the plugin was loaded before the SItoA addon.

I tested this on Windows 7, not Linux.

Installing PyQtForSoftimage


I read somewhere that installing PyQtForSoftimage could be difficult, so I gave it a try. I didn’t have any problems.

For my test, I installed PyQtForSoftimage in Softimage 2014 SP2, using Python 2.7.3 and pywin32 218.

Here’s a recipe that will work with Softimage 2014 and earlier. But if you’re using Softimage 2014, you can skip the part about using the system Python. Instead, use PYTHONPATH to point to folder where PyQt4 is installed (hat tip: Tim C).

On-sentence-summary
You need to switch from the Python installed with Softimage to the system Python (and pywin32), install PyQT, and then install the PyQtForSoftimage addon.

General Recipe

  1. Download and install Python 2.7.x (Note that Softimage ships with Python v2.7.3).
  2. Download and install pywin32 (Softimage ships with pywin32 217).
  3. In the Softimage Scripting preferences, clear the Use Python Installed with Softimage check box. Then restart Softimage.
    PythonInstalledWithSoftimage

    Or edit your prefs file (%XSI_USERHOME%\Data\Preferences\default.xsipref) and add this line: scripting.sipython = False

  4. Check that Python is working in Softimage. In the script editor, run a Python snippet like this: Application.LogMessage( “Hello World” )
  5. Download and install PyQt.
  6. Download (right-click and then click Save As) and install the PyQtForSoftimage addon.
  7. Check that everything is working. Open the Plug-in Manager, find PyQtForSoftimage, and run some of the examples.
    PyQt_Example

    I found that the ExampleDialog and ExampleSignalSlot examples did pop up dialogs, but the Log Text button didn’t log anything to the history log.

Softimage 2014 Recipe

  1. Download and install PyQt.
  2. Set the PYTHONPATH environment variable to point to the location of PyQt4. You could do this in setenv.bat, or in the System environment variables.
  3. Download (right-click and then click Save As) and install the PyQtForSoftimage addon.
  4. Check that everything is working. Open the Plug-in Manager, find PyQtForSoftimage, and run some of the examples.

Finding empty polygon meshes


Now that there are intrinsic ICE attributes like NbPoints and NbPolygons, there a couple of ways you can check for an empty mesh:

# Assume a polymesh is selected...
o = Application.Selection(0)

# Check the intrinsic ICE attribute
nb =  o.ActivePrimitive.ICEAttributes("NbPoints")
print nb.IsDefined and nb.DataArray[0] <= 0

# Check using the object model
print o.ActivePrimitive.Geometry.Points.Count <= 0

The typical way to package this up for users it to define a filter. Then a user just has to select the filter and press CTRL+A. Here’s the Match callback for a filter that finds empty polygon meshes. Note that I switched to checking the number of polygons. That way, if somehow there was something weird like a mesh with just one point, you’d still find it.

The intrinsic attribute NbPolygons should always exist, but just to be sure I check IsDefined, and if that is False, I fall back to checking Geometry.Polygons.Count.

# Match callback for the EmptyPolygonMesh custom filter.
def EmptyPolygonMesh_Match( in_ctxt ):
	Application.LogMessage("EmptyPolygonMesh_Match called",constants.siVerbose)

	o = in_ctxt.GetAttribute( 'Input' )
	if o.type == 'polymsh':
		nb =  o.ActivePrimitive.ICEAttributes("NbPolygons")
		return (nb.IsDefined and nb.DataArray[0] <= 0) or o.ActivePrimitive.Geometry.Polygons.Count <= 0
	else:
		return False

I packaged the filter as an addon. Get it here.

Importing multiple FBX files with drag-and-drop


As an exercise, I updated Tim Crowson’s Multi_ImporterPPG addon with a DragAndDrop event, so you can import multiple files with a single drag-and-drop. You can download the modified version here.

Here’s the DragAndDrop event handler. The doit() function is also used by the Import menu command; I just had to generalize it a bit to work in either case (menu or drag-and-drop).

def Multi_Importer_DragAndDrop_OnEvent( in_ctxt ):

	action = in_ctxt.GetAttribute( "DragAndDropAction" )
	source = in_ctxt.GetAttribute( "DragSource" )

	if action == constants.siSourceDragAction:
		if re.search( r"\obj$", source, re.I ):
			in_ctxt.SetAttribute( "DragSourceSupported", True )
		elif re.search( r"fbx$", source, re.I ): 
			in_ctxt.SetAttribute( "DragSourceSupported", True )
		elif re.search( r"emdl$", source, re.I ): 
			in_ctxt.SetAttribute( "DragSourceSupported", True )
		elif re.search( r"lwo$", source, re.I ): 
			in_ctxt.SetAttribute( "DragSourceSupported", True )
		else:
			in_ctxt.SetAttribute( "DragSourceSupported", False )
		
	
	if action == constants.siSourceDropAction:

		Application.SetValue('preferences.Interaction.autoinspect', False, '')

		if not Application.ActiveSceneRoot.Properties( 'Multi_Importer' ):
			vtcol = Application.AddProp('Multi_Importer','Scene_Root')
			p = Application.Dictionary.GetObject( vtcol.Value("Value") )

			# Set the flag that hides certain parts of the PPG layout
			p.Parameters("bMenuCommand").Value = False

			# Inspect the PPG in modal mode
			Application.InspectObj( vtcol.Value("Value"), "", "", 4 )

			p.Parameters("bMenuCommand").Value = True
			
		p = Application.ActiveSceneRoot.Properties('Multi_Importer')

		options = { 
			'OBJgrouping' : p.Parameters('importOBJgrouping').Value,
			'OBJhrc' : p.Parameters('importOBJhrc').Value,
			'importOBJnormals' : p.Parameters('importOBJNormals').Value,
			'includeOBJmat' : p.Parameters('includeOBJMaterial').Value,
			'includeOBJuv' : p.Parameters('includeOBJUV').Value,
			'includeOBJwrap' : p.Parameters('includeOBJUVWrap').Value,
			'fbxScale' : p.Parameters('fbxScale').Value,
			'importEMDLasRef' : p.Parameters('importEMDLasRef').Value,
			'lwoScaleFactor' : p.Parameters('lwoScaleFactor').Value
			}
		
		doit( source, options )
	
	return True

Animating the Environment shader Transformation parameter


We’ve had a couple of questions about this recently, so here goes…

In the 2011 release, parameters like the Environment shader’s Transformation parameter were changed to expose the raw transformation matrix instead of StaticKineState. This allows ICE attributes to plug directly in the shader input matrix ports and have texturable matrix ports.

A transformation matrix is a combination of the scaling, rotation, and translation, and when you start animating those values, you’re going to see some “weird” numbers šŸ˜‰ For example, if I animate the Z rotation from 0 to 45 degrees, I’ll see this in the Animation Editor. Note that in the viewport I’m using ICE to show the transformation matrix for a cone that has the same Z rotation from 0 to 45 degrees: see how it matches up with the fcurves for the Environment transformation.

To make things more artist-friendly, you have to make the Transformation parameter texturable so you can plug in a Create_Transform node in the render tree.

To make the Transformation parameter texturable, install this addon.