示例#1
0
def makeCloneObject2( target, replaceName=['SOURCENAME_', 'TARGETNAME_'], **options ):
    
    import sgBModel_dag
    import sgBFunction_attribute
    import sgBFunction_value
    import sgBFunction_connection
    
    op_cloneAttrName = None
    op_shapeOn       = None
    op_connectionOn  = None
    
    op_cloneAttrName = sgBFunction_value.getValueFromDict( options, 'cloneAttrName' )
    op_shapeOn = sgBFunction_value.getValueFromDict( options, 'shapeOn' )
    op_connectionOn = sgBFunction_value.getValueFromDict( options, 'connectionOn' )
    
    if op_cloneAttrName:
        attrName = op_cloneAttrName
    else:
        attrName = sgBModel_dag.cloneTargetAttrName
    
    targets = getParents( target )
    targets.append( target )
    
    targetCloneParent = None
    for cuTarget in targets:
        sgBFunction_attribute.addAttr( cuTarget, ln=attrName, at='message' )
        cloneConnection = cmds.listConnections( cuTarget+'.'+attrName, s=1, d=0 )
        if not cloneConnection:
            print "replaceName : ", cuTarget.split( '|' )[-1].replace( replaceName[0], replaceName[1] )
            targetClone = cmds.createNode( 'transform', n= cuTarget.split( '|' )[-1].replace( replaceName[0], replaceName[1] ) )
            cmds.connectAttr( targetClone+'.message', cuTarget+'.'+attrName )
            
            if op_shapeOn:
                cuTargetShape = getShape( cuTarget )
                if cuTargetShape:
                    duObj = cmds.duplicate( cuTarget, n=targetClone+'_du' )[0]
                    duShape = cmds.listRelatives( duObj, s=1, f=1 )[0]
                    duShape = cmds.parent( duShape, targetClone, add=1, shape=1 )[0]
                    cmds.delete( duObj )
                    cmds.rename( duShape, targetClone+'Shape' )
            if op_connectionOn:
                sgBFunction_connection.getSourceConnection( cuTarget, targetClone )
                cuTargetShape    = getShape( cuTarget )
                targetCloneShape = getShape( targetClone )
                
                if cuTargetShape and targetCloneShape:
                    sgBFunction_connection.getSourceConnection( cuTargetShape, targetCloneShape )
        else:
            targetClone = cloneConnection[0]
        
        targetCloneParentExpected = getParent( targetClone )
        if cmds.ls( targetCloneParentExpected ) != cmds.ls( targetCloneParent ) and targetCloneParent:
            targetClone = cmds.parent( targetClone, targetCloneParent )[0]

        cuTargetPos = cmds.getAttr( cuTarget+'.m' )
        cmds.xform( targetClone, os=1, matrix=cuTargetPos )

        targetCloneParent = targetClone
    return targetCloneParent
示例#2
0
 def __init__(self, label, popupLabel='Load Selected', typ='single', addCommend = [], **options ):
     
     self._label = label
     self._popup = popupLabel
     self._position = sgBFunction_value.getValueFromDict( options, 'position' )
     self._textWidth = sgBFunction_value.getValueFromDict( options, 'textWidth' )
     self._olnyAddCommand = sgBFunction_value.getValueFromDict( options, 'olnyAddCmd' )
     self._addCommand = addCommend
     if self._textWidth == None: self._textWidth = 120
     self._field  =''
     self._type = typ
     self._cmdPopup = [self.cmdLoadSelected]
示例#3
0
 def __init__(self, label, **options ):
     
     import sgBFunction_value
     
     popupLabel = sgBFunction_value.getValueFromDict( options, *['popupLabel', 'popLabel'] )
     typ        = sgBFunction_value.getValueFromDict( options, *['type', 'typ'] )
     addCommand = sgBFunction_value.getValueFromDict( options, *['addCommand', 'addCmd'] )
     globalForm = sgBFunction_value.getValueFromDict( options, *['globalForm', 'form'] )
     globalField = sgBFunction_value.getValueFromDict( options, *['globalField', 'field'] )
     
     if not popupLabel: popupLabel = 'Load Selected'
     if not typ       : typ = 'single'
     if not addCommand: addCommand = []
     
     self._label = label
     self._popup = popupLabel
     self._position = sgBFunction_value.getValueFromDict( options, 'position' )
     self._textWidth = sgBFunction_value.getValueFromDict( options, 'textWidth' )
     self._olnyAddCommand = sgBFunction_value.getValueFromDict( options, 'olnyAddCmd' )
     self._addCommand = addCommand
     if self._textWidth == None: self._textWidth = 120
     self._field  =''
     self._type = typ
     self._cmdPopup = [self.cmdLoadSelected]
     self._globalForm = globalForm
     self._globalField = globalField
示例#4
0
    def __init__(self, label, **options):

        import sgBFunction_value

        popupLabel = sgBFunction_value.getValueFromDict(
            options, *['popupLabel', 'popLabel'])
        typ = sgBFunction_value.getValueFromDict(options, *['type', 'typ'])
        addCommand = sgBFunction_value.getValueFromDict(
            options, *['addCommand', 'addCmd'])
        globalForm = sgBFunction_value.getValueFromDict(
            options, *['globalForm', 'form'])
        globalField = sgBFunction_value.getValueFromDict(
            options, *['globalField', 'field'])

        if not popupLabel: popupLabel = 'Load Selected'
        if not typ: typ = 'single'
        if not addCommand: addCommand = []

        self._label = label
        self._popup = popupLabel
        self._position = sgBFunction_value.getValueFromDict(
            options, 'position')
        self._textWidth = sgBFunction_value.getValueFromDict(
            options, 'textWidth')
        self._olnyAddCommand = sgBFunction_value.getValueFromDict(
            options, 'olnyAddCmd')
        self._addCommand = addCommand
        if self._textWidth == None: self._textWidth = 120
        self._field = ''
        self._type = typ
        self._cmdPopup = [self.cmdLoadSelected]
        self._globalForm = globalForm
        self._globalField = globalField
示例#5
0
    def __init__(self,
                 label,
                 popupLabel='Load Selected',
                 typ='single',
                 addCommend=[],
                 **options):

        self._label = label
        self._popup = popupLabel
        self._position = sgBFunction_value.getValueFromDict(
            options, 'position')
        self._textWidth = sgBFunction_value.getValueFromDict(
            options, 'textWidth')
        self._olnyAddCommand = sgBFunction_value.getValueFromDict(
            options, 'olnyAddCmd')
        self._addCommand = addCommend
        if self._textWidth == None: self._textWidth = 120
        self._field = ''
        self._type = typ
        self._cmdPopup = [self.cmdLoadSelected]
示例#6
0
def curve_onJoint( topJoint, **options ):
    
    jntsH = cmds.listRelatives( topJoint, c=1, ad=1 )
    jntsH.append( topJoint )
    
    points = []
    for jnt in jntsH:
        point = cmds.xform( jnt, q=1, ws=1, t=1 )
        points.append( point )
    
    epCurve = sgBFunction_value.getValueFromDict( options, 'editPoint', 'ep' )
    degrees = sgBFunction_value.getValueFromDict( options, 'degrees', 'd' )
    
    if not degrees:
        if len( points ) == 2: degrees = 1
        elif len( points ) == 3: degrees = 2
        else: degrees = 3
    
    if epCurve:
        cmds.curve( ep=points, d=degrees )
    else:
        cmds.curve( p=points, d=degrees )
示例#7
0
def curve_onJoint(topJoint, **options):

    jntsH = cmds.listRelatives(topJoint, c=1, ad=1)
    jntsH.append(topJoint)

    points = []
    for jnt in jntsH:
        point = cmds.xform(jnt, q=1, ws=1, t=1)
        points.append(point)

    epCurve = sgBFunction_value.getValueFromDict(options, 'editPoint', 'ep')
    degrees = sgBFunction_value.getValueFromDict(options, 'degrees', 'd')

    if not degrees:
        if len(points) == 2: degrees = 1
        elif len(points) == 3: degrees = 2
        else: degrees = 3

    if epCurve:
        cmds.curve(ep=points, d=degrees)
    else:
        cmds.curve(p=points, d=degrees)
示例#8
0
def makeCloneObject2(target,
                     replaceName=['SOURCENAME_', 'TARGETNAME_'],
                     **options):

    import sgBModel_dag
    import sgBFunction_attribute
    import sgBFunction_value
    import sgBFunction_connection

    op_cloneAttrName = None
    op_shapeOn = None
    op_connectionOn = None

    op_cloneAttrName = sgBFunction_value.getValueFromDict(
        options, 'cloneAttrName')
    op_shapeOn = sgBFunction_value.getValueFromDict(options, 'shapeOn')
    op_connectionOn = sgBFunction_value.getValueFromDict(
        options, 'connectionOn')

    if op_cloneAttrName:
        attrName = op_cloneAttrName
    else:
        attrName = sgBModel_dag.cloneTargetAttrName

    targets = getParents(target)
    targets.append(target)

    targetCloneParent = None
    for cuTarget in targets:
        sgBFunction_attribute.addAttr(cuTarget, ln=attrName, at='message')
        cloneConnection = cmds.listConnections(cuTarget + '.' + attrName,
                                               s=1,
                                               d=0)
        if not cloneConnection:
            print "replaceName : ", cuTarget.split('|')[-1].replace(
                replaceName[0], replaceName[1])
            targetClone = cmds.createNode('transform',
                                          n=cuTarget.split('|')[-1].replace(
                                              replaceName[0], replaceName[1]))
            cmds.connectAttr(targetClone + '.message',
                             cuTarget + '.' + attrName)

            if op_shapeOn:
                cuTargetShape = getShape(cuTarget)
                if cuTargetShape:
                    duObj = cmds.duplicate(cuTarget, n=targetClone + '_du')[0]
                    duShape = cmds.listRelatives(duObj, s=1, f=1)[0]
                    duShape = cmds.parent(duShape, targetClone, add=1,
                                          shape=1)[0]
                    cmds.delete(duObj)
                    cmds.rename(duShape, targetClone + 'Shape')
            if op_connectionOn:
                sgBFunction_connection.getSourceConnection(
                    cuTarget, targetClone)
                cuTargetShape = getShape(cuTarget)
                targetCloneShape = getShape(targetClone)

                if cuTargetShape and targetCloneShape:
                    sgBFunction_connection.getSourceConnection(
                        cuTargetShape, targetCloneShape)
        else:
            targetClone = cloneConnection[0]

        targetCloneParentExpected = getParent(targetClone)
        if cmds.ls(targetCloneParentExpected) != cmds.ls(
                targetCloneParent) and targetCloneParent:
            targetClone = cmds.parent(targetClone, targetCloneParent)[0]

        cuTargetPos = cmds.getAttr(cuTarget + '.m')
        cmds.xform(targetClone, os=1, matrix=cuTargetPos)

        targetCloneParent = targetClone
    return targetCloneParent