2 This is example code demonstrating how to add and remove MCameraMessages using the
7 import maya.api.OpenMaya
as OpenMaya
10 def beginManipCB(node, clientData):
11 print(
"Inside beginManipCB, clientData is %s"%clientData)
12 def endManipCB(node, clientData):
13 print(
"Inside endManipCB, clientData is %s"%clientData)
18 addCallbacksToPerspCamera()
20 def addCallbacksToPerspCamera():
26 maya.cmds.select(
'perspShape')
33 print(
"List length is %d"%slist.length())
37 while not iter.isDone():
40 dependNode = iter.getDependNode()
41 dagPath = iter.getDagPath()
42 print(
"Node: %s"%dagPath.partialPathName())
43 if (dependNode.hasFn(OpenMaya.MFn.kCamera)):
44 print(
"This is a camera, adding manipulation callbacks with payloads")
45 payloadBegin =
"12345.5"
46 payloadEnd =
"54321.5"
57 print(
"This node is not a camera...")
61 def removeCallbacks():
63 for id
in callbackIDs:
68 import cameraMessageTest2 as cmt2
70 maya.cmds.file(f=1,new=1)
74 cmt2.removeCallbacks()