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!
