Notifications
Clear all

[Closed] dependsOn

What has replaced dependsOn when used in the following format, i.e inside a script that assigns a script as a controller as in this simplified script. I understand how to do it manually, as in press the Create button and point to a node, but the manual says that dependsOn is redundant but offers no alternative that I can find – or at least understand.

delete $Point*
clearlistener()
pA=Point()
pB=Point()
pA.position.controller=position_script()
txt=”dependsOn $Point02

txt+=”aa=$Point02.pos

txt+=”aa -= [10,0,0]

[size=2]pA.position.controller.script=txt
[/size]

7 Replies
1 Reply
(@bobo)
Joined: 11 months ago

Posts: 0

This is an unfortunate ommision in the Help. (I take full responsibility).
What is missing is the documentation of the interface that allows you to create variables the same way you do in the UI (and in the corresponding, documented interface for Expression controllers).

Just type in

showInterfaces position_script

and you will get all methods to push buttons,create variables etc. in the new script controller.

Your code above will STILL work in 8 – dependsOn inside a script now creates implicitly a variable and assigns the node to it. So loading an old file from 6 or 7 with dependsOn in it will work with the new controllers without manual intervention…

The reason for warning that dependsOn is obsolete is this:
If you create a variable, assing a node to it, AND in addition add a dependsOn to the script code, you will end up with two redundant variables and pollute the controller. I don’t think it would have any bad side effects though…

anything that is a variable now updated the controller as if it were dependson

eg,
you have a variable pointing at a bezier_float controller
you dont need to mention it in the script,
when the controller changes the script controller updates

mark

Mark,
Thanks for the reply, but still don’t get it…surely this should update interactively when Point01 moves. And will it work when cloned?: –

p1=Point pos:[10,0,10]
p2=Point()
p2.position.controller=position_script()
p1.position.controller=Position_XYZ ()
txt=”aa=$Point01.controller

txt+=“bb = aa.position + [10,0,0]”
p2.position.controller.script=txt

Bobo thanks for reply I shall look into how that works…p.s I’m very new to this scripting,even though I’ve been using Max since it was on Dos. I blame your matrix DVD for getting me into this , which is great by the way and has opened up a whole load of questions for me, and solved a few !

Again thanks for both of you taking the time to reply.

are you assigning the variable with the script controller interface? (using the create button and then assigning to a node (assign node) or assign track or controller?

mark

No, I understand how that works, manually as it where, but I am trying to put a script inside a controller ( creating a scripted controller), using another script. Previously dependsOn would have been used to make the viewport interactive.
The trouble is that, as Bobo points out, there is no information for how to make a link with a node from another script. I think the answer is in what Bobo has posted,

i.e showInterfaces position_script
but it will take a while for me to get time to go through it and find which bit is relevant, (as this is new to me).
unless you know more than me which is highly probable…

to set a variable in a script controller using script, ok i didnt understand that this was what you were after at first

as bobo stated you need to use the undocumented commands to set it, i use it quite alot so i can help you there,

say you have two nodes mybox ($box01) and mysphere ($sphere01)
say you assign a script controller to the x position of mybox

fs = mynode.position.X_position.controller = float_script()
fs.addtarget “variableA” mysphere.position.X_position.controller – assign my spheres x pos controller as a variable
fs.script = “-variableA” – so the script evaluate to minus the spheres x pos controller value

this will update anytime the myspheres x position controller updates (moving it)

in the same way if you want to make an script controller dependant on a node by adding a node with addnode in the same way as above

fs.addnode “sphere” mysphere

hopefully this helps you understand

mark

got it – thank you !