Message 1 of 10
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
It is a script that I am designing to align a camera to another, at the time of eliminating the locator and the pairing does not happen.
- Creates a locator in the pivot of the selected camera
- Once the locator created and the camera root are selected, I link them with parent constraint
- Once the locator and the target camera "proxy" have been selected, I link the locator to the target camera.
At the end of all the steps I cannot delete the locator created nor the relationship.
It does not find them by name apparently.
cmds.delete(newparent)
cmds.delete(newLoc)
The example on the screen is 2 cameras, there is nothing special.
import maya.cmds as cmds
class MatchCamScript():
def __init__(self):
myWin = cmds.window(minimizeButton=0,maximizeButton=0,title="Match Cam", widthHeight=(150, 80))
cmds.columnLayout("mainColumn")
cmds.rowLayout( numberOfColumns=2, columnAttach=(1, "right", 10), columnWidth=[(1,143),(2,245)] )
self.button = cmds.button(p = "mainColumn",label="Camera Rig",width=148,align='center', command= lambda x: self.makelocator())
cmds.separator(p = "mainColumn")
self.button = cmds.button(p = "mainColumn",label="Root Camera Rig Selected",width=148,align='center', command=lambda x: self.selroot())
cmds.separator(p = "mainColumn")
self.button = cmds.button(p = "mainColumn",label="Camera Proxy Selected",width=148,align='center', command=lambda x: self.selproxy())
cmds.showWindow(myWin)
def execute():
pass
def makelocator(args,):
sel = cmds.ls(sl = 1)
for obj in sel:
newLoc = cmds.spaceLocator( n='LocatorCameraPivot' )
newCon = cmds.parentConstraint(obj, newLoc, mo = 0)
cmds.delete(newCon)
def selroot(args,):
nodes = cmds.ls(sl=True)
myParent = nodes[-1]
nodes.pop()
for node in nodes:
newparent = cmds.parentConstraint(nodes[-1], myParent, mo=True, weight=1)
def selproxy(args,):
nodes = cmds.ls(sl=True)
myParent = nodes[-1]
nodes.pop()
for node in nodes:
newparentX = cmds.parentConstraint(myParent, nodes[-1], mo=False)
cmds.delete(newparentX)
cmds.delete(newparent)
cmds.delete(newLoc)
MatchCamScript()
Solved! Go to Solution.