Introduction to Maya - Modeling Fundamentals Vol 1
This course will look at the fundamentals of modeling in Maya with an emphasis on creating good topology. We'll look at what makes a good model in Maya and why objects are modeled in the way they are.
# 1 06-02-2020 , 11:11 AM
Registered User
Join Date: Feb 2020
Posts: 1

Simple Expression not working!

Hi, can anyone tell me why this expression is not working in Maya 2017 or Maya 2020 when it does work in Maya 2015!?



float $newPosn ;

if (frame == 1){

$newPosn = 0.0;

}

pCube1.translateY = $newPosn;

$newPosn = $newPosn + 1.0;



It is driving me mad as I need to do something more complicated than this, but using the same principle of incrementing by a value each frame!



Thanks in advance!


Last edited by azurecgi; 06-02-2020 at 11:22 AM. Reason: typo
# 2 07-02-2020 , 02:57 PM
Gen's Avatar
Super Moderator
Join Date: Dec 2006
Location: South FL
Posts: 3,522
I'm guessing frame is supposed to be the current frame. If that's the case then querying the currentTime command is what you want to do. Basically, anything within the `` will be evaluated so you can get a usuable value that you can assign to a variable or compare to another value or whatever. And to assign your $newPosn value to the cube's translateY, then you want to use the setAttr command.


float $newPosn;
if (`currentTime -q` == 1){
$newPosn = 0.0;
}
setAttr pCube1.translateY $newPosn;
$newPosn = $newPosn + 1.0;


- Genny
__________________
::|| My CG Blog ||::
::|| My Maya FAQ ||::
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads