Formatting Time in Font COP

   5268   6   1
User Avatar
Member
132 posts
Joined: July 2007
Offline
Hello all.
I've had a heck of a time getting something (apparently) simple to work and would appreciate any pointers:
I'm trying to display the elapsed seconds on my animation using a COP Network.
Using $T in the Text field produces too many significant digits so I was trying to find a way to get, say %3.2f (in sprintf talk). That is, tenth and hundredth places.
My great idea was to use hou.time() in the following:
“%3.2f”%hou.time()

I had a bit of an issue getting this to work at first since I seemed to need a keyframe that didn't exist at first.
But, after adding a keyframe at 1 and using this (along with switching the interpreter to python from hscript) it did work in the viewer.

But..the renders hung on the first frame.
Moving to version 10 seemed to fix this but then certain frames were getting garbled.
I also found that the file would hang upon loading “some” of the time.

In conclusion: Lots of weird issues springing up after adding this font node with that expression. Switched to XP and same issues, more or less.
Any thoughts?
I'm going to just leave it as frames or look for a formatting solution in HScript for now but I really am dismayed to bump into such trouble on such a simple part of my project and not have much of an idea of how to fix it or why it's happening.

The OSX console showed “No Drawable” during the file load hanging.

System: Macbook Pro, Houdini 9.5.379 and 10.0.249.5, Windows XP (32) and OSX (both versions, both OSes).

Thanks!
User Avatar
Member
132 posts
Joined: July 2007
Offline
I found a solution that will work for me:
Avoiding python entirely, I can use:
`round($T*100)/100`

I still wonder why the python route caused such trouble?
Is it something about using python in a string expression?
Hmm…
User Avatar
Member
7710 posts
Joined: July 2005
Offline
You can't use python with backticks on string parameters. You have to create a channel on your string parameter, change its language to python, and then use your python expression.
User Avatar
Member
132 posts
Joined: July 2007
Offline
When you say “create a channel on my string parameter”, do you mean create a keyframe on the existing text parameter or something else?

I wasn't using back ticks with python. I just returned to back tick expressions when my python code made things go haywire as per my original post.

Thanks for your idea.
User Avatar
Staff
3455 posts
Joined: July 2005
Offline
you may want to have a look at this:
http://www.sidefx.com/index.php?option=com_content&task=view&id=1500&Itemid=132 [sidefx.com]
04 Building a Time Code -
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
132 posts
Joined: July 2007
Offline
Thanks for the link, Michael, that WAS handy.

So, I still wonder how Python can effectively replace this (since I thought it was the future), but here's what I'm going with for an HScript solution that works nicely:

time: `padzero(trunc(2,$F/$FPS))`:`padzero(2,$F%$FPS)`
User Avatar
Member
7710 posts
Joined: July 2005
Offline
len
When you say “create a channel on my string parameter”, do you mean create a keyframe on the existing text parameter or something else?

I mean: go to frame 1, then right-click on the parameter and choose Channels and Keyframes > Set Keyframe
  • Quick Links