On Wed, Jun 12, 2019 at 12:06 PM yann19 <yangki...@gmail.com> wrote: > 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? >
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_maya+unsubscr...@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 > <https://groups.google.com/d/msgid/python_inside_maya/a3e88d80-ab9a-4d07-a0cb-e139fa1f93ed%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA0pMfAZQZ3PDfQATBBjtywaOBKSZcbWDWaBYC%3DAaUVyTA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.