当前位置: 首页>>代码示例>>Python>>正文


Python NodeUtility.setPlugValue方法代码示例

本文整理汇总了Python中marigold.utility.NodeUtility.setPlugValue方法的典型用法代码示例。如果您正苦于以下问题:Python NodeUtility.setPlugValue方法的具体用法?Python NodeUtility.setPlugValue怎么用?Python NodeUtility.setPlugValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在marigold.utility.NodeUtility的用法示例。


在下文中一共展示了NodeUtility.setPlugValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: copyBitSettings

# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import setPlugValue [as 别名]
def copyBitSettings():
    '''
    Copies the bit shape settings (OpenGL stuff) from the second object to the
    first (in selection order).
    '''
    selList = cmds.ls( selection=True, long=True )
    depFn = OpenMaya.MFnDependencyNode()
    
    if len(selList) == 2:
        # First object is target.
        targetShape = cmds.listRelatives( selList[0], shapes=True, fullPath=True )[0]
        targetShapeMObj = NodeUtility.getDependNode( targetShape )
        depFn.setObject( targetShapeMObj )
        targetShapeType = depFn.typeName()
        
        # Second object is source.
        sourceShape = cmds.listRelatives( selList[1], shapes=True, fullPath=True )[0]
        sourceShapeMObj = NodeUtility.getDependNode( sourceShape )
        depFn.setObject( sourceShapeMObj )
        sourceShapeType = depFn.typeName()
        
        if targetShapeType == sourceShapeType:        
            # The types match. Do the copy of attribute settings.
            for attr in cmds.listAttr( sourceShape, multi=True, keyable=True ):
                # Get the plugs.
                sourcePlug = NodeUtility.getPlug( sourceShape, attr )
                targetPlug = NodeUtility.getPlug( targetShape, attr )
                
                # Get the source plug value.
                sourcePlugValue = NodeUtility.getPlugValue( sourcePlug )
                
                # Set the target's plug value.
                NodeUtility.setPlugValue( targetPlug, sourcePlugValue )
        else:
            raise ValueError( '{0} and {1} do not match.'.format( selList[0], selList[1] ) )
开发者ID:EriLee,项目名称:marigold,代码行数:37,代码来源:FrameUtility.py

示例2: setPriorities

# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import setPlugValue [as 别名]
 def setPriorities( self ):
     '''
     Applies the user adjusted priorities to all the modules of a character.
     '''
     for index in xrange( self.dropList.count() ):
         moduleName = self.dropList.item( index ).text()
         moduleComponent = self.modDict[moduleName][0]
         priorityPlug = NodeUtility.getPlug( moduleComponent, 'buildPriority' )
         NodeUtility.setPlugValue( priorityPlug, index )
         
     self.close()
开发者ID:EriLee,项目名称:marigold,代码行数:13,代码来源:UICharacterPriorityPrompt.py

示例3: setAttribute

# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import setPlugValue [as 别名]
 def setAttribute( self, inPlugName, inPlugValue, inNodeName, inLock=False ):
     #print inPlugName, inPlugValue, inNodeName
     #print type( inPlugValue )
     '''
     if isinstance( inPlugValue, unicode ):
         # This is a unicode string. Likely a node name.
         print 'UNICODE'
         plugValue = inPlugValue
     elif isinstance( inPlugValue, str ):
         print 'STRING'
         plugValue = inPlugValue
     else:
         # This is likely coming from a QT object.
         print 'PASS'
         plugValue = inPlugValue.text()
     '''
     plug = NodeUtility.getPlug( inNodeName, inPlugName )
     NodeUtility.setPlugValue( plug, inPlugValue )
     cmds.setAttr( '{0}.{1}'.format( inNodeName, inPlugName ), lock=inLock )
开发者ID:EriLee,项目名称:marigold,代码行数:21,代码来源:BaseComponent.py

示例4: storeControlTransforms

# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import setPlugValue [as 别名]
def storeControlTransforms( sourceObj, targetObj ):
    '''
    Store control transform data.
    
    @param sourceObj: String. Name of object to pull data from.
    @param targetObj: String. Name of object to store data on.
    '''    
    sourceMatrix = TransformUtility.getMatrix( sourceObj, 'matrix' )
    
    # Store the position
    targetPosPlug = NodeUtility.getPlug( targetObj, 'controlPosition' )
    sourceTranslation = TransformUtility.getMatrixTranslation( sourceMatrix, OpenMaya.MSpace.kTransform )
    pos = [ sourceTranslation.x, sourceTranslation.y, sourceTranslation.z ]
    NodeUtility.setPlugValue( targetPosPlug, pos )
    
    # Store the rotation
    targetRotPlug = NodeUtility.getPlug( targetObj, 'controlRotation' )
    sourceRotation = TransformUtility.getMatrixRotation( sourceMatrix, 'euler' )
    #rot = [ degrees(angle) for angle in (sourceRotation.x, sourceRotation.y, sourceRotation.z) ]
    rot = [ sourceRotation.x, sourceRotation.y, sourceRotation.z ]
    NodeUtility.setPlugValue( targetRotPlug, rot )
    
    # Store the scale.
    targetSclPlug = NodeUtility.getPlug( targetObj, 'controlScale' )
    sourceScale = TransformUtility.getMatrixScale( sourceMatrix, OpenMaya.MSpace.kTransform )
    scl = [ sourceScale.x, sourceScale.y, sourceScale.z ]
    NodeUtility.setPlugValue( targetSclPlug, scl )
开发者ID:EriLee,项目名称:marigold,代码行数:29,代码来源:__init__.py

示例5: redoIt

# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import setPlugValue [as 别名]
 def redoIt( self ):
     ''' Do the actual work of the command. '''
     # Perform the operations enqueued within our reference to MDagModifier. This effectively
     # creates the DAG nodes specified using self.dagModifier.createNode(). Node creation is 
     # done in doIt().
     self.MDagMod.doIt()
     
     # Apply the user defined arguments to the controller node.
     self.MFnDagNode.setObject( self.controllerNode )
     
     # Set the name.
     self.MFnDagNode.setName( self.name )
     # Get the aim node's shape.
     self.MFnDepNode.setObject( self.MFnDagNode.child( 0 ) )
     print self.MFnDepNode.name()
     
     # Update plugs with values, if any, from the command.
     print self.MFnDepNode.findPlug( 'color' )
     
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'color' ), self.color )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'localPosition' ), self.position )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'rotate' ), self.rotation )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'transparency' ), self.transparency )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'backAlpha' ), self.backAlpha )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'lineWidth' ), self.lineWidth )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'width' ), self.width )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'height' ), self.height )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'depth' ), self.depth )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'drawType' ), self.drawType )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'topFrontRight' ), self.opTFR )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'topFrontLeft' ), self.opTFL )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'topBackRight' ), self.opTBR )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'topBackLeft' ), self.opTBL )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'botFrontRight' ), self.opBFR )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'botFrontLeft' ), self.opBFL )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'botBackRight' ), self.opBBR )
     NodeUtility.setPlugValue( self.MFnDepNode.findPlug( 'botBackLeft' ), self.opBBL )
         
     self.MDGMod.doIt()
开发者ID:EriLee,项目名称:marigold,代码行数:41,代码来源:rigControllers.py

示例6: applyXMLtoControl

# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import setPlugValue [as 别名]
def applyXMLtoControl():
    # Get the selected object. Only takes one object.
    sel = cmds.ls( selection=True, dagObjects=True, allPaths=True, transforms=True )
    
    # Get the XML file.
    attrList = readControlXML()
    
    # Grab the shape node.
    transNode = NodeUtility.getDagPath( sel[0] )
    MFnDepNode = OpenMaya.MFnDependencyNode()
    MFnDepNode.setObject( transNode.child( 0 ) )
    
    if MFnDepNode.typeName() == 'ControlBox':        
        # Update plugs with values, if any, from the command.
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'color' ),
                                  [ float( attrList[ 'color' ][ 'value' ][0] ), float( attrList[ 'color' ][ 'value' ][1] ), float( attrList[ 'color' ][ 'value' ][2] ) ] )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'localPosition' ),
                                  [ float( attrList[ 'localPosition' ][ 'value' ][0] ), float( attrList[ 'localPosition' ][ 'value' ][1] ), float( attrList[ 'localPosition' ][ 'value' ][2] ) ] )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'rotate' ),
                                  [ float( attrList[ 'rotate' ][ 'value' ][0] ), float( attrList[ 'rotate' ][ 'value' ][1] ), float( attrList[ 'rotate' ][ 'value' ][2] ) ] )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'transparency' ), float( attrList[ 'transparency' ][ 'value' ] ) )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'backAlpha' ), float( attrList[ 'backAlpha' ][ 'value' ] ) )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'lineWidth' ), int( attrList[ 'lineWidth' ][ 'value' ] ) )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'width' ), float( attrList[ 'width' ][ 'value' ] ) )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'height' ), float( attrList[ 'height' ][ 'value' ] ) )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'depth' ), float( attrList[ 'depth' ][ 'value' ] ) )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'drawType' ), int( attrList[ 'drawType' ][ 'value' ] ) )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'topFrontRight' ),
                                  [ float( attrList[ 'topFrontRight' ][ 'value' ][0] ), float( attrList[ 'topFrontRight' ][ 'value' ][1] ), float( attrList[ 'topFrontRight' ][ 'value' ][2] ) ] )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'topFrontLeft' ),
                                  [ float( attrList[ 'topFrontLeft' ][ 'value' ][0] ), float( attrList[ 'topFrontLeft' ][ 'value' ][1] ), float( attrList[ 'topFrontLeft' ][ 'value' ][2] ) ] )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'topBackRight' ),
                                  [ float( attrList[ 'topBackRight' ][ 'value' ][0] ), float( attrList[ 'topBackRight' ][ 'value' ][1] ), float( attrList[ 'topBackRight' ][ 'value' ][2] ) ] )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'topBackLeft' ),
                                  [ float( attrList[ 'topBackLeft' ][ 'value' ][0] ), float( attrList[ 'topBackLeft' ][ 'value' ][1] ), float( attrList[ 'topBackLeft' ][ 'value' ][2] ) ] )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'botFrontRight' ),
                                  [ float( attrList[ 'botFrontRight' ][ 'value' ][0] ), float( attrList[ 'botFrontRight' ][ 'value' ][1] ), float( attrList[ 'botFrontRight' ][ 'value' ][2] ) ] )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'botFrontLeft' ),
                                  [ float( attrList[ 'botFrontLeft' ][ 'value' ][0] ), float( attrList[ 'botFrontLeft' ][ 'value' ][1] ), float( attrList[ 'botFrontLeft' ][ 'value' ][2] ) ] )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'botBackRight' ),
                                  [ float( attrList[ 'botBackRight' ][ 'value' ][0] ), float( attrList[ 'botBackRight' ][ 'value' ][1] ), float( attrList[ 'botBackRight' ][ 'value' ][2] ) ] )
        NodeUtility.setPlugValue( MFnDepNode.findPlug( 'botBackLeft' ),
                                  [ float( attrList[ 'botBackLeft' ][ 'value' ][0] ), float( attrList[ 'botBackLeft' ][ 'value' ][1] ), float( attrList[ 'botBackLeft' ][ 'value' ][2] ) ] )
开发者ID:EriLee,项目名称:marigold,代码行数:45,代码来源:XMLUtility.py

示例7: applyDeformerMesh

# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import setPlugValue [as 别名]
def applyDeformerMesh():
    '''
    Applies the deformer mesh to the OpenGL values of the active controller.
    '''
    selList = OpenMaya.MSelectionList()
    OpenMaya.MGlobal.getActiveSelectionList( selList )
    if selList.length() is 1:
        control = OpenMaya.MObject()
        selList.getDependNode( 0, control )    
        controlDagNode = OpenMaya.MFnDagNode( control )
        controlShape = controlDagNode.child( 0 )
        controlShapeDep = OpenMaya.MFnDependencyNode( controlShape )
        locCheck = False
        meshCheck = False
        for c in xrange( controlDagNode.childCount() ):
            child = controlDagNode.child( c )
            if child.apiType() == OpenMaya.MFn.kPluginLocatorNode:
                locCheck = True
            elif child.apiType() == OpenMaya.MFn.kMesh:
                # Set the check to True.
                meshCheck = True
                # Grab the mesh.
                deformMesh = OpenMaya.MFnMesh( child )
                
                # Grab the vertices of the mesh.
                vertexCount = OpenMaya.MIntArray()    
                vertexList = OpenMaya.MIntArray()
                vertexArray = OpenMaya.MFloatPointArray()
                deformMesh.getVertices( vertexCount, vertexList )
                deformMesh.getPoints( vertexArray, OpenMaya.MSpace.kObject )
                
                # Set the OpenGL points.
                glPosition = NodeUtility.getPlugValue( NodeUtility.getPlug( controlShapeDep.name(), 'localPosition' ) )
                glWidth = NodeUtility.getPlugValue( NodeUtility.getPlug( controlShapeDep.name(), 'width' ) )
                glHeight = NodeUtility.getPlugValue( NodeUtility.getPlug( controlShapeDep.name(), 'height' ) )
                glDepth = NodeUtility.getPlugValue( NodeUtility.getPlug( controlShapeDep.name(), 'depth' ) )
                NodeUtility.setPlugValue( NodeUtility.getPlug( controlShapeDep.name(), 'botBackRight' ), [ (vertexArray[0].x-(-glWidth/2))-glPosition[0],(vertexArray[0].y-(-glHeight/2))-glPosition[1],(vertexArray[0].z-(-glDepth/2))-glPosition[2] ]  )
                NodeUtility.setPlugValue( NodeUtility.getPlug( controlShapeDep.name(), 'botBackLeft' ), [ (vertexArray[1].x-(glWidth/2))-glPosition[0],(vertexArray[1].y-(-glHeight/2))-glPosition[1],(vertexArray[1].z-(-glDepth/2))-glPosition[2] ] )
                NodeUtility.setPlugValue( NodeUtility.getPlug( controlShapeDep.name(), 'botFrontLeft' ), [ (vertexArray[2].x-(glWidth/2))-glPosition[0],(vertexArray[2].y-(-glHeight/2))-glPosition[1],(vertexArray[2].z-(glDepth/2))-glPosition[2] ] )
                NodeUtility.setPlugValue( NodeUtility.getPlug( controlShapeDep.name(), 'botFrontRight' ), [ (vertexArray[3].x-(-glWidth/2))-glPosition[0],(vertexArray[3].y-(-glHeight/2))-glPosition[1],(vertexArray[3].z-(glDepth/2))-glPosition[2] ] )
                NodeUtility.setPlugValue( NodeUtility.getPlug( controlShapeDep.name(), 'topBackRight' ), [ (vertexArray[4].x-(-glWidth/2))-glPosition[0],(vertexArray[4].y-(glHeight/2))-glPosition[1],(vertexArray[4].z-(-glDepth/2))-glPosition[2] ] )
                NodeUtility.setPlugValue( NodeUtility.getPlug( controlShapeDep.name(), 'topFrontRight' ), [ (vertexArray[5].x-(-glWidth/2))-glPosition[0],(vertexArray[5].y-(glHeight/2))-glPosition[1],(vertexArray[5].z-(glDepth/2))-glPosition[2] ] )
                NodeUtility.setPlugValue( NodeUtility.getPlug( controlShapeDep.name(), 'topFrontLeft' ), [ (vertexArray[6].x-(glWidth/2))-glPosition[0],(vertexArray[6].y-(glHeight/2))-glPosition[1],(vertexArray[6].z-(glDepth/2))-glPosition[2] ] )
                NodeUtility.setPlugValue( NodeUtility.getPlug( controlShapeDep.name(), 'topBackLeft' ), [ (vertexArray[7].x-(glWidth/2))-glPosition[0],(vertexArray[7].y-(glHeight/2))-glPosition[1],(vertexArray[7].z-(-glDepth/2))-glPosition[2] ] )
                
                # Clean up by deleting the mesh.
                MDGMod = OpenMaya.MDGModifier()
                MDGMod.deleteNode( child )
                MDGMod.doIt()
        if locCheck is False:
            sys.stderr.write( 'applyDeformerMesh: This is the wrong type of object. Needs to be an OpenGl Controller.' )
        if meshCheck is False:
            sys.stderr.write( 'applyDeformerMesh: This control object doesn\'t have a deformer mesh.' )
    elif selList.length() > 1:
        sys.stderr.write( 'applyDeformerMesh: To many things selected. Only select one controller.' )
    else:
        sys.stderr.write( 'applyDeformerMesh: Nothing selected.' )
开发者ID:EriLee,项目名称:marigold,代码行数:59,代码来源:ControllerUI.py


注:本文中的marigold.utility.NodeUtility.setPlugValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。