Thanks again !
But your code has fundamental flaw - it works only if there's exactly one key.
What if there are keys for every frame? And these keys have the same values - ergo camera is fixed in space ?
"Delete Static Channels" detects this. Of course I can iterate every keyframe checking if it's changing value, but (as lazy as I am :) ) I hoped for some existing command.
Maybe event smth. that's more clever than just keyframes (ie. checking parents or constraints).
Worst case scenario is playback entire shot range and watch for camera worldSpace movements - but this is unacceptable (playback can be slow in lighting scenes).


W dniu 2015-04-17 o 14:09, Mahmoodreza Aarabi pisze:

Test this on single and multiple static channels. it work on camera and its shape’s keys of attributes:

from maya import cmds

def detect_static_channel():
    sels = cmds.ls(sl=True)
    objs = []
    for each in sels:
        obj_shape = cmds.ls(shapes=True)[0]
        objs.append(each)
        objs.append(obj_shape)
        for o in objs:
            attrs = cmds.listAttr(o, k=True)
            for at in attrs:
                key_count = cmds.keyframe((o + '.' + at), q=True, kc=True)
                if key_count >= 1:
                    values = cmds.keyframe((o + '.' + at), q=True, vc=True)
                    value = cmds.keyframe((o + '.' + at), q=True, vc=True)[0]
                    if all(item == value for item in values) == True:
                        temp_value = cmds.getAttr(o + '.' + at)
                        cmds.cutKey((o + '.' + at), cl=True)
                        cmds.setAttr((o + '.' + at), temp_value)

detect_static_channel()

Good luck
:)


On Fri, Apr 17, 2015 at 5:00 AM, Mahmoodreza Aarabi <madoo...@gmail.com> wrote:
i reach to good result for this
but this mel code create a camera that all keyable attributes have key, also some attributes like Focal Length, F Stop and others have key too.
do you want the code apply on keyable attrs or all?

On Fri, Apr 17, 2015 at 3:56 AM, f.michal <f.mic...@gmail.com> wrote:
As trivial as that MEL:

camera;
// Result: camera1 //
bakeResults -simulation true -t "1:24" -sampleBy 1 -disableImplicitControl true -preserveOutsideKeys true -sparseAnimCurveBake false -removeBakedAttributeFromLayer false -removeBakedAnimFromLayer false -bakeOnOverrideLayer false -minimizeRotation true -controlPoints false -shape true {"camera1"};
// Result: 18 //


W dniu 2015-04-17 o 12:37, Mahmoodreza Aarabi pisze:
can you share a simple scene that have the problem?

On Fri, Apr 17, 2015 at 3:13 AM, f.michal <f.mic...@gmail.com> wrote:
Thanks !
But static channals are also those who have many keys all with the same values - which is my case.
Bigger picture: I'm trying to determine if camera moves or not in a shot.
If it's static there's a potential advantage in render frame range on some passes.

W dniu 2015-04-17 o 12:07, Mahmoodreza Aarabi pisze:

Hello
Static Channels are related to when you set a single keyframe on an object
when you want to delete it you can do it with the menu you want.but if you want to detect a static channel on an animation curve of an object you can use this code:

from maya import cmds

sels = cmds.ls(sl=True)
keyCount = 0
for each in sels:
    attrs = cmds.listAttr(each, k=True)
    for at in attrs:
        keyCount = cmds.keyframe((each + '.' + at), q=True, kc=True)
        if keyCount == 1:
            tempValue = cmds.getAttr(each + '.' + at)
            cmds.cutKey((each + '.' + at), cl=True)
            cmds.setAttr((each + '.' + at), tempValue)

main snippet is this keyCount = cmds.keyframe('object.attr', q=True, kc=True) that return count of your keyframes on an object.

good luck



--
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/5530DCE7.7010001%40gmail.com.

For more options, visit https://groups.google.com/d/optout.



--


Bests,
madoodia
--
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/CADvbQw%2BAi%3DdpEy5M6pnUGyHFtET%3DtsZiryZG43F1Q0f16Wz8GA%40mail.gmail.com.
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/5530E6C0.7050704%40gmail.com.

For more options, visit https://groups.google.com/d/optout.



--


Bests,
madoodia



--


Bests,
madoodia
--
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/CADvbQwJ3--EoP4atUFVi8ysqDUCk4PsGtmQ%3DX%2BcRTOOgS6WK%3DQ%40mail.gmail.com.
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/5530F948.6000301%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to