Notifications
Clear all

[Closed] Quick question regarding float_script

Hi,

I wrote this today:

 for i = 1 to oneArray.count do 

(

o = oneArray[i]

oString = o.name as string 

r = twoArray[i]

rString = r.name as string

oH = float_script()

o.height.controller = oH

oH.script = ("$"+oString+".height = "+"$"+rString+".height")

oL = float_script()

o.length.controller = oL

oL.script = ("$"+oString+".length = "+"$"+rString+".length")

oW = float_script()

o.width.controller = oW

oW.script = ("$"+oString+".width = "+"$"+rString+".width")

)


When I change the o.height r.height changes as well. r.height is not highlighted so I can’t change it by typing adressing that a controller is in charge of the property. The thing is that it does not change the geometry in my viewport as I thought it would do. It might be something simple but so far I was unable to figure it out. Any ideas?

Many thanks

Guimassssssss…

6 Replies

Scripted controllers do not update automatically unless they have an explicit reference to another object to depend on.

Prior to Max 8, this was done using dependsOn().
Since Max 8, the code you wrote is considered obsolete – you are supposed to use the new variables in the script controller to connect to the referenced objects – this will not only make the scripted controllers independent of name changes, but also cause automatic updates when parameters they reference have been changed.
Please consult the MAXScript Reference of Max 9 or 2008 for details. (the Max 8 version of the reference was missing the documentation of the necessary interface)

thanks Bobo for your quick reply,

Yes I do have Max 8 here at the office but even though I manage to download the version 9 MAXScript reference I still do not undertand how it works, and I apologize for that. I am a big fan of Max help. Well I am trying to get to understand the concept doing it by hand before going into scripting and it does not work. If someone can give me a hand on that it would be great.

Please see the code sample (first try) and the one that I did using the Script Controller Editor in the attached jpg. I am just trying to figure out how it works. Would be something like instances, if I change the radius of one the second will follow automatically without the need of pressing the evaluate button. Is it possible?

Thanks for any help

G

Have you looked at wiring the radiae (sp?) together? It’s a little simpler than using a script controller because both objects are already specified: select one object; right click and wire; select the object’s radius from the list; then navigate the dialogue to the other object’s radius; be sure to have a two way connection and now the two should be linked forever.

That’s really cool, thanks a lot!

Looks a lot with what I’ve seen with maya. Mate just a question though, this is not working with knots, vertexes, etc… I would like, if it is possible to see a line of code that shows how to reference an object and how to access a property of this object in a scripted controller. Is it possible like in the parameter wiring that if you change one parameter from one object the other one changes as well using scripted controllers? I am finding the reference a little confusing… I’ll go more over it this weekend.

Thanks a lot again, I did not know about wiring parameters.

Yes, but it only goes one way. The object with the script becomes a “slave” of the unscripted object. If you want to get into moving verts around based on other parameters (like an other object’s radius) then, yes, you will have to use a script controller. There’s pretty good documentation on how to do this in the help (for all I know, Bobo wrote it).

Thanks James, I finally got the way to do it, so I will be able to apply the method in my future work.

 
[size=1]a = $Sphere01
 
b = $Sphere02
 
sC = float_script()
 
a.radius.controller = sC
 
--sC.AddTarget "sph2R" b[4][1]--same as line below
 
sC.AddTarget "sph2R" b[#Object__Sphere][#Radius]
 
sC.script = "sph2R"
 
[/size]

All I have to do is to find the subAnim that I want as a reference and add it as a variable to the script controller. Dude I was really lost on this. I would like to thank all you guys for making this an amazing forum.