Community
Maya Forum
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

About maya's expression

2 REPLIES 2
Reply
Message 1 of 3
ozzy_n
55 Views, 2 Replies

About maya's expression

I have an expression that was working in 2016 and earlier.

I can confirm that they do not work in 2020 and later versions.

 

For example, the following expression

float $x = `getAttr pSphere1.tx`;
setAttr pCube1.tx $x;

 

In this case, the content is simply the same as pCube1.tx = pSphere1.tx; and

It works fine that way, but

I want to use the mel command to reproduce the delayed following movement by expression.

However, the latest version of maya doesn't work well.

 

Was there a specification change at the time of some version upgrade?

2 REPLIES 2
Message 2 of 3
brentmc
in reply to: ozzy_n

Hi,

Although setAttr / getAttr in Maya expressions are technically allowed (because expressions can call MEL commands) they are not recommended and may not evaluate properly.

When you use getAttr/setAttr Maya doesn't create input/output connections on the expressions node. Without these connections the expression node cannot be properly scheduled and this is even more important in newer versions of Maya that use parallel evaluation and caching.

As a first step try replacing your setAttr calls with direct connections in the expression and see if that improves things. Otherwise you might be able to using something like the Delay node in MASH instead of an expression?

There is a small note about this in the Maya documentation under "Advanced Animation Expression Topics":

https://help.autodesk.com/view/MAYAUL/2024/ENU/?guid=GUID-9E3669B0-43B6-4B93-9494-C20439B87FD0

Note: It is not recommended to use a MEL script to access an object's attributes. Using a MEL script creates difficulties as doing so obscures connections between nodes in the evaluation graph, which are required to function properly. For example, a status-related expression such as the size of a cache file or the current time of day will not evaluate automatically. As these events are not driven by animation, Maya won't evaluate them until you toggle the "animated" attribute. (Using MEL scripts works occasionally because, in a few cases, the expression is in the evaluation graph due to one or more of its input attributes being animated.) However, we recommend using the direct method, described here, for consistent results, instead of MEL Scripts.
Brent McPherson
Principle Engineer
Message 3 of 3
ozzy_n
in reply to: brentmc

Hi brentmc, thanks for your reply.

It was working in 2016 and when I looked up how to track it with a time delay, all the articles that came up were using mel, so I was worried.

I will study the advice you gave me and the links you provided. Thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report