I have created a MNodeMessage callback targeted for a specified image plane node. This callback is effected only when User tries to make any changes towards the shape attributes.
def img_plane_attr_callback(msg, plug, *clientData):
attr_fullname = str(plug.partialName(useLongNames=True))
node_shape = OM.MFnDagNode(plug.node()).fullPathName()
if attr_fullname in ["maintainRatio", "width", "height"]:
update_size(node_shape)
elif attr_fullname in ["imageCenterX", "imageCenterY", "imageCenterZ"]:
update_position(node_shape)
else:
pass
While this seems to work for what I am trying to achieve, do I need to consider factoring in msg
so as to ensure that I am not capturing other events? Or if there is a better way to improve the above code?
P.S: I did not use msg
as it is the sum of the enum - from the static public attributes (eg. setting a new value: (kAttributeset) 8 + (kIncomingDirection) 2048 = 2056)
And because of the number of possible actions that can happen on the attributes (key/ unkey/ lock/ unlock etc) the values can varies and hence I thought it will be easier to filter it by the attribute names…