Determine first and last frame from imagePlane node

14 views
Skip to first unread message

yann19

unread,
Jun 11, 2019, 8:06:21 PM6/11/19
to Python Programming for Autodesk Maya
I have an imagePlane node in which I am using an image sequence, say myPicture.001.jpg - myPicture.030.jpg.

However, on the same imagePlane node, I have also set its Frame Offset attribute with a value of -10, and so the image sequence will be starting off at Frame 11 and ends at Frame 41.

As I would like the imagePlane to hold first and last frame (eg. if I navigate to Frame 5, it will stays at myPicture.001.jpg, and if I navigate to Frame 50, it will stays at myPicture.030.jpg). While I understand that this 'holding' can be done with me removing the expression and sets a keyframe at Frame 11 and Frame 41 respectively, but this is doable if I am doing it manually within the scene.

My question here is how can I do this in a pythonic manner?
Initially, I tried to use `cmds.getAttr("{0}.frameExtension".format(my_imagePlane))` in hopes that it has a range of numbers and I can derive the first and last number from it. but I was wrong..

As the field is still driven by expression, how can I determine Frame 11 and Frame 41 are the frames that I should keyed?

Justin Israel

unread,
Jun 11, 2019, 10:52:20 PM6/11/19
to python_in...@googlegroups.com
If I understand you correctly, then maybe what you are after is to call 

    cmds.getAttr("{0}.frameOffset".format(my_imagePlane))
 
and do the math to derive the actual file number for a given frame.
The problem I see if that you can't really know the first and last frame number that the image sequence provides, without evaluating the image files on disk externally. Maya is just swapping in frame numbers and trying to load an image if it can.

I thought I might have a play with an expression that completely does the pre and post hold. Is this useful?

//---
int $first = 1;
int $last = 26;
//---

int $offset = imagePlaneShape1.frameOffset;
int $start = $first + ($offset * -1);
int $end = $last + ($offset * -1);

if (frame < $start) {
    imagePlaneShape1.frameExtension = $first;
    print ("pre-hold " + imagePlaneShape1.frameExtension + "\n");
} else if (frame > $end) {
    imagePlaneShape1.frameExtension = $last;
    print ("post-hold " + imagePlaneShape1.frameExtension + "\n");
} else {
    imagePlaneShape1.frameExtension = frame + $offset;
    print ("frame " + imagePlaneShape1.frameExtension + "\n");
}



Justin

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a3e88d80-ab9a-4d07-a0cb-e139fa1f93ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

yann19

unread,
Jun 13, 2019, 2:32:40 PM6/13/19
to Python Programming for Autodesk Maya
Hi Justin,

That does works, thank you!
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages