當前位置: 首頁>>代碼示例>>Python>>正文


Python NodeUtility.getDependNode方法代碼示例

本文整理匯總了Python中marigold.utility.NodeUtility.getDependNode方法的典型用法代碼示例。如果您正苦於以下問題:Python NodeUtility.getDependNode方法的具體用法?Python NodeUtility.getDependNode怎麽用?Python NodeUtility.getDependNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在marigold.utility.NodeUtility的用法示例。


在下文中一共展示了NodeUtility.getDependNode方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: copyBitSettings

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getDependNode [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: createCompoundCurve

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getDependNode [as 別名]
def createCompoundCurve(inCurves):
    """
    Merges all the controls into one transform node.
    
    @param inCurves: List of Strings. Names of curves to combine under one transform node.
                        The first curve in the list is considered the parent of all the others.
    @return: MObject. Compound curve transform node.
    """
    # List for creating the compound.
    compoundList = []

    # Get the nurbs curves of all curves in the list.
    for index in range(1, len(inCurves)):
        curve = NodeUtility.getDagPath(inCurves[index])
        for child in xrange(curve.childCount()):
            nurb = curve.child(child)
            nurbDagPath = OpenMaya.MDagPath.getAPathTo(nurb)
            if nurb.apiType() == OpenMaya.MFn.kNurbsCurve:
                compoundList.append(nurbDagPath.fullPathName())

    # Add the transform of the parent curve. This is the first curve passed into
    # the function.
    parent = NodeUtility.getDagPath(inCurves[0])
    compoundList.append(parent.fullPathName())

    # Now parent the shapes to the first curve's transform node.
    cmds.parent(compoundList, shape=True, relative=True)

    # Delete the remaining transform nodes of the other curves.
    for index in range(1, len(inCurves)):
        cmds.delete(inCurves[index])

    # Returns a MObject.
    return NodeUtility.getDependNode(parent.fullPathName())
開發者ID:EriLee,項目名稱:marigold,代碼行數:36,代碼來源:NurbsCurveUtility.py

示例3: addPlug

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getDependNode [as 別名]
def addPlug( inBit, inPlugName, inAttrType, inAttrDataType ):
    '''
    Adds a plug to the frame bit.
    
    @param inBit: String. Name of the bit to add the attribute to.
    @param inPlugName: String. Name of the plug to add.
    @param inAttrType: String. Type of attribute to add.
    @param inAttrDataType: String. The attribute data type.
    '''
    if inAttrType == 'attributeType':
        if inAttrDataType == 'float3':
            cmds.addAttr( inBit, longName=inPlugName, attributeType=inAttrDataType )
            cmds.addAttr( longName='{0}X'.format( inPlugName ), attributeType='float', parent=inPlugName )
            cmds.addAttr( longName='{0}Y'.format( inPlugName ), attributeType='float', parent=inPlugName )
            cmds.addAttr( longName='{0}Z'.format( inPlugName ), attributeType='float', parent=inPlugName )
        else:
            cmds.addAttr( inBit, longName=inPlugName, attributeType=inAttrDataType )
    elif inAttrType == 'dataType':
        if inAttrDataType == 'typed':
            # Make it a string.
            inAttrDataType = 'string'
        cmds.addAttr( inBit, longName=inPlugName, dataType=inAttrDataType )
    elif inAttrType == 'matrixType':
        mObj = NodeUtility.getDependNode( inBit )
        dgModifier = OpenMaya.MDGModifier()
        mAttr = OpenMaya.MFnMatrixAttribute()
        controlMatrix = mAttr.create( inPlugName, inPlugName, OpenMaya.MFnMatrixAttribute.kDouble )
        dgModifier.addAttribute( mObj, controlMatrix )
        dgModifier.doIt()
開發者ID:EriLee,項目名稱:marigold,代碼行數:31,代碼來源:FrameUtility.py

示例4: createCurveCircle

# 需要導入模塊: from marigold.utility import NodeUtility [as 別名]
# 或者: from marigold.utility.NodeUtility import getDependNode [as 別名]
def createCurveCircle(inName, inNormal=[0, 1, 0], inRadius=1):
    """
    @param inName: String. Name of curve circle.
    @param inNormal: List. Direction the curve faces.
    @param inRadius: Int. Radius of the circle.
    @return. MObject. Curve circle.
    """
    node = cmds.circle(name=inName, normal=inNormal, radius=inRadius)
    return NodeUtility.getDependNode(node[0])
開發者ID:EriLee,項目名稱:marigold,代碼行數:11,代碼來源:NurbsCurveUtility.py


注:本文中的marigold.utility.NodeUtility.getDependNode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。