Last active
February 27, 2019 08:22
-
-
Save patwooky/999c4de50c221bc2db75f4b64911c44a to your computer and use it in GitHub Desktop.
20190227 Maya Line up Solve Group to Cam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymel.core import * | |
def lineup_cam_grp(solveGrp, targetCamXform, startFrame=993): | |
''' | |
This function takes a freshly imported solve and lines it up to an existing camera, | |
matching position and rotation. | |
These are the things that happens in the script | |
- finds camera and cam shape in solve group | |
- moves keyframes by 993 frames (by default) to the first frame of the seq | |
- create a group aligned to the solved camera | |
- parent the solve group into the new group | |
- align the group to the targetCamXform | |
- set near / far clip | |
- set frame range to start frame | |
''' | |
camShape = listRelatives(solveGrp, ad=True, type='camera') | |
if not camShape: | |
print('no cameras found') | |
return | |
# gets the first camera found. one solve group usually only has a single camera | |
camShape = camShape[0] | |
camName = listRelatives(camShape, parent=True, type='transform')[0] | |
animObjsList = [camName, camShape] | |
for thisObj in animObjsList: | |
keyframe(thisObj, e=True, animation='keysOrObjects', option='over', | |
relative=True, timeChange=startFrame) | |
newGrp = group(name='{}_{}_grp'.format(solveGrp, camName), empty=True) | |
parent(newGrp, camName) | |
xform(newGrp, a=True, translation=[0,0,0], rotation=[0,0,0]) | |
parent(newGrp, None) | |
parent(solveGrp, newGrp) | |
myConstraint = parentConstraint(targetCamXform, newGrp, maintainOffset=False) | |
delete(myConstraint) | |
camShape.farClipPlane.set(50000) | |
camShape.nearClipPlane.set(0.1) | |
# loops through imageplanes | |
[PyNode(imagePlane(x, q=True, camera=True)) for x in ls(type='imagePlane')] | |
''' | |
setAttr "|transform1|Camera01Plane.alphaGain" 0.468041; | |
setAttr "|transform1|Camera01Plane.depth" 1; | |
''' | |
playbackOptions(min=startFrame, animationStartTime=startFrame) | |
# end lineup_cam_grp() | |
lineup_cam_grp(ls(sl=True)[0], ls(sl=True)[1], startFrame=993) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment