# Scripted Operator only works in the Script Editor?

**URL:** https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093
**Category:** Xsi
**Tags:** developers
**Created:** [October 15, 2001, 11:35am UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093 "2001-10-15T11:35:33Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![wolfinger](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/w/d78d45/32.png) [@wolfinger](https://forum.highend3d.com/u/wolfinger)
#### Post date: [October 15, 2001, 11:35am UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/1 "2001-10-15T11:35:33Z")

</div>

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);

Out.Value = Math.atan( (x1-x2) / (z1-z2) ) \* 57.295 + 90;

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:

SetValue("cylinder.kine.local.roty", Math.atan( (x1-x2) / (z1-z2) ) \* 57.295 + 90);

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)

---

<div class="post-metadata">

### Author: ![devdoka](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@devdoka](https://forum.highend3d.com/u/devdoka)
#### Post date: [October 15, 2001, 8:46pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/2 "2001-10-15T20:46:11Z")

</div>

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

---

<div class="post-metadata">

### Author: ![wolfinger](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/w/d78d45/32.png) [@wolfinger](https://forum.highend3d.com/u/wolfinger)
#### Post date: [October 15, 2001, 10:07pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/3 "2001-10-15T22:07:08Z")

</div>

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... ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/smile.gif)

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 ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/smile.gif)  
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...

---

<div class="post-metadata">

### Author: ![wolfinger](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/w/d78d45/32.png) [@wolfinger](https://forum.highend3d.com/u/wolfinger)
#### Post date: [October 15, 2001, 10:21pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/4 "2001-10-15T22:21:40Z")

</div>

> [@](#):
>
> In reply to:  
> suppose you want to write a scripted operator to control an object's orientation based on its position; if the object has a path constraint, the orientation is evaluated before the position is updated at each frame so the operator uses stale values. To achieve the desired result, constrain an intermediate object like a null to the path, then constrain the object's position to the null. When calculating the new orientation, use the null's position.

damn. the last thing I wanted was to make things even more complicated.

---

<div class="post-metadata">

### Author: ![devdoka](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@devdoka](https://forum.highend3d.com/u/devdoka)
#### Post date: [October 15, 2001, 11:10pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/5 "2001-10-15T23:10:45Z")

</div>

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 );

LogMessage( "X current: " + oObject.posx.value );  
LogMessage( "Z current: " + oObject.posz.value );  
LogMessage( "X next: " + oObjectNext.posx.value );  
LogMessage( "Z next: " + oObjectNext.posz.value );  
------------end of script---------------------

Matt

* * *

Matt Lind  
Animator / Technical Director  
Softimage certified instructor:  
 Softimage|3D  
 Softimage|XSI  
speye\_21@hotmail.com

---

<div class="post-metadata">

### Author: ![wolfinger](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/w/d78d45/32.png) [@wolfinger](https://forum.highend3d.com/u/wolfinger)
#### Post date: [October 16, 2001, 6:38pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/6 "2001-10-16T18:38:46Z")

</div>

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...

---

<div class="post-metadata">

### Author: ![wolfinger](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/w/d78d45/32.png) [@wolfinger](https://forum.highend3d.com/u/wolfinger)
#### Post date: [October 16, 2001, 6:47pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/7 "2001-10-16T18:47:19Z")

</div>

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...

---

<div class="post-metadata">

### Author: ![devdoka](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@devdoka](https://forum.highend3d.com/u/devdoka)
#### Post date: [October 16, 2001, 7:51pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/8 "2001-10-16T19:51:12Z")

</div>

@@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.

---

<div class="post-metadata">

### Author: ![devdoka](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@devdoka](https://forum.highend3d.com/u/devdoka)
#### Post date: [October 16, 2001, 7:56pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/9 "2001-10-16T19:56:09Z")

</div>

@@ 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.

---

<div class="post-metadata">

### Author: ![wolfinger](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/w/d78d45/32.png) [@wolfinger](https://forum.highend3d.com/u/wolfinger)
#### Post date: [October 16, 2001, 8:32pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/10 "2001-10-16T20:32:41Z")

</div>

Um, does that mean that whatever I learn now will be obsolete in a week or two? that would be a major bummer...

---

<div class="post-metadata">

### Author: ![wolfinger](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/w/d78d45/32.png) [@wolfinger](https://forum.highend3d.com/u/wolfinger)
#### Post date: [October 16, 2001, 8:47pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/11 "2001-10-16T20:47:08Z")

</div>

Methods under E:

> [@](#):
>
> In reply to:   
> E
> 
> Elements  
> ElementsOffsets  
> ElementsValues  
> EndSubComponent0D  
> EpsilonEquals  
> EpsilonEquals  
> Equals  
> Equals  
> EvalExecuteCommand  
> ExecuteScript  
> ExecuteScriptProc  
> Expand  
> Extremities  
> ExtremitiesPosition

No go there =/

---

<div class="post-metadata">

### Author: ![wolfinger](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/w/d78d45/32.png) [@wolfinger](https://forum.highend3d.com/u/wolfinger)
#### Post date: [October 16, 2001, 8:52pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/12 "2001-10-16T20:52:25Z")

</div>

or did you mean the Eval method? It's only available for FCurves if I can read that info right.

I was under the impression that having FCurves needs keyframe animation, i.e. constraint animation isn't sufficient.

---

<div class="post-metadata">

### Author: ![devdoka](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@devdoka](https://forum.highend3d.com/u/devdoka)
#### Post date: [October 16, 2001, 9:15pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/13 "2001-10-16T21:15:53Z")

</div>

Oooops!

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

---

<div class="post-metadata">

### Author: ![wolfinger](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/w/d78d45/32.png) [@wolfinger](https://forum.highend3d.com/u/wolfinger)
#### Post date: [October 16, 2001, 9:36pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/14 "2001-10-16T21:36:00Z")

</div>

ookey! thanks again ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/smile.gif)

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.

---

<div class="post-metadata">

### Author: ![wolfinger](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/w/d78d45/32.png) [@wolfinger](https://forum.highend3d.com/u/wolfinger)
#### Post date: [October 16, 2001, 10:07pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/15 "2001-10-16T22:07:10Z")

</div>

> [@](#):
>
> In reply to:   
> Kinematics.Global
> 
> Description
> 
> Return or set the global transformation of object  
> Issue
> 
> read-only; implemented as parameter
> 
> Return Value
> 
> Transform

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?

---

<div class="post-metadata">

### Author: ![devdoka](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@devdoka](https://forum.highend3d.com/u/devdoka)
#### Post date: [October 16, 2001, 10:14pm UTC](https://forum.highend3d.com/t/scripted-operator-only-works-in-the-script-editor/61093/16 "2001-10-16T22:14:48Z")

</div>

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.
