Hi everyone, I had this weird issue with the use of MEventMessage for 
`timeChanged`

What I am trying to achieve is - When User scrubs the time slider, eg. from 
F1 to F10, the `timeChanged` event that I have created, will be picked up 
and returning me the current attribute of that frame.

Eg. I have created an imagePlane, set keyframe at F1 on its "Image center 
X" with the value of 1 and another keyframe at F10, with a value of 10.
As I create the following event:
def time_changed(*args, **kwargs):
    node = '|imagePlane1'
    node_shape = cmds.listRelatives(node, shapes=True, f=True)[0]

    axes_dict = {}
    for axis in ["X", "Y", "Z"]:
        value = cmds.getAttr("{0}.imageCenter{1}".format(node_shape, axis))
        axes_dict[axis] = value
    
    print axes_dict

time_changed_event = OM.MEventMessage.addEventCallback("timeChanged", 
time_changed)

When I click on the Time Slider to F5, the `axes_dict` returned me `{'Y': 
0.0, 'X': 0.0, 'Z': -50.0}` which is incorrect. It should be `{'Y': 0.0, 
'X': 4.4444, 'Z': -50.0}` (same values as shown in the channel box)
However if I go to F8 this time, the `axes_dict` though incorrect, it 
returns me the value of the 'previous' frame `{'Y': 0.0, 'X': 4.4444, 'Z': 
-50.0}` 

Am I using `timeChanged` incorrectly? I have tried using `cmds.refresh()` 
but it does not seems to work. 

Please advise.

-- 
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/41c870ce-45cd-4eff-8da3-659a14ff7d04%40googlegroups.com.

Reply via email to