Is there an expression for end frame of timeline?

Is there an expression for end frame of timeline?

lms2k
Enthusiast Enthusiast
3,335 Views
6 Replies
Message 1 of 7

Is there an expression for end frame of timeline?

lms2k
Enthusiast
Enthusiast

I'm trying to make an attribute's value be the same number as the end frame of my timeline. 

 

This way, I will not have to re-enter the new end frame number every time I change the timeline.

 

Is there an expression for this? I am very green to expressions.

 

Thank you

0 Likes
Accepted solutions (1)
3,336 Views
6 Replies
Replies (6)
Message 2 of 7

trs_andre
Collaborator
Collaborator

Hi!

 

You can access the last frame of the timeline by typing:

 

`playbackOptions -query -maxTime`

 

Hope it helps!

André Moreira

Game Developer / Technical Artist

LinkedIn

Message 3 of 7

lms2k
Enthusiast
Enthusiast

Thank you for the help!

 

When I make an expression with,

playbackOptions -query -maxTime

and when I connect it to the attribute, it only displays 0. However when I type it in the MEL command line it displays the correct value. 

 

I posted a screenshot. Am I setting this up correctly? Thank you again.

 

 

 

 

 

 

 
 

 

0 Likes
Message 4 of 7

trs_andre
Collaborator
Collaborator
Accepted solution

Try right clicking the extra attribute of your object and add the expression from there.

And then write the expression as in the picture 😉

André Moreira

Game Developer / Technical Artist

LinkedIn

0 Likes
Message 5 of 7

lms2k
Enthusiast
Enthusiast

Wow I was so close to getting that result, but I deleted the '' marks! 

 

So YES, that worked! And I am so grateful. 

 

However the attribute doesn't seem to update when I change the end length of the timeline unless I go back in the expression editor and change the "evaluation" setting. Is this something you have encountered? 

 

If not that's alright and I can try to fix this and I can accept your answer as a solution. -- Attached are screenshots though of the attributes before and after I reloaded the editor. 
Oh I also made the attribute twice, one as an integer attribute and one as a float just to be thorough. Evaluation.PNGTimeline.PNGExpression_Float_and_Integer.PNG

Message 6 of 7

trs_andre
Collaborator
Collaborator

Glad it worked! 😃

Those `` can be easy to forget!

 

Yes, depending on the Evaluation method, Maya will evaluate the expression on different timings.

You can find an explanation below!

 

=====

When Evaluation is set to On demand, the expression calculates only when the input connection of your expression changes, or when you click Edit in the Expression Editor. When Evaluation is set to Always, every frame change triggers an evaluation even if nothing in the scene has changed.

=====

From: https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/Maya/fil...

André Moreira

Game Developer / Technical Artist

LinkedIn

0 Likes
Message 7 of 7

lms2k
Enthusiast
Enthusiast

Thank you for the extra info and all your help. I've accepted your post as the solution.

 

You've been a great and kind help!! 🙂