Auto-Update Script Controller

Auto-Update Script Controller

info
Contributor Contributor
844 Views
5 Replies
Message 1 of 6

Auto-Update Script Controller

info
Contributor
Contributor
Hello Community,

is there a way to make a script controller always update himself (evaluate the value) when an object is moved?

In detail:

I am scripting a controller to attache a dummy's position to a vertice position of a different object. So far so good (and so simple 😉

But it would be more elegant, if the dummy would update its position, when ever the object is moved.

Kind regards
Arnim
0 Likes
845 Views
5 Replies
Replies (5)
Message 2 of 6

info
Contributor
Contributor
I have found a solution:

Simply add a "dependson" <node> to the top of the script.

Kind regards
Arnim
0 Likes
Message 3 of 6

Steve_Curley
Mentor
Mentor
Then read the help for DependsOn to find that it has been deprecated for many versions and should not be used in new scripts as it could be removed at any time (which is what deprecated means), thus breaking your code.

Assuming your object is an Editable Poly:-
Assign a Position Script in place of the normal PositionXYZ controller (on the dummy)
Create a variable (I used theBox) and click Assign Node (choose the object).

in coordsys world (polyOp.getVert theBox 1)

Works fine here. When moving the box the Dummy stays glued to vertex 1 of the box. Why yours isn't I don't know, you would have to post the code.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 4 of 6

info
Contributor
Contributor
Hello Steve,

thanks for your reply.

Now, I have found the mistake. I was working sluttishly (?). I thought, it wouldn't matter if I descriped the "snap-to-object" with its original name ($sphere) instead of a nodename defined within the controller. Stupid me...

It works fine, when I set it up more carefully 😉

Kind regards
Arnim
0 Likes
Message 5 of 6

Steve_Curley
Mentor
Mentor
That would work (with dependsOn) in earlier versions where the Script Controllers were little more than the script and variables. Problem with that method, apart from the dependsOn issue, it that if you were to rename $sphere to something else, the script would fail. With the new method the controller link is to the node (object) rather than the name of the object, so changing the name shouldn't affect the script.

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 6 of 6

info
Contributor
Contributor
Yes you're right. I simply was too lazy. As it was a quick try, I did not care if the name would change later...

But it is an important lesson for me, how script controllers work.

And thanks again for your warning about the probable removal of 'dependson'.

This will save a lot of work in the future...

Kind
Regards
0 Likes