float_script supported in Max7?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 05 May 2008   #1
float_script supported in Max7?

I've got a user running a script of mine who keeps getting the following error:

-- Unknown property: "addNode" in Controller:Float_Script

He's the only user (so far) with this problem. Would it have anything to do with the fact that he's using Max7? Many thanks.
 
Old 05 May 2008   #2
Yup - adding nodes and such like is a max 8+ thing.
You'll have to reference the node manually in your script for max 7, and use a "dependsOn".

Dave
__________________
Portfolio | Keyframes and Code
 
Old 05 May 2008   #3
Note that by "refer manually" - more correctly, "refer explicitly", you'll run into a problem (which is exactly why it was fixed in r8)...

If this is the script code (double a particular sphere's radius) in pre-r8:
$Sphere01.radius * 2


Then the object getting renamed - a rather benign operation - will make the script error out (unless there's another object named "Sphere01", of course).

Typical work-around for this is to reference the node's handle instead.

-- get $Sphere01's handle
theHandle = $Sphere01.inode.handle



theSphere = maxOps.getNodeByHandle <value of theHandle>
theSphere.radius * 2


Note that this will break if you merge the object that has the controller into a new scene, even if you merge $Sphere01 with it, as the node handle gets changed. So it's a 'unique ID', but only for any given scene. Which is poo, but there you go.

A bit more robus would involve you setting up a Custom Attribute, or use setAppdata, on Sphere01 and set a more unique value (perhaps using genClassID() or some other random generator that is likely to be unique), which you can then find again in the scene by looping over all the (appropriate) nodes yourself in the controller; this'll slow the controller down a good bit, so might be something you want to handle by only finding that object once, and then caching that object in a (global) variable.

Fun stuff, eh?
 
Old 05 May 2008   #4
Aha. Thanks, Dave.

Now, all my MXS experience is post-Max8, so bear with me here. I've currently got something like this:
-- make a box, a sphere and a dummy
b = box()
-- add a customAttribute "chum" to the box
custAttribute.add b ca
d = $dummy()
s = sphere pos:[50,0,0]
-- make the dummy the parent of the box
b.parent = d
-- make the sphere the box's chum
b.chum = s
-- create a float script
fs = float_script()
d.rotation.z_rotation.controller = fs
fs.addNode "obj" b
fs.script = "paramWire.connect2Way obj.rotation.controller[#z_rotation]\
obj.chum.rotation.controller[#z_rotation] (\"Z_Rotation\") (\"Z_Rotation\")"

In retrofitting this to be Max7-compliant, would the dependsOn go inside the fs.script? And would it read dependsOn b b.chum d ? Many thanks!

Edit: Thanks as well to you, ZBoxx (guess our posts crossed in cyberspace). My question remains, though, where to place that dependsOn. This business is hampered by the fact that I don't have direct access to Max7.

Last edited by bhnh : 05 May 2008 at 07:32 PM.
 
Old 05 May 2008   #5
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 10:31 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.