Phil Barrenger's - 3D Stuff
 
 
Tutorial - turning your favourite scripts into buttons

 

This tutorial is aimed at people new to, and a little duanted by, scripts.

Learning outcomes :
1) Create your own toolbars
2) Make your favourite scripts accessible through buttons
3) Create HOT KEYS for your favourite scripts

1) Creating your own toolbars.  

Open XSI so you have a nice clean scene to start with. Go to : Application - Toolbars - New Custom Toolbar. This creates a new empty toolbar but for it to exist next time you open up XSI we need to save it.
Right click in the blank space inside your new toolbar, a menu will pop up, click the save as and choose a new name for your toolbar.
Thats it for making a toolbar - you can now open this toolbar anytime you want by selecting Application - Toolbars and choosing your's from the list. At the moment it's useless though as it's empty, lets fix that. Right click again on the empty toolbar, from the menu choose Customise. This opens a new window that lists all of the commands that you can add as buttons to your menu - it's a big list, you can focus the list a little by choosing from the command catagories drop down list. To add a command as a button to your menu you simply click and drag the command from this window and drop it on top of your toolbar - could it be any easier?

fig 1
2) Make your favourite scripts accessible through buttons

Open the Script Editor by clicking the button next to playback at the base of your screen (as marked in orange in fig2). In the script Editor choose file - open and open a script that you want to turn into a button. The script should load into the white editing pane in the script editor.

Select all the text of the script (shortcut cntrl + a, remember that the script editor uses the focus of your mouse, so if your mouse is outside the editor then no typing will register). With all the text highlighted click and drag, on a highlighted portion of text, and drop it onto your toolbar, a window will pop up.

fig 2

This is where the action happens!

Command / Button Name - is the text that'll appear on the button and it will also appear in you command list later when we go to make a hotkey.

Script Command Name - is the name that can be used from now on in other scripts to call the action performed by this script.

Description and filename are self explanitory.

Script Language - this is one of the advantages of making buttons out of scripts rather than just running them from the script editor. When you make a script into a button / command xsi automagically detects the language it was written in and uses this language each time it is run from now on regardless of whether you have set xsi up to use this language in your prefferences. Where as if you run a script from the script editor then the scripting prefferences must be set to the scripting language the script was written in or it will fail.

 

OK, set the inputs up as you want the and click ok - That's it! easy.

3) Create HOT KEYS for your favourite scripts

Having made your script into a button you have also turned it into a command of the same name. You can use this command to add the same button to other toolbars in the same way we did in step one. You can also use it to map a keyboard shortcut to the command.

Go to File - Keyboard Mapping. The keyboard mapping template will open up. From the Group list choose Custom Script Commands, the Command list will update to show you all the available custom commands. Find yours from the list. To assign it to a button you click and drag your command from the list and drop it onto the key that you want to use. If you want to use it as a combination with Cntrl, Alt or Shift then hold down one or all of these keys while you drag the command onto a key. That's it! Close the Keyboard Mapping template and choose yes when you are prompted to save your changes to the mapping template. Your shortcut should now be working like a charm.