Normalized Time

   417   4   0
User Avatar
Member
10 posts
Joined: Jan. 2017
Offline
I'm building a VEX snippet and I want a way to represent the current frame as a float between 0 and 1, 0 being the first frame and 1 being the frame range. I know that @frame can give me the current frame, but what VEX snippet do I need to get the last frame in my time slider?
User Avatar
Member
1479 posts
Joined: Sept. 2015
Offline
float Frame_Range, New_Value;

Frame_Range = 240;

New_Value = fit(@frame, 0, Frame_Range, 0, 1);
Edited by BabaJ - June 25, 2018 15:24:31
User Avatar
Member
10 posts
Joined: Jan. 2017
Offline
Thank you for the quick reply. This is what I have currently implemented. However, I was wondering if there was a piece of VEX code that would automatically put in the end frame, similar to $FEND when you're working with parameters
User Avatar
Member
1479 posts
Joined: Sept. 2015
Offline
I don't think Vex has direct access to the Frame Range values.

The only way I can think of is to create a parameter and use Python to ‘grab’ your current hip files Frame Range to put it there:

hou.playbar.playbackRange()[1]

playbackRange returns two values, first for the beginning frame range and the second the end, hence the one in square brackets.

Then in vex you could use a channel reference to get that parameter.

Now your saying your building a ‘snippet’ so I assume your inside a vop node, so I don't know if this will work there but it will for a wrangle node at the sop level.

You could use an Hscript reference with backticks.

float End_Frame = `$FEND`;

Edit: on an unrelated sidenote. I was just trying to figure out how to parse the lines of code in a wrangle with python. Looked at the parameter that holds the text, and it too is referred as a snippet.
Edited by BabaJ - June 28, 2018 11:38:20
User Avatar
Member
10 posts
Joined: Jan. 2017
Offline
Thank you! I'll try the backticks method.

I'm using a wrangle node, not a VOP node, so the the text isn't referred to as a snippet in that case?
  • Quick Links