View Single Post
# 5 14-01-2003 , 07:27 PM
mark_wilkins's Avatar
Registered User
Join Date: Jan 2003
Posts: 161
Remember, custom attributes do not have to appear in the channel box, nor do they have to be keyable. If you make them non-keyable, they won't appear in the channel box in any case. Also, if you use the addAttr command to make them, you can use the -hidden option which will leave the attribute keyable but will keep it from appearing in either the attribute editor or the channel box.

Let me be more clear about why using global variables in this way concerns me: Maya does a fairly complex analysis of the connections between nodes in your scene to make sure that it's recalculating what needs to be recalculated for each frame. If the *attributes* connected to an object expression node (which is not strictly applicable to your case because you're using particle expressions, which are different) do not change, that expression will never be recalculated, even if the expression itself depends on data you've gotten from other kinds of sources, like from a call to a MEL command like getAttr (which does not form a connection in the DG to your expression node) or from a global variable.

Also, Maya uses these connections to figure out in what order to execute expressions. When you use global variables or getAttr to grab data from elsewhere in the scene, Maya can't always figure out how to correctly evaluate the scene, which is what you've experienced. This means that when your scene does update it may update incorrectly.

The reason you've not had the first kind of problem (where things don't update at all, instead of updating incorrectly) is that you're using this approach with particle expressions, which are guaranteed to run every frame for every particle, instead of with object expressions, which are not so guaranteed. Even so, you still can't count on your scene being evaluated in any particular order unless you have the DG connections in place to let Maya know that it needs to evaluate things a certain way -- and that might mean making custom attributes.

There may be a safe way to use global variables in this way, and I have no doubt that it works some of the time, but I'm not sure that I know what the preconditions are for such an approach working and I VERY much doubt that Secrets of the Pros discusses that aspect of the problem. user added image

-- Mark


Mark R. Wilkins
author of MEL Scripting for Maya Animators
www.melscripting.com