PDA

View Full Version : Finding XSI Commands


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

franky
02-26-2008, 06:15 AM
thanks a lot for the explanation! really helpful.

Sunces
03-07-2008, 12:18 PM
Thanks for the breakdown!

Photon
03-14-2008, 12:19 AM
Thanxs. I like it.

ximage
07-31-2008, 05:49 AM
this is cool.

im tryign to teach my self scripting, Jscript to be correct.

and i was wondering how would i actually stor call backs from commands, like the command to create curves, i need to log the XYZ of the points, do command give call backs or would it be best to get the positions of the point off the actual curve?

cheers

ximage

thiago
07-31-2008, 05:54 AM
this is cool.

im tryign to teach my self scripting, Jscript to be correct.

and i was wondering how would i actually stor call backs from commands, like the command to create curves, i need to log the XYZ of the points, do command give call backs or would it be best to get the positions of the point off the actual curve?

cheers

ximage

it depends on what you wanna do? why do you need to store this data?

Just to put straight the terms and ideas:
Usually you manipulate data like this, not store it.

Because this kind of data (like point positions), is already stored in the curve object. There's no reason to store it again unless you are going to make something very very specific.

ximage
07-31-2008, 06:27 AM
ok sorry

explained a bit wrong, i want to retrive the data. put it in a variable and use it.

as you execute the command it doesnt create the crv straight away until the first click is done, so how can i store the crv if it not there yet?

sorry for the nooby questions

cheers for your help

ximage

thiago
07-31-2008, 04:43 PM
to get an output of curve drawing, you need to first create a curve, then you go in modify>curve>add point tool.

it will log commands like SIAddPointOnCurveAtEnd, SIAddPointOnCurveAtStart or SIAddPointOnCurve

is that what you want?


as you execute the command it doesnt create the crv straight away until the first click is done, so how can i store the crv if it not there yet?


you don't, you don't get a pointer for something that doesn't exist.
What you do is draw the curve, after you finish XSI will keep it selected. So with the curve selected you can get it and do whatever you want.

Take a look on my sketch pluguin. I use a lot of curve manipulation... its all Jscript.
http://community.softimage.com/downloads.php?do=file&id=42

ximage
10-06-2008, 04:25 AM
Hey thiago

thanks for the help.



with regard to this question still, i know i could use SIAddPointOnCurveAtEnd, SIAddPointOnCurveAtStart or SIAddPointOnCurve to create my curve bit by bit with using the pickposition command too, but the thing i want to know is would it be easier to use the command that is already there like "create curve tool".

and say if i had the create curve command in a function and wanted to do some other things after it like make that curve the child of another object, or rename it it cant really be done as i cant seem to find out HOW or IF these command give call backs and as the command is called the script wont hold until that command is finished say as if i use the pickposition one.

i hope im making a bit more sense :P

maybe having a look at my script may explain this a bit better. first real attempt at scripting so most things aren't optimised.

cheers

Daniel

the addon is attached :)

thiago
10-06-2008, 05:14 AM
I don't see anything attached.

Regarding the callbacks. No these commands don't return anything AFAIK.
BUT they do select the curve in the end of the action, so this way you can just get the selection and decide what to do next.
Just to make this crystal clear:
It will inevitably select the curve in the end. So you know that what's selected is what you want to work on.

An OnSelectionChange event could do the trick for you.

Did you take a look on my Sketch tool? I do exactly that.. Draw curve, move to parent, rename, etc...

A pseudo code:
call a create curve command
end of the action the create curve will select the curve you just added.
the onselection change event will be called.
if selection.type == crvlist and meet all the requirements to know if that's your curve... do whatever you want.

ximage
10-06-2008, 06:51 AM
ooops dont know why it didn't attach..wierd.

cheers for taking the time to reply thiago, yeh i did take a quick look at your tools script, didnt look hard enough though i guess.

yeh i was looking in to using event, i missed that one somehow in the SDK.

the tool is attached now. its definately work in progress. see what you think, im trying to make a plugin to make re-topologising meshes quicker.

once again cheers for your time

Ximage