View Full Version : Maya doesn't update attributes while executing script?

12 December 2010, 01:33 PM
So.. the script I'm working on are supposed to activate a VRay attribute on a shaderEngine -node and then set the value... simple enough eyh?
For some reason Maya doesn't know that the attribute exists unless the script is done executing. After the script is done, there's no problem accessing the attr from mel but there's no way to do it from within the script.

It should be as simple as:
vray addAttributesFromGroup $shaderEngineHandle vray_roundedges 1;
setAttr ($shaderEngineHandle + ".vrayRoundEdgesRadius") $roundEdgesVal;

Error: setAttr: No object matches name: <SGname>.vrayRoundEdgesRadius

I've tried "refresh", "updateAE", "refreshAE"... what am I doing wrong?

12 December 2010, 01:41 PM
I take it <SGname> is something you've edited into that error report, and not what the actual error prints out? If not then your $shaderEngineHandle seems to contain the wrong string data.

I assume that the attribute you are trying to set is added by the vray function somehow? It would appear that it is not creating them there and then in script-time so they do not exist when you come to the next setAttr line. You could try evalDeferring your setAttr lines which would wait until idle time (by which time the attrs would presumably exist).

evalDeferred("setAttr "+$shaderEngineHandle+".vrayRoundEdgesRadius "+$roundEdgesVal);

12 December 2010, 01:54 PM
Yea, since the SG-name didn't realy mattered I edited that out. But what you say totaly makes sense and evalDeferred worked beautifully!
Thanks a bunch!

CGTalk Moderation
12 December 2010, 01:54 PM
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.