Esempio n. 1
0
def updateTemplate(self,saveTemplatePose = False,**kws):
    """
    Function to update a skeleton if it's been resized
    """
    if not self.isSized():
        log.warning("'%s' not sized. Can't update"%self.getShortName())
        return False
    if not self.isTemplated():
        log.warning("'%s' not templated. Can't update"%self.getShortName())
        return False
    
    if saveTemplatePose:self.storeTemplatePose()#Save our pose before destroying anything
        
    i_templateNull = self.templateNull#link for speed
    corePosList = i_templateNull.templateStarterData
    i_root = i_templateNull.root
    i_controlObjects = i_templateNull.controlObjects
    
    
    if not cgmMath.isVectorEquivalent(i_templateNull.controlObjects[0].translate,[0,0,0]):
        raise StandardError,"updateTemplate: doesn't currently support having a moved first template object"
        return False
    
    mc.xform(i_root.parent, translation = corePosList[0],worldSpace = True)
    
    for i,i_obj in enumerate(i_controlObjects[1:]):
        log.info(i_obj.getShortName())
        objConstraints = constraints.returnObjectConstraints(i_obj.parent)
        if objConstraints:mc.delete(objConstraints) 
        buffer = search.returnParentsFromObjectToParent(i_obj.mNode,i_root.mNode)
        i_obj.parent = False
        if buffer:mc.delete(buffer)
        mc.xform(i_obj.mNode, translation = corePosList[1:][i],worldSpace = True) 
        
    buffer = search.returnParentsFromObjectToParent(i_controlObjects[0].mNode,i_root.mNode)
    i_controlObjects[0].parent = False
    if buffer:mc.delete(buffer)
    
    doParentControlObjects(self)
    self.loadTemplatePose()#Restore the pose
    return True
Esempio n. 2
0
def plasticConstraintsAndScaleFromObjectToTransform():
    selection = mc.ls(sl=True, flatten=True)
    for obj in selection:
        #Make a transform
        group = rigging.groupMeObject(obj,maintainParent = True)

        #Get scale connections
        objScaleConnections = []
        for s in 'sx','sy','sz':
            buffer =  attributes.returnDriverAttribute(obj+'.'+s)
            attributes.doBreakConnection(obj+'.'+s)
            attributes.doConnectAttr(buffer,(group+'.'+s))

        # Get constraint info from obj
        objConstraints = constraints.returnObjectConstraints(obj)

        for const in objConstraints:
            constraintTargets = constraints.returnConstraintTargets(const)
            mc.delete(const)

            mc.parentConstraint(constraintTargets,group, maintainOffset = True)
Esempio n. 3
0
def plasticConstraintsAndScaleFromObjectToTransform():
    selection = mc.ls(sl=True, flatten=True)
    for obj in selection:
        #Make a transform
        group = rigging.groupMeObject(obj,maintainParent = True)

        #Get scale connections
        objScaleConnections = []
        for s in 'sx','sy','sz':
            buffer =  attributes.returnDriverAttribute(obj+'.'+s)
            attributes.doBreakConnection(obj+'.'+s)
            attributes.doConnectAttr(buffer,(group+'.'+s))

        # Get constraint info from obj
        objConstraints = constraints.returnObjectConstraints(obj)

        for const in objConstraints:
            constraintTargets = constraints.returnConstraintTargets(const)
            mc.delete(const)

            mc.parentConstraint(constraintTargets,group, maintainOffset = True)