I have a scene with a cylinder with it's position (but not angle) constrained to a path. I'm trying to control the tangency of the cylinder with this script:
var x1 = GetValue("cylinder.kine.global.posx"); var z1 = GetValue("cylinder.kine.global.posz"); var time = GetValue("TimeSet.Frame"); time++; var x2 = GetValue("cylinder.kine.global.posx", time); var z2 = GetValue("cylinder.kine.global.posz", time);
But it doesn't work. I tried following the variables with logmessages, and it appears that the time difference is not evaluated at all, x1 has the same value as x2, same for z1 and z2.
Now next I move the same script to the Script Editor for debugging, and change the last line to this:
And suddenly it works! Why does the time offset work in the Script Editor but not the Animation Editor Scripted Operator?? I also tried doing the SetValue in the Scripted Operator instead of the Out.Value, but to no effect.
I'm very much starting to get fed up with XSI scripting. Here the same global script gets different behavior depending on where it's run, and in another scene I get Huge memory leaks. Is it really this buggy? Is there ANY decent documentation anywhere, or are we supposed to guess everything? Does anybody have a clue about why this doesn't work?
(TimeSet is my own custom parameter set belonging to the scene root, which has a parameter called Frame, which gives the current frame number via an expression. I looked and looked but found no information on how to directly access the current frame number. I'd really like some kind of documentation here)
Hmmm....my original reply seems to have disappeared.
Anyway, the answers to all your questions are in the XSI animation manual in the scripted operator section.
You cannot use GetValue and SetValue inside of Scripted Operators which is why you get the different results. To use Scripted operators effectively, you'll need to become familiar with the XSI Object Model as opposed to the XSI commands. With the object model, you can get all the low level stuff much easier and more efficiently.
In order to modify elements within the scene via a scripted operator, you must make a "connection" to the affected parameter (see manuals for details).
To Get the current frame from a script:
var Frame = GetValue( "PlayControl.Current" );
to Get the current frame from within a scripted operator (or using the Object model in a script):
var oRoot = Application.ActiveProject.ActiveScene.Root; var oPlayControl = oRoot.Properties.Find( "PlayControl" ); var oFrame = oPlayControl.Current;
Matt
Matt Lind Animator / Technical Director Softimage certified instructor: Softimage|3D Softimage|XSI speye_21@hotmail.com
There have been some database problems recently, so some post may have been lost...
Okay, so my basic problem has been that I've read the XSI 1.0 Animation manual cover to cover, but never really read the V1.5 Animation manual. I just kept reading the 1.0 and 1.5 Scripting sections and wondering why there was so little information...
I need to digest this new information now. I can probably fix my Scripted Operator up now that I know where I can find the Object Model reference. Same with the Angular velocity thread, your EvaluateAt tip didn't actually work when I finally tested it earlier today, but now that I have the Object Model map I can find the error in it without having to bug you about it. And then I can probably fix up my other script that was causing massive memory leak with all its SetValues and GetValues.
I'll be back later with questions undoubtably Thank you very much for your help Matt.
Where in the world are you anyway? Matt can certainly be an English name, but Lind would suggest Sweden or thereabouts...
Not as complicated as you may think. Here's a start based on your example above (assuming you have a "connection" to the object's geometry primitive):
------------- Start of script (Jscript)--------------------- var oPlayControl = ActiveProject.Properties.Find( "PlayControl" ); var oObject = InGeom.value;
var oObjectNext = oObject.EvaluateAt( oPlayControl.Current.value + 1 );
Where did you find the EvaluateAt command? I can't find any reference to it anywhere, and XSI says //ERROR : "Object doesn't support this property or method"
Also, it's a bit unclear to me does the object.posx refer to the local or global position, and what the other one is.
Even after reading the HTML docs the object model structure remains unclear, partly because the object model chart wouldn't display anything except the first page. It says click the triangle to expand but nothing happens...
Is there an object model tutorial on the net somewhere? (don't say in the HTML docs)
Now I have the null constrained to the path, and the cylinder as a child to the null. I got the null object root node as in Input Connection, and I'm trying to get the global position in the next frame...
@@Is there an object model tutorial on the net somewhere? (don't say in the HTML docs)
Sorry, you'll have to use the HTML docs or the XSI animation manual. v2.0 will have dramatic improvements in the scripting documenation.
@@Now I have the null constrained to the path, and the cylinder as a child to the null. I got the null object root node as in Input Connection, and I'm trying to get the global position in the next frame...
If the null is not a child of any object, then it's local and global coords will be the same.
@@ Where did you find the EvaluateAt command? I can't find any reference to it anywhere, and XSI says //ERROR : "Object doesn't support this property or method"
in the HTML docs, browse the 'objects' instead of 'commands'. If you installed v1.5.3, you should have a 'methods' button in the top-left corner of the HTML docs main page. Click it and browse until you come across "EvaluateAt()".
@@Also, it's a bit unclear to me does the object.posx refer to the local or global position, and what the other one is.
Local. To get global you need to either call the kinematics object, make a "connection" to the global parameters of the object, or use the alternative syntax for accessing parameters:
x = oObject.Kinematics.Global.Parameters( "PosX" ).value;
@@Even after reading the HTML docs the object model structure remains unclear, partly because the object model chart wouldn't display anything except the first page. It says click the triangle to expand but nothing happens...
I don't have v1.5.3 installed on my machine, so I cannot help you their. If you browse the objects pages, you can follow links around the block so to speak and get an idea of how things are wired together. The hierarchy will become much more clear in XSI v2.0. Just hang on, it won't be too much longer.
Oh well, the script I showed is how you attack the problem in XSI v2.0. As you can plainly see, It's not difficult. And to answer your question, no, things you learn now will not be obsolete in v2.0 - they just won't be as efficient as the new methods coming down the pipe. ;-D
Matt
Matt Lind Animator / Technical Director Softimage certified instructor: Softimage|3D Softimage|XSI speye_21@hotmail.com
um... that means I'm stuck tho, doesn't it? Is the only way to access non-current data in XSI 1.5 via the GetValue method, which means no scripted operators? Or I could plot the motion to get an FCurve, but I want to keep it procedural, so that's a big no-no.
What does this mean? What is a 'Transform'? It's not linked to any helpfile, it just says that. How can I get the method listing for Transform, to see if it has methods that can accept frame numbers as parameters?
I don't have XSI v1.5x installed anymore so I can't help you there, but there should still be a way to extract the info you're looking for. Keep searching.
As for the transform, it's a superset of a matrix object. Look under the SITransformation object for it's description, properties, and methods.