def parentPivotLocMeObject(obj): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Pass an object into it and return locator placed at the center of the bounding box of the object while matching other factors ARGUMENTS: obj(string) RETURNS: name(string) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ """pass an object into it and get locator placed at the pivots - matching translation, rotation and rotation order""" locBuffer = locMeObject(obj) """ see if there is a parent, if there is, copy the pivot of it, if not, set it to world center """ parents = mc.listRelatives(obj,parent=True,fullPath=True) if parents != None: rigging.copyPivot(locBuffer,parents[0]) return locBuffer else: worldCenterPivot = mc.spaceLocator() rigging.copyPivot(locBuffer,worldCenterPivot[0]) mc.delete(worldCenterPivot) return locBuffer
def parentPivotLocMeObject(obj): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Pass an object into it and return locator placed at the center of the bounding box of the object while matching other factors ARGUMENTS: obj(string) RETURNS: name(string) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ """pass an object into it and get locator placed at the pivots - matching translation, rotation and rotation order""" locBuffer = locMeObject(obj) """ see if there is a parent, if there is, copy the pivot of it, if not, set it to world center """ parents = mc.listRelatives(obj, parent=True, fullPath=True) if parents != None: rigging.copyPivot(locBuffer, parents[0]) return locBuffer else: worldCenterPivot = mc.spaceLocator() rigging.copyPivot(locBuffer, worldCenterPivot[0]) mc.delete(worldCenterPivot) return locBuffer
def copyPivot(self,sourceObject): """ Copy the pivot from a source object to the current instanced maya object. """ try: #If we have an Object Factory instance, link it sourceObject.nameShort sourceObject = sourceObject.nameShort except: #If it fails, check that the object name exists and if so, initialize a new Object Factory instance assert mc.objExists(sourceObject) is True, "'%s' - source object doesn't exist" %sourceObject assert self.transform ,"'%s' has no transform"%obj assert mc.ls(sourceObject,type = 'transform'),"'%s' has no transform"%sourceObject rigging.copyPivot(self.nameLong,sourceObject)
def locMeClosestUVOnSurface(obj, surface, pivotOnSurfaceOnly=False): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Places locators on the cv's of a surface ARGUMENTS: curve(string) RETURNS: locList(list) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ locBuffer = locMeObject(obj) pivotLoc = locMeObject(obj) controlSurface = mc.listRelatives(surface, shapes=True) """ make the closest point node """ closestPointNode = mc.createNode('closestPointOnSurface') """ to account for target objects in heirarchies """ attributes.doConnectAttr((locBuffer + '.translate'), (closestPointNode + '.inPosition')) attributes.doConnectAttr((controlSurface[0] + '.worldSpace'), (closestPointNode + '.inputSurface')) """ make the pointOnSurfaceNode """ pointOnSurfaceNode = mc.createNode('pointOnSurfaceInfo') """ Connect the info node to the surface """ attributes.doConnectAttr((controlSurface[0] + '.worldSpace'), (pointOnSurfaceNode + '.inputSurface')) """ Contect the pos group to the info node""" attributes.doConnectAttr((pointOnSurfaceNode + '.position'), (pivotLoc + '.translate')) attributes.doConnectAttr((closestPointNode + '.parameterU'), (pointOnSurfaceNode + '.parameterU')) attributes.doConnectAttr((closestPointNode + '.parameterV'), (pointOnSurfaceNode + '.parameterV')) if pivotOnSurfaceOnly != True: position.movePointSnap(locBuffer, pivotLoc) else: rigging.copyPivot(locBuffer, pivotLoc) mc.delete(closestPointNode) mc.delete(pointOnSurfaceNode) mc.delete(pivotLoc) #Rotate constBuffer = mc.normalConstraint(surface, locBuffer) mc.delete(constBuffer[0]) return locBuffer
def locMeClosestUVOnSurface(obj, surface, pivotOnSurfaceOnly = False): """ >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION: Places locators on the cv's of a surface ARGUMENTS: curve(string) RETURNS: locList(list) >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> """ locBuffer = locMeObject(obj) pivotLoc = locMeObject(obj) controlSurface = mc.listRelatives(surface,shapes=True) """ make the closest point node """ closestPointNode = mc.createNode ('closestPointOnSurface') """ to account for target objects in heirarchies """ attributes.doConnectAttr((locBuffer+'.translate'),(closestPointNode+'.inPosition')) attributes.doConnectAttr((controlSurface[0]+'.worldSpace'),(closestPointNode+'.inputSurface')) """ make the pointOnSurfaceNode """ pointOnSurfaceNode = mc.createNode ('pointOnSurfaceInfo') """ Connect the info node to the surface """ attributes.doConnectAttr ((controlSurface[0]+'.worldSpace'),(pointOnSurfaceNode+'.inputSurface')) """ Contect the pos group to the info node""" attributes.doConnectAttr ((pointOnSurfaceNode+'.position'),(pivotLoc+'.translate')) attributes.doConnectAttr ((closestPointNode+'.parameterU'),(pointOnSurfaceNode+'.parameterU')) attributes.doConnectAttr ((closestPointNode+'.parameterV'),(pointOnSurfaceNode+'.parameterV')) if pivotOnSurfaceOnly != True: position.movePointSnap(locBuffer,pivotLoc) else: rigging.copyPivot(locBuffer,pivotLoc) mc.delete(closestPointNode) mc.delete(pointOnSurfaceNode) mc.delete(pivotLoc) #Rotate constBuffer = mc.normalConstraint(surface,locBuffer) mc.delete(constBuffer[0]) return locBuffer