Camera for compositors



Complication may arise sometimes, when we export camera from maya to compositing softwares.
The camera will be in a rig or in a group or multiple groups having constraints and troubles, OMG...

You can use below script (I have written both MEL and Python for convenient  usage )
just select the Camera and run!

Animation copy will be done to a duplicated camera which lies outside the group. It can be exported anywhere.



//MEL
string $Sel[] = `ls -sl` ;
select -cl ;
string $newObj[] = `duplicate $Sel[0]` ;
parent -w $newObj ;
string $PC[] = `parentConstraint $Sel $newObj` ;
bakeSimulation -t (`playbackOptions -q -min`+":"+`playbackOptions -q -max`) -sb 1 -at t -at r $newObj ;
delete $PC ;



#Python
import maya.cmds as mc
sel = mc.ls(sl=1)[0]
mc.select(cl=1)
newObj = mc.duplicate(sel)
mc.parent(newObj, w=1)
PC = mc.parentConstraint(sel, newObj)
mc.bakeSimulation(newObj, t= (mc.playbackOptions(q=1,min=1), mc.playbackOptions(q=1,max=1)), sb=1, at=["t","r"] )
mc.delete(PC)


 The script does the following tasks.
Make a duplicate of the camera for getting the same attribute values; unparent it; parentConstraint from the old one to new; bake keys
; delete the constraint node