|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| built in ObjectSet variables break when using certain scripted controllers
|
|
|
I have already logged this with the Bug Submission form, but I thought I would cross post this here. If you get a chance please try this and help me confirm this problem.
1) begin with a fresh scene
2) create a rectangle
3) in the Curve Editor, change the width controller of that rectangle to a Bezier Float
4) add a scripted controller to the rectangle’s transform/scale
5) edit script controller:
5a) create a variable called test, assign the rectangle as a node.
5b) add the following script line above the default [1,1,1]:
“deletekeys test.width.controller #allkeys”
6) with the time slider at 0, in the script listener do a “print cameras”, it should print OK
7) change the time slider to any other time (positive or negative). running the “print cameras” gives a “** system exception **”
A scripted controller using the deleteKeys function on an object causes several global variable to break on frames other than 0
The effected variables I have found are:
geometry
lights
cameras
helpers
shapes
systems
spacewarps
I have not tried any other functions other than deleteKeys, it’s possible that others may cause the same problem.
I have confirmed this in 2009 x32, 2009 x64, 2011 x32, 2011 x64 and 2012 x64
-Ray
Ray Collett - Technical Director - Newlands & Company Inc.
|
|
|
|
Self-refs in script controller is not a good idea at all, so am not sure this is a real bug. I put the “print cameras” inside the expression and then it gives error even on frame zero.
Max 9 through 2009, XP-Pro x64 SP2
ASUS EAH3450 Series (Driver 8.470).
Core 2 Duo E8400 3GHz, 4Gb Ram, DX9.0c.
| Attachment
|
|
|
|
|
Anubis 22 May 2011 12:57 AM
Self-refs in script controller is not a good idea at all, so am not sure this is a real bug. I put the “print cameras” inside the expression and then it gives error even on frame zero.
I have a script for submitting jobs to backburner that we have used for several years. Within that script, I query the $cameras variable. It broke on Friday, and it took a bit of searching to narrow down the cause. One of my artists wrote a scripted controller that adjusted the width of an object and he added the deletekeys function to it so that scrubbing the timeline with the animate button in the ON state would not create unwanted keys. The two scripts are unrelated. I don’t see anything in the manual that says that using the deletekeys in a scripted controller will cause built-in variables to break. Seems like a bug to me.
edit: BTW, We don’t get an illegal self-reference error.
Ray Collett - Technical Director - Newlands & Company Inc.
|
|
|
|
This is not new, I just tested it in Max9 and got exactly the same results.
I suspect it may be because those globals are a subset of “everything” - possibly created by the equivalent of
for o in objects where superclassof o == camera collect o
every time they are referenced (pure guesswork, but that’s how it seems), which would mean it is looking at ALL scene objects, including the one to which the script controller is attached, thus causing the self reference error.
Note that the “test” variable is utterly irrelevent here - any script controller (without any defined variables or “$” references to the same or other objects) will give the same (self reference) error if you “print <selection>” inside the controller script. Quite why the difference between frame 0 and any other frame (listener command) is beyond me, but as mentioned earlier, is the same in Max9, so not a new problem.
I must say that what is being done there is decidedly “bad practice” - having got it working I can see the trackview constantly refreshing even when the PC is just sitting there untouched. Too many controllers like that and you’ll slow Max down to the point where it’s unusable.
I would suggest that moving the DeleteKeys from the script controller to the script which submits the BB job would be a better solution, or a separate script which removes keys from all tracks which have have the original script attached to them.
Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.
|
|
|
Steve_Curley 22 May 2011 06:31 AM
Note that the “test” variable is utterly irrelevent here - any script controller (without any defined variables or “$” references to the same or other objects) will give the same (self reference) error if you “print <selection>” inside the controller script. Quite why the difference between frame 0 and any other frame (listener command) is beyond me, but as mentioned earlier, is the same in Max9, so not a new problem.
Just to be clear here, I’m not suggesting that the “print <selection>” command goes inside the scripted controller, that was something that Anubis did. The script that my artist created is quite a bit more complicated than just the deletekeys command. I suppose I could of included it in my posting, but I was trying to simplify things a bit. Basically, it has several node variables, it does some math to calculate the distances between those nodes and then assigns a computed value to the rectangle width. The deletekeys is the last command in the controller so that keys don’t get inadvertently created if the user turns on the AutoKey mode.
The scripted controller that we use has no illegal self reference errors or warnings.
Off the top of my head, a close approximation of the script goes something like this:
--These would be node variables, not baked into the script
ObjA = $sphere01
ObjB = $teapot01
--Find half the distance, assign to width, purge any unwanted keys
objDist = distance ObjA ObjB
test.width = objDist / 2.0
deleteKeys test.width.controller
Steve_Curley 22 May 2011 06:31 AM
I must say that what is being done there is decidedly “bad practice” - having got it working I can see the trackview constantly refreshing even when the PC is just sitting there untouched. Too many controllers like that and you’ll slow Max down to the point where it’s unusable.
Do you have a better way of having an object self compute it’s width, while also making sure that it does not get plagued by auto created keys? We’ve had similar scenes with several dozen of these kinds of objects and never really noticed much of a slow down. I’ve also never seen the trackview constantly refresh like you describe. Is that because of the print command?
Steve_Curley 22 May 2011 06:31 AM
I would suggest that moving the DeleteKeys from the script controller to the script which submits the BB job would be a better solution, or a separate script which removes keys from all tracks which have have the original script attached to them.
The script that submits BB jobs is unrelated to the objects that have the scripted controllers. It’s a generic script that we use on every job, and to customize it to look for certain types of objects and delete keys from specific controllers is out of it’s scope. I could possibly see creating a custom script for this specific job that does the deletekeys, but the point of putting the deletekeys command into the scripted controller is so that an artist can freely make clones of that object without having to edit scripts or update lists of objects that need special attention. Also, if someone unfamiliar with the problem pops into that scene, turns on auto key to make some changes and then fails to run that special script, then unwanted keys are introduced.
Thanks for the help!
Ray
Ray Collett - Technical Director - Newlands & Company Inc.
|
|
|
Just to be clear here, I’m not suggesting that the “print <selection>” command goes inside the scripted controller, that was something that Anubis did.
True, but none the less it DOES cause a Self Reference exception despite nothing being actually referenced in the controller script. This may or may not be relevent, but is strange enough to raise a few eyebrows.
I’ve also never seen the trackview constantly refresh like you describe. Is that because of the print command?
No - it was the DeleteKeys. It was quite subtle, but definitely there.
Do you have a better way of having an object self compute it’s width
Well, you could just put the Script Controller directly on the Width… I fail to see any benefit to a script controller on the Scale controlling the Width of the same object.
There are times when such methodology is useful, like changing the Text value of a Text object (shape) which can’t be done directly because there’s no “text” property available to assign a controller script to in the first place.
If the Width is controlled by a Script Controller there’s no way to force keys onto that track even if you wanted them - the Width spinner on the Modify Panel is “greyed out” and cannot be changed - regardless of Autokey.
Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.
|
|
|
|