Loading...
26 October, 2011#

Softimage XSI Custom Menu

The easiest way to access your own, or third party scripts from the UI in Softimage XSI is creating a toolbar. With these you can simple drag & drop text from the script editor onto your own toolbar, then save that in your user or workgroup folders.
That is fine, but they don’t really have place to dock them to the layout.

Instead of that, my much preferred way is to create your own custom menu in the menu bar.

I recall not really finding much information of how to make these custom menus for XSI, the help file has never really provided much information, but the best way to start usually would be to make a custom property from the wizard.
Animate > Create > Parameter > Custom Property Wizard

This isn’t specifically for making a menu, but it creates a plugin script that you can then open and it may help you understand some of the concepts associated with a plugin.

(as it says in the old/not amazingly useful wiki here: http://softimage.wiki.softimage.com/index.php/Custom_Menus).

So to save you all that trouble, here is a basic custom menu template that you can easily use and adopt for your own menus.

The following code should be saved as a Python file (.py) in the Application/Data/Plugins directory.
I would always recommend creating your own workgroup which is software version independent, and others can connect to (potentially very useful for a custom menu where you might be sharing studio tools on a server)

sr_Example_menu_v1.0.py

You will see I have saved the version on the script file which aligns with the versioning in the script:

in_reg.Major = 1
in_reg.Minor = 0

If you use these, XSI will always load the latest version.

I have commented in the example script where you should insert your own code – but if you use as is, it should display the example menu correctly.

# ############################################################
# sr_Example_Menu
#
# www.simonreeves.com
# simon@simonreeves.com
# 26/09/2011
# ############################################################
 
import win32com.client
from win32com.client import constants
 
# ############################################################
# On startup
 
def XSILoadPlugin( in_reg ):
	# the basic info goes here, self explanatory, author name/email etc.
	in_reg.Author = "simonr"
	in_reg.Name = "sr_Example_Menu"
	in_reg.Email = "simon@simonreeves.com"
	in_reg.URL = "http://www.simonreeves.com"
	# XSI will automatically look for the higer version number so this is good to use.
	in_reg.Major = 1
	in_reg.Minor = 0
 
	# Register Menus
 
	# Here we register the menu's to be used in this plugin by any of the scripts, "constants.siMenuMainTopLevelID" creates a menu bar item
	# They need to be labelled so you can reference that name later in this example: "sr_Example"
	in_reg.RegisterMenu(constants.siMenuMainTopLevelID,"sr_Example", False, False)
	# or else you can pick a menu that already exists, search for siMenuAnchorPoints in the SDK help to find all the menus you can attch your scripts to
	in_reg.RegisterMenu(constants.siMenuTbRenderPassPartitionID, "sr_ExamplePartitionMenu",False,False)
 
	# Register Commands
	# Next we register the scripts/commands that will be used - the order doesn't matter here, neither does the menu as the commands can be placed onto various menus.
	in_reg.RegisterCommand("ExampleScript1","ExampleScript1")
	in_reg.RegisterCommand("ExampleScript2","ExampleScript2")
 
	return True
 
# ############################################################
# Add commands to menus
 
# Next we add the COMMANDS on to the MENUS were just registed in the correct order.
# The def starts with the menu "sr_Example" suffixed with "_Init"
 
def sr_Example_Init( in_ctxt ):
 
	oMenu = in_ctxt.Source
 
	# This line adds each command as a simple item, the first paramater is the label, the second is command name we registered.
	oMenu.AddCommandItem("ExampleScript1","ExampleScript1")
 
	# Add a seperator
	oMenu.AddSeparatorItem()
 
	# Add a SubMenu and a command to it
	oExampleSubmenu = oMenu.AddSubMenu("SubMenu")
	oExampleSubmenu.AddCommandItem("ExampleScript2","ExampleScript2")
 
	return True
 
def sr_ExamplePartitionMenu_Init( in_ctxt ):
 
	oMenu = in_ctxt.Source
 
	# This line adds each command as a simple item, the first paramater is the label, the second is command name we registered.
	oMenu.AddCommandItem("ExampleScript1","ExampleScript1")
 
	# Add a seperator
	oMenu.AddSeparatorItem()
 
	# Add a SubMenu and a command to it
	oExampleSubmenu = oMenu.AddSubMenu("SubMenu")
	oExampleSubmenu.AddCommandItem("ExampleScript2","ExampleScript2")
 
	return True	
 
# ############################################################	
# Command Scripts
 
# Now we associate the commands that have been registered with actual scripts
# Again the defs for the COMMANDS are run with a suffix, this time of "Execute"
 
def ExampleScript1_Execute():
	print "ExampleScript1!"
	return
 
def ExampleScript2_Execute():
	print "ExampleScript2!"
	return

I’m sure I had some good help/spying at their menus from Juan Brockhaus (nice website link I found here for him), Andy Nicholas and Peter Agg over the last couple of years in this area to thanks to them!

If you have any comments then ask below!

13 October, 2011#

Nuke QTCF.dll Not found

I’ve seen this error pop up a few times, last time it was when nuke was already installed, but then I installed quicktime.. No doubt issues from QT, shame it’s not 64bit on windows…

If you get the error that QTFC.dll was not found “This application has failed to start becasue QTCF.dll was not found. Re-installing the application may fix this problem.” (it seems to be common in many apps).

Not sure if this is applicable on 32bit, as it’s redundant these days.
But for 64bit windows 7, the file that is missing is in here:

C:\Program Files (x86)\QuickTime\QTSystem

copy it into here!

C:\Windows\SysWOW64

Bingo!

8 October, 2011#

Python Scripting in Softimage XSI: Selection

I was originally planning to post purely about the incredibly useful simple task of making a loop to do repetitive tasks for you. You don’t need to be a TD for this to make things easier day to day, modelling, texturing, lighting, scene organising etc. You could use this in any situation.
ANYWAY as I wrote it I realised I was getting deep into some fundamentals whilst I was explaining how to access the object selection. So For this post I’ll just stick to selection and then advance that in the loop later.

    • Using this command, you can access the objects that are currently selected:
      Application.Selection

      This is a collection, so if you were to ‘print’ that command, you wouldn’t get great feedback about what it contains.
      In the following code examples, the lines that begin with # hashes show the results of the previous line of code when they are run.

      Note: if you ‘comment’ out a line in a script with the # it will be ignored when run – thus you can use it for commenting your code)

      print Application.Selection
      # Result:
      # >

      See! Not so helpful. But as a collection, you can iterate through it using a ‘for loop’. Good old loop.

      Here there are a couple of important things to note in the loop.
      The indent is used by python instead of {} or things like that in other code. So after the loop begins, the next line that is INSIDE that loop, is in the indent, when lines stop being indented, the loop is over – it should be clear to read.
      “oObject” is a variable being declared at this point to be used in the loop. So you can name this whatever you like it is not in relation to anything previously (this is something that confused me to begin with so I’ll try and make that clear)
      I prefix the variables with ‘o’ to make it clear what they are, I picked this up from somewhere..

      for oObject in Application.Selection:
      	# During the loop
      	print oObject
      	# Finished this loop
      # After the loop
       
      # Result:
      # crvlist10
      # crvlist11
      # polymsh

      So that’s the way to access each object in a loop. I’ll write up why that’s useful in the next post about loops specifically.

    • If you want to specifically pick the first, last, or any other object by index you can do that too.
      Note here I will create variables and then print whatever they contain, instead of printing the full command, this is a main principle while scripting, for tidiness, clarity of reading, organising, swapping data in and out.. And other great mysterious reasons I don’t understand.

      oFirstObject = Application.Selection(0)
      print oFirstObject
      # crvlist1

      So that’s getting the first object (or ONLY object if there’s only one selected)
      Arrays/indices always start from 0 in scripting, so the FIRST index is always 0. Keeping that in mind, how to get the last object…

      To do that you need to get the length of the selection – the number of objects selected.
      For instance if you have 4 selected, the indices would be 0,1,2,3. So after getting the length (4) you need to subtract 1 to get the last index in the list. To get the length, use this command:

      len(Application.Selection)

      Then you can use it like so, subtracting 1:

      oObjectCount = len(Application.Selection)
      oLastObject = Application.Selection(oObjectCount - 1) 
      print oLastObject

I guess that is about that for accessing the selection! I’ll write about what to do with the selection with loop later.

4 October, 2011#

Demo Reel 2011

[vimeo clip_id="30047322"]