Toggling LUT on and off for the render region


Here’s a simple self-installing plugin that adds a “Toggle LUT” command to the viewport Display menu. You can use this hide/show gamma correction in the render region while you’re working on the lighting of your scene (eg for film work, to toggle between the linear display and the “print space” lut).

To install this plugin, copy the code and save it in a .py file in the Application\Plugins folder of the User location or a workgroup. Then either restart Softimage or use the Plugin Manager to load the new plugin. After the plugin is loaded, you can use File > Keyboard Mapping to assign a shortcut key to the ToggleLut command.

# ToggleLUT
# Initial code generated by Softimage SDK Wizard
# Executed Wed Jun 15 05:51:55 EDT 2011 by blairs
import win32com.client
from win32com.client import constants

null = None
false = 0
true = 1

def XSILoadPlugin( in_reg ):
	in_reg.Author = "blairs"
	in_reg.Name = "ToggleLUT"
	in_reg.Major = 1
	in_reg.Minor = 0

	in_reg.RegisterCommand("ToggleLUT","ToggleLUT")
#	in_reg.RegisterMenu(constants.siMenuVMCameraID,"Camera_Toggle_LUT",false,false)
	in_reg.RegisterMenu(constants.siMenuVMDisplayID,"Display_Toggle_LUT",false,false)
	#RegistrationInsertionPoint - do not remove this line

	return true

def XSIUnloadPlugin( in_reg ):
	strPluginName = in_reg.Name
	return true

def ToggleLUT_Init( in_ctxt ):
	oCmd = in_ctxt.Source
	oCmd.Description = ""
	oCmd.ReturnValue = true

	return true

def ToggleLUT_Execute(  ):

	rr = Application.Preferences.GetPreferenceValue("Display.color_management_render_region")
	Application.Preferences.SetPreferenceValue("Display.color_management_render_region", not(rr) )

	return true

def Display_Toggle_LUT_Init( in_ctxt ):
	oMenu = in_ctxt.Source
	oMenu.AddCommandItem("ToggleLUT","ToggleLUT")
	return true

A little more about the interactive tool SDK


Softimage 2012 includes several examples of custom tools built with the new interactive tool SDK. For example, there’s the Box Transform Tool:

The Box Transform Tool is a complex manipulator-style tool that uses highlighting, shortcut keys, context menus and on-screen controls.

Interactive tools are a new type of custom plugin, implemented in C++. You need to know OpenGL, because it is used for drawing and picking in the viewport. More here…

Compiling legacy preset-based operators


Preset-based operators are a deprecated feature, but there are still some of them around (Taut for example).

To compile a 64-bit version of one of these preset-based operators, here’s what I had to do:

  • Use the SDK Wizard to generate a Visual C++ project for a 64-bit plugin.
  • Add the module definition file to the Linker > Input properties (otherwise you get “Unable to locate the initialization entry point named” errors in Softimage).
  • Deal with string conversion errors like “error C2664: ‘OutputDebugStringA’ : cannot convert parameter 1 from ‘wchar_t [255]’ to ‘LPCSTR'”.

64-bit version of Taut operator


I compiled a 64-bit version of Taut for the FxNut Andy Nicholas. Download here.

Taut is a C++ modelling operator for straightening edges. It features an intelligent algorithm that searches your current selection for distinct lines, which allows multiple edges to be straightened at once. It also features three modes of operation that provide different ways of distributing the vertices along the lines.

Python: importing modules into plugins


New in the Softimage 2011 Subscription Advantage Pack

The siutils Python module makes it easier to import modules into your self-installing plugins. Just put your modules in the same location as your plugin file , and you can use the __sipath__ variable to specify the module location.

__sipath__ is always defined in the plugin namespace, so no matter where you put a plugin, you can simply use __sipath__ to specify the location.

Here’s a simple example that shows how to import a module into your plugin.

  • Line 04: Import the siutils module
  • Line 39: Use add_to_syspath() to add __sipath__ to the Python sys path.
    If the module was located in a subfolder of the plugin location, you could use siutils.add_subfolder_to_syspath( __sipath__, ‘mysubfolder’ )

  • Line 40: Import the module
import win32com.client
from win32com.client import constants

import siutils

null = None
false = 0
true = 1

def XSILoadPlugin( in_reg ):
	in_reg.Author = "blairs"
	in_reg.Name = "TestPlugin"
	in_reg.Major = 1
	in_reg.Minor = 0

	in_reg.RegisterCommand("Test","Test")
	#RegistrationInsertionPoint - do not remove this line

	return true

def XSIUnloadPlugin( in_reg ):
	strPluginName = in_reg.Name
	Application.LogMessage(str(strPluginName) + str(" has been unloaded."),constants.siVerbose)
	return true

def Test_Init( in_ctxt ):
	oCmd = in_ctxt.Source
	oCmd.Description = ""
	oCmd.ReturnValue = true

	return true

def Test_Execute(  ):

	Application.LogMessage("Test_Execute called",constants.siVerbose)

#	print __sipath__ 

	siutils.add_to_syspath( __sipath__ )
	import TestModule
	TestModule.test( "hello world" )

	return true

The Valve Source addon and 64-bit Softimage


You can use the Valve Source ModTool addon with the commerical version of Softimage, but if you are using 64-bit Softimage, none of the compiled Valve Source plugins will be available (because they’re all 32-bit).

So, that means no SMD, Weight, or VMF import and export in 64-bit Softimage. You can use install 32-bit Softimage if you need access to these tools; 32-bit Softimage will run with the same license as 64-bit Softimage.