SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

SM Forums / Maya Questions / Programming / Simple Expression not working!

Programming MEL Scripts, Expressions & Programming Related Topics

Join the conversation. Reply to post
Thread Tools
06-02-2020, 11:11 AM   #1
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
  Reply with quote
07-02-2020, 02:57 PM   #2
Super Moderator
Gen's Avatar
Join Date: Dec 2006
Location: South FL
Posts: 3,518
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 ||::
  Reply with quote

Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple rigging help... DaveJH Animation 0 04-03-2019 09:59 PM
Simple Expression please help! takecake Programming 1 11-02-2017 03:20 PM
simple expression question lxhtin Dynamics & Special Effects 0 04-11-2012 08:52 PM
Simple animation between keyframes not working 3dviz Maya Basics & Newbie Lounge 8 07-10-2012 10:23 PM
deplicate special Not working Need Help From simple maya hicham07 Maya Basics & Newbie Lounge 2 27-07-2012 06:45 PM