thiago
02-21-2008, 06:47 AM
It's very common to drag scripts from the script editor to a toolbar. This way you create a button in the toolbar so when pressed this will run a script.
But imagine you need to activate a tool via scripting that will need some user interaction before proceed. Or if you want to run an specific command that is on the XSI interface like the Add Edge Tool or activate the Snapping mode.
As an example let's say you need to activate the Add Edge Tool via scripting.
What happen if you hit Add Edge tool in the polymesh>add edge tool is that XSI doesn't really log anything until you really use the tool.
So for example if you use add edge tool in a "cube", it will return something like this:
AddEdge("cube.pnt[LAST];cube.edge[14];", 66.9126281078331, siPersistentOperation, null, null);
So how to activate the tool for interaction via scripting, without really need to "use" the tool?
//Jscript
// using Commands() will return a collection with all XSI commands
// So you first point to the command you want to use, like this:
oCommands = Application.Commands("Add Edge Tool");
//Then you execute it:
oCommands.Execute();
You can also simplify your sintax just like this:
Application.Commands("Add Edge Tool").Execute();
But how do you know the name of each command you want? Guessing is not an option as XSI comes with 2300 commands.
Best way to do this is filter the command you want, based on what is on this post in the XSI Wiki http://softimage.wiki.avid.com/index.php/XSI_Support_Blog#Finding_Commands_you_don.27t_know _about
Another way is to loop through all commands available and log each one. :)
To make this easy, I'm putting a list of all commands I got from a fresh installation of XSI (it mean no plugins :P). Just download the attached and open the .txt file that's inside.
Or run this in your script editor and you'll log Commands + UID's:
//Jscript
//the Application.Commands below will return a collection of objects with
//all XSI commands
oCommands = Application.Commands;
//now simply loop all your oCommands collection logging each command name + UID
for(i = 0; i < oCommands.Count; i++)
{
LogMessage(oCommands(i) + " UID IS: " + oCommands(i).UID);
}
logMessage("logged " + oCommands.count + " commands");
IMPORTANT!!
Commands like Terminate AddEdge With Interior Points" or "Create Curve Partition Clusters" are kinda weird and probably called by another tool in XSI. But they are documented on and well exposed to the SDK at least!
But you'll find things like "Low Level Create Cluster Command" or "Continuous Draw" that are not documented at all and I have no idea what they are supposed to do! So it's all up to you.. use it at your own risk! And if your XSI explode don't go bother the support guys :P
But imagine you need to activate a tool via scripting that will need some user interaction before proceed. Or if you want to run an specific command that is on the XSI interface like the Add Edge Tool or activate the Snapping mode.
As an example let's say you need to activate the Add Edge Tool via scripting.
What happen if you hit Add Edge tool in the polymesh>add edge tool is that XSI doesn't really log anything until you really use the tool.
So for example if you use add edge tool in a "cube", it will return something like this:
AddEdge("cube.pnt[LAST];cube.edge[14];", 66.9126281078331, siPersistentOperation, null, null);
So how to activate the tool for interaction via scripting, without really need to "use" the tool?
//Jscript
// using Commands() will return a collection with all XSI commands
// So you first point to the command you want to use, like this:
oCommands = Application.Commands("Add Edge Tool");
//Then you execute it:
oCommands.Execute();
You can also simplify your sintax just like this:
Application.Commands("Add Edge Tool").Execute();
But how do you know the name of each command you want? Guessing is not an option as XSI comes with 2300 commands.
Best way to do this is filter the command you want, based on what is on this post in the XSI Wiki http://softimage.wiki.avid.com/index.php/XSI_Support_Blog#Finding_Commands_you_don.27t_know _about
Another way is to loop through all commands available and log each one. :)
To make this easy, I'm putting a list of all commands I got from a fresh installation of XSI (it mean no plugins :P). Just download the attached and open the .txt file that's inside.
Or run this in your script editor and you'll log Commands + UID's:
//Jscript
//the Application.Commands below will return a collection of objects with
//all XSI commands
oCommands = Application.Commands;
//now simply loop all your oCommands collection logging each command name + UID
for(i = 0; i < oCommands.Count; i++)
{
LogMessage(oCommands(i) + " UID IS: " + oCommands(i).UID);
}
logMessage("logged " + oCommands.count + " commands");
IMPORTANT!!
Commands like Terminate AddEdge With Interior Points" or "Create Curve Partition Clusters" are kinda weird and probably called by another tool in XSI. But they are documented on and well exposed to the SDK at least!
But you'll find things like "Low Level Create Cluster Command" or "Continuous Draw" that are not documented at all and I have no idea what they are supposed to do! So it's all up to you.. use it at your own risk! And if your XSI explode don't go bother the support guys :P