CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
Thread Tools Search this Thread Display Modes
Old 05-21-2008, 03:58 PM   #1
bhnh's Avatar
Bruce Hammond
Peterborough, USA
Join Date: Dec 2007
Posts: 107
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-21-2008, 04:44 PM   #2
davestewart's Avatar
Dave Stewart
Animator / scripter
United Kingdom
Join Date: Sep 2004
Posts: 488
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".

Portfolio | Keyframes and Code
Old 05-21-2008, 07:22 PM   #3
Lord of the posts
ZeBoxx2's Avatar
Richard Annema
Caustic Graphics / SplutterFish
Groningen, Netherlands
Join Date: Jul 2006
Posts: 1,461
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-21-2008, 07:26 PM   #4
bhnh's Avatar
Bruce Hammond
Peterborough, USA
Join Date: Dec 2007
Posts: 107
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-21-2008 at 07:32 PM.
Old 05-21-2008, 07:26 PM   #5
CGTalk Moderation
CGTalk Forum Leader
Join Date: Sep 2003
Posts: 1,066,478
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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Society of Digital Artists

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

All times are GMT. The time now is 03:17 PM.

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