Counting Up a Digital Time/Temperature Reading w/ Python

Counting Up a Digital Time/Temperature Reading w/ Python

andymc4997
Advocate Advocate
343 Views
2 Replies
Message 1 of 3

Counting Up a Digital Time/Temperature Reading w/ Python

andymc4997
Advocate
Advocate

Hi everyone, I hope you're having a good weekend!

 

Could a Maya Python programmer give me an idea of how to animate both a digital timer and a temperature reading using Type objects?

 

I've attached a rough draft video of what I've crudely created with just a an Animated Text Generator (with yes, lots of tedious keyframing :/). 

 

I need the temp to not have a decimal place, and the timer to be standard minutes : seconds. 

 

Both readings count up to 400 and 4:00 respectively from a certain frame (in this animation frame 20) to the last.

 

I've looked all over the web and there doesn't seem to be a video/tutorial showing how to do this. As you can surely tell, I'm no programmer!

 

Thanks in advance for any/all help!

0 Likes
Accepted solutions (1)
344 Views
2 Replies
Replies (2)
Message 2 of 3

Kahylan
Advisor
Advisor
Accepted solution

Hi,

I highly recommend, that if you plan to continue doing highly technical stuff like this in Maya, you learn Python coding yourself. Writig stuff like this, especially in single line expression format, is quite tedious. You were lucky, that I had some free time on my hands today and that I actually looked into doing different kinds of clocks a while ago for a tutorial I plan on making.

Here is the python expression for the Temp:

startValue = 0; endValue =400;startFrame = 20; endFrame = 100; step =((endValue-startValue)/(endFrame-startFrame));time = cmds.getAttr("time1.outTime"); value1 =max(startValue, round((time-startFrame)*step));min(value1, endValue);

this is the one for your digital clock:

startDayTimeInMinutes = 0; endDayTimeInMinutes =240;startFrame = 20; endFrame = 100; step =((endDayTimeInMinutes-startDayTimeInMinutes)/(endFrame-startFrame));time = cmds.getAttr("time1.outTime") ;valueMinRange =max(startDayTimeInMinutes,((time -startFrame)*step));valueMaxRange =min(endDayTimeInMinutes, valueMinRange) ;hours =  round(valueMaxRange/60);minutes = (round(valueMaxRange))%60;output =f"{hours:02d} : {minutes:02d}";output

 

by changing the values in the first 4 variables, you can change the range of numbers/time your animation does as well as the start and end time of your animation. The variable Names should be self explanatory.

If you have any further questions, let me know.

I hope it helps!

0 Likes
Message 3 of 3

andymc4997
Advocate
Advocate

@Kahylan Wow, thanks so much for this very quick reply, and for providing the code!

My 3D work primarily consists of more artistic renders/animations as well as product shots for marketing purposes, so no, I don't to a lot of technical things like this. I've considered learning Python/MEL, but haven't quite justified the time dedication yet. Being a husband/father/musician.. bla bla also plays into it for me ;). 

 

So anyway.. with not being a programmer, I wasn't aware of how tedious this type of code might be, so I apologize for being naive to that.

This will help me immensely on this project, so thanks again!

0 Likes