本文整理汇总了Python中marigold.utility.NodeUtility.getPlugValue方法的典型用法代码示例。如果您正苦于以下问题:Python NodeUtility.getPlugValue方法的具体用法?Python NodeUtility.getPlugValue怎么用?Python NodeUtility.getPlugValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marigold.utility.NodeUtility
的用法示例。
在下文中一共展示了NodeUtility.getPlugValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: applyStoredTransforms
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [as 别名]
def applyStoredTransforms( sourceObj, targetObj ):
'''
Applies stored transform data for a control object.
@param sourceObj: String. Name of object to pull data from.
@param targetObj: String. Name of object to apply data to.
'''
#print 'applyStoredTransforms @@@@@@'
#print 'sourceObj: {0}'.format( sourceObj )
#print 'targetObj: {0}'.format( targetObj )
MFnTrans = OpenMaya.MFnTransform()
targetDagPath = NodeUtility.getDagPath( targetObj )
MFnTrans.setObject( targetDagPath )
sourcePosPlug = NodeUtility.getPlug( sourceObj, 'controlPosition' )
sourcePosValue = NodeUtility.getPlugValue( sourcePosPlug )
sourcePos = OpenMaya.MVector( sourcePosValue[0], sourcePosValue[1], sourcePosValue[2] )
MFnTrans.setTranslation( sourcePos, OpenMaya.MSpace.kTransform )
sourceRotPlug = NodeUtility.getPlug( sourceObj, 'controlRotation' )
sourceRotValue = NodeUtility.getPlugValue( sourceRotPlug )
sourceRot = OpenMaya.MEulerRotation( sourceRotValue[0], sourceRotValue[1], sourceRotValue[2] )
MFnTrans.setRotation( sourceRot )
sourceSclPlug = NodeUtility.getPlug( sourceObj, 'controlScale' )
sourceSclValue = NodeUtility.getPlugValue( sourceSclPlug )
scaleDoubleArray = OpenMaya.MScriptUtil()
scaleDoubleArray.createFromList( [sourceSclValue[0], sourceSclValue[1], sourceSclValue[2]], 3 )
scaleDoubleArrayPtr = scaleDoubleArray.asDoublePtr()
MFnTrans.setScale( scaleDoubleArrayPtr )
示例2: applyDeformerMesh
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [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.' )
示例3: mirrorModule
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [as 别名]
def mirrorModule():
# Mirrors a module.
selList = cmds.ls( selection=True, long=True )
if len( selList ) == 1:
# Prompt for axis.
mirrorAxis = int( cmds.layoutDialog( ui=mirrorObjectPrompt ) )
inBitObj = selList[0]
# Check if selected bit is the root.
if NodeUtility.attributeCheck( inBitObj, 'frameRoot' ):
# This is the root bit of the module. From here we know we can get the
# meta node by accessing the frameRoot attribute.
metaNode = NodeUtility.getNodeAttrDestination( inBitObj, 'frameRoot' )[0]
else:
# The selected bit is not the root. Run through each custom attribute
# to find one connected to the meta node.
attrList = cmds.listAttr( inBitObj, userDefined=True )
for attr in attrList:
connection = NodeUtility.getNodeAttrDestination( inBitObj, attr )
if NodeUtility.attributeCheck( connection[0], 'metaType' ):
metaNode = connection[0]
break
# Now that we have the meta node, we need the XML file name and it's location.
metaClassPlug = NodeUtility.getPlug( metaNode, 'metaClass' )
metaClassValue = NodeUtility.getPlugValue( metaClassPlug )
metaBuildFolderPlug = NodeUtility.getPlug( metaNode, 'buildFolder' )
metaBuildFolderValue = NodeUtility.getPlugValue( metaBuildFolderPlug )
# Create the target module.
'''
NEED TO FIX THIS!
targetRootBit = buildFrameModule( metaBuildFolderValue, metaClassValue )
'''
# Loop through each object in the source module.
metaRootBit = NodeUtility.getNodeAttrSource( metaNode, 'rootBit' )[0]
sourceChildBits = NodeUtility.getFrameRootAllChildren( metaRootBit )
targetChildBits = NodeUtility.getFrameRootAllChildren( targetRootBit )
sourceBits = []
targetBits = []
for i,bit in enumerate( sourceChildBits ):
sourceBits.append( bit )
sourceBits.insert( 0, metaRootBit )
for i, bit in enumerate( targetChildBits ):
targetBits.append( bit )
targetBits.insert( 0, targetRootBit )
for bit in xrange( len(sourceBits) ):
# Mirror the source onto the target.
mirrorObject( inSourceObj=sourceBits[bit], inTargetObj=targetBits[bit], inMirrorAxis=mirrorAxis )
示例4: copyBitSettings
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [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] ) )
示例5: __init__
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [as 别名]
def __init__( self, nodeName, parent=None ):
super( componentWidget, self ).__init__( parent )
self.parent = parent
def on_context_menu( point, inNodeName ):
popMenu = QtGui.QMenu()
deleteAction = QtGui.QAction( 'Delete Component', popMenu, triggered=lambda a=inNodeName:self.deleteComponentFromObject( a ) )
popMenu.addAction( deleteAction )
popMenu.exec_( self.componentLabel.mapToGlobal( point ) )
# Setup layout.
verticalLayout = QtGui.QVBoxLayout()
verticalLayout.setContentsMargins( 0,0,0,0 )
verticalLayout.setSpacing( 0 )
verticalLayout.setAlignment( QtCore.Qt.AlignTop )
# Label for component
componentLabel = QTWidgets.basicLabel( nodeName, 'bold', 10, 'black', '6E9094', inIndent=20 )
componentLabel.setMinimumHeight( 18 )
componentLabel.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
componentLabel.customContextMenuRequested.connect( lambda point, nodeName=nodeName:on_context_menu( point, nodeName ) )
# Properties
propertyStack = QtGui.QVBoxLayout()
propertyFrame = QTWidgets.basicFrame()
propertyFrame.setMinimumHeight( 40 )
propertyFrame.setMaximumHeight( 40 )
# Add string edit property
modulePlug = NodeUtility.getPlug( nodeName, 'moduleName' )
moduleValue = NodeUtility.getPlugValue( modulePlug )
moduleTextLayout = QTWidgets.stringProperty( 'Module Name', moduleValue )
'''
ADD EDIT FIELDS FOR PRIORITY AND CHARACTER ROOT!!!!!!!!!
'''
# Add everything to the vertical layout.
propertyStack.addLayout( moduleTextLayout )
propertyFrame.setLayout( propertyStack )
verticalLayout.addWidget( componentLabel )
verticalLayout.addWidget( propertyFrame )
# Connections
moduleTextBox = propertyFrame.findChild( QtGui.QLineEdit, 'Module Name' )
moduleTextBox.editingFinished.connect( lambda inPlugName='moduleName', inQTType='QLineEdit', inPlugValue=moduleTextBox, inNodeName=nodeName
:ModuleRootComponent( inNodeName ).setComponentAttributeFromQT( inPlugName, inQTType, inPlugValue, inNodeName ) )
#return mainWidget
self.setLayout( verticalLayout )
示例6: __init__
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [as 别名]
def __init__( self, nodeName, parent=None ):
super( componentWidget, self ).__init__( parent )
self.parent = parent
def on_context_menu( point, inNodeName ):
popMenu = QtGui.QMenu()
buildAction = QtGui.QAction( 'Build Joint', popMenu, triggered=lambda a=inNodeName:self.buildNode( a ) )
popMenu.addAction( buildAction )
deleteAction = QtGui.QAction( 'Delete Component', popMenu, triggered=lambda a=inNodeName:self.deleteComponentFromObject( a ) )
popMenu.addAction( deleteAction )
popMenu.exec_( componentLabel.mapToGlobal( point ) )
# Setup layout.
verticalLayout = QtGui.QVBoxLayout()
verticalLayout.setContentsMargins( 0,0,0,0 )
verticalLayout.setSpacing( 0 )
verticalLayout.setAlignment( QtCore.Qt.AlignTop )
# Label for component
componentLabel = QTWidgets.basicLabel( nodeName, 'bold', 10, 'black', '6E9094', inIndent=20 )
componentLabel.setMinimumHeight( 18 )
componentLabel.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
componentLabel.customContextMenuRequested.connect( lambda point, node=nodeName:on_context_menu( point, node ) )
# Properties
propertyStack = QtGui.QVBoxLayout()
propertyFrame = QTWidgets.basicFrame()
propertyFrame.setMinimumHeight( 40 )
propertyFrame.setMaximumHeight( 40 )
# Add string edit property
propertyPlug = NodeUtility.getPlug( nodeName, 'jointName' )
propertyValue = NodeUtility.getPlugValue( propertyPlug )
jointTextLayout = QTWidgets.stringProperty( 'Joint Name', propertyValue )
propertyStack.addLayout( jointTextLayout )
propertyFrame.setLayout( propertyStack )
verticalLayout.addWidget( componentLabel )
verticalLayout.addWidget( propertyFrame )
# Connections
textBox = propertyFrame.findChild( QtGui.QLineEdit )
textBox.editingFinished.connect( lambda inPlugName='jointName', inQTType='QLineEdit', inPlugValue=textBox, inNodeName=nodeName
:BasicJointComponent( inNodeName ).setComponentAttributeFromQT( inPlugName, inQTType, inPlugValue, inNodeName ) )
self.setLayout( verticalLayout )
示例7: nodeRotation
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [as 别名]
def nodeRotation( self ):
'''
dagFn= OpenMaya.MFnDagNode( self.fNodePath )
path = OpenMaya.MDagPath()
dagFn.getPath( path )
path.pop()
transformFn = OpenMaya.MFnTransform( path )
q = OpenMaya.MQuaternion()
transformFn.getRotation( q, OpenMaya.MSpace.kWorld )
return q
'''
plug = NodeUtility.getPlug( 'ControlBox1', 'rotate' )
rot = NodeUtility.getPlugValue( plug )
e = OpenMaya.MEulerRotation( rot[0], rot[1], rot[2] )
return e
示例8: getFrameBitSettings
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [as 别名]
def getFrameBitSettings( inFrameBit ):
'''
Retrieves the settings for the frame bit.
@param inFrameBit: String. Name of frame bit.
@return: Dictionary. All the custom attributes on the frame bit.
'''
attrList = cmds.listAttr( inFrameBit, userDefined=True )
if attrList is not None:
tempDict = {}
for attr in attrList:
plug = NodeUtility.getPlug( inFrameBit, attr )
plugValue = NodeUtility.getPlugValue( plug )
tempDict[ attr ] = plugValue
else:
tempDict = None
return tempDict
示例9: saveModule
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [as 别名]
def saveModule( self ):
'''
Save the module into an XML file for re-use.
We assume that the root node of the module is the one with the module root meta node.
This means it and all of it's children will be saved in the XML.
'''
# Get the selected module
item = cmds.ls( long=True, selection=True )[0]
# Try to get the module meta component.
moduleComp = Components.searchModule( item, 'ModuleRootComponent' )
if moduleComp:
# Get the module info and save it as an XML.
modulePlug = NodeUtility.getPlug( moduleComp[1], 'moduleName' )
moduleName = NodeUtility.getPlugValue( modulePlug )
XMLUtility.writeModuleXML( moduleComp[0], self.SELECTED_ITEM, moduleName )
示例10: componentGui
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [as 别名]
def componentGui( inNodeName ):
def on_context_menu( point ):
popMenu = QtGui.QMenu()
popMenu.addAction( 'actionEdit' )
popMenu.addAction( 'actionDelete' )
popMenu.addSeparator()
popMenu.addAction( 'actionAdd' )
popMenu.exec_( componentLabel.mapToGlobal( point ) )
mainWidget = QtGui.QWidget()
verticalLayout = QtGui.QVBoxLayout( mainWidget )
verticalLayout.setContentsMargins( 0,0,0,0 )
verticalLayout.setSpacing( 0 )
verticalLayout.setAlignment( QtCore.Qt.AlignTop )
# Label for component
componentLabel = QTWidgets.basicLabel( inNodeName, 'bold', 10, 'black', 448094 )
componentLabel.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
componentLabel.customContextMenuRequested.connect( on_context_menu )
propertyFrame = QTWidgets.basicFrame()
propertyFrame.setMinimumHeight( 40 )
propertyFrame.setMaximumHeight( 40 )
# Add string edit property
plug = NodeUtility.getPlug( inNodeName, 'jointName' )
plugValue = NodeUtility.getPlugValue( plug )
QTWidgets.stringProperty( propertyFrame, 'Joint Name', plugValue )
# Add everything to the vertical layout.
verticalLayout.addWidget( componentLabel )
verticalLayout.addWidget( propertyFrame )
#print 'test2: {0}'.format( prop.takeAt(0).widget() )
#print propertyFrame.count()
#print propertyFrame.findChild( QtGui.QLineEdit )
#for item in xrange( propertyFrame.count() ):
# print propertyFrame.itemAt( item ).widget()
return mainWidget
示例11: readCurveValues
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [as 别名]
def readCurveValues(inObj):
"""
Read stored curve CV values on an object. Object must have curve CV attributes
created with addCurveValues().
@param inObj: String. Name of object to add curve cv values too.
@return: List of dicts.
"""
curveAttrs = cmds.listAttr(inObj, string="curve*", category="nurbCurve")
# [cur, cur, ...]
# cur[i] = { #:[x,y,z] }
curList = []
for attr in curveAttrs:
plug = NodeUtility.getPlug(inObj, attr)
plugValue = NodeUtility.getPlugValue(plug)
cvDict = {}
for index, point in enumerate(plugValue):
cvDict[index] = point
curList.append(cvDict)
curList
return curList
示例12: __init__
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [as 别名]
def __init__( self, nodeName, parent=None ):
super( componentWidget, self ).__init__( parent )
self.parent = parent
def on_context_menu( point, inNodeName ):
popMenu = QtGui.QMenu()
deleteAction = QtGui.QAction( 'Delete Component', popMenu, triggered=lambda a=inNodeName:self.deleteComponentFromObject( a ) )
popMenu.addAction( deleteAction )
popMenu.exec_( self.componentLabel.mapToGlobal( point ) )
# Colors.
userColors = GeneralUtility.getUserDefinedColors( inType=1 )
self.colorList = []
for color in userColors:
self.colorList.append( GeneralUtility.convertRGB( color, inType=1 ) )
# Setup layout.
verticalLayout = QtGui.QVBoxLayout()
verticalLayout.setContentsMargins( 0,0,0,0 )
verticalLayout.setSpacing( 0 )
verticalLayout.setAlignment( QtCore.Qt.AlignTop )
# Label for component
#self.componentLabel = QTWidgets.basicLabel( nodeName, 'bold', 10, 'black', '6E9094', inIndent=20 )
self.componentLabel = QtGui.QLabel()
self.componentLabel.setText( nodeName )
self.componentLabel.setIndent( 20 )
controlColorPlug = NodeUtility.getPlug( nodeName, 'controlColor' )
self.COLOR = NodeUtility.getPlugValue( controlColorPlug )
self.componentLabel.setStyleSheet( 'font:bold; font-size:10px; color:black; background-color:rgb({0},{1},{2})'.format(self.colorList[self.COLOR-1][0],
self.colorList[self.COLOR-1][1],
self.colorList[self.COLOR-1][2] ) )
self.componentLabel.setMinimumHeight( 18 )
self.componentLabel.setContextMenuPolicy( QtCore.Qt.CustomContextMenu )
self.componentLabel.customContextMenuRequested.connect( lambda point, nodeName=nodeName:on_context_menu( point, nodeName ) )
propertyFrame = QTWidgets.basicFrame()
propertyFrame.setMinimumHeight( 100 )
propertyFrame.setMaximumHeight( 100 )
propertyStack = QtGui.QVBoxLayout()
# Add string edit property
propertyRow = QtGui.QHBoxLayout()
propertyPlug = NodeUtility.getPlug( nodeName, 'controlName' )
propertyValue = NodeUtility.getPlugValue( propertyPlug )
self.textBox = QtGui.QLineEdit()
self.textBox.setAlignment( QtCore.Qt.AlignLeft )
self.textBox.setMinimumHeight( 20 )
if propertyValue:
self.textBox.setText( propertyValue )
textBoxLabel = QtGui.QLabel()
textBoxLabel.setText( 'Control Name' )
textBoxLabel.setAlignment( QtCore.Qt.AlignCenter )
textBoxLabel.setMinimumHeight( 12 )
propertyRow.addWidget( self.textBox )
propertyRow.addWidget( textBoxLabel )
# Colors.
colorRow = QtGui.QHBoxLayout()
color1Btn = QtGui.QPushButton()
color1Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[0][0], self.colorList[0][1], self.colorList[0][2] ) )
color1Btn.clicked.connect( lambda a=nodeName, b=1:self.colorChange( a, b ) )
color2Btn = QtGui.QPushButton()
color2Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[1][0], self.colorList[1][1], self.colorList[1][2] ) )
color2Btn.clicked.connect( lambda a=nodeName, b=2:self.colorChange( a, b ) )
color3Btn = QtGui.QPushButton()
color3Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[2][0], self.colorList[2][1], self.colorList[2][2] ) )
color3Btn.clicked.connect( lambda a=nodeName, b=3:self.colorChange( a, b ) )
color4Btn = QtGui.QPushButton()
color4Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[3][0], self.colorList[3][1], self.colorList[3][2] ) )
color4Btn.clicked.connect( lambda a=nodeName, b=4:self.colorChange( a, b ) )
color5Btn = QtGui.QPushButton()
color5Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[4][0], self.colorList[4][1], self.colorList[4][2] ) )
color5Btn.clicked.connect( lambda a=nodeName, b=5:self.colorChange( a, b ) )
color6Btn = QtGui.QPushButton()
color6Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[5][0], self.colorList[5][1], self.colorList[5][2] ) )
color6Btn.clicked.connect( lambda a=nodeName, b=6:self.colorChange( a, b ) )
color7Btn = QtGui.QPushButton()
color7Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[6][0], self.colorList[6][1], self.colorList[6][2] ) )
color7Btn.clicked.connect( lambda a=nodeName, b=7:self.colorChange( a, b ) )
color8Btn = QtGui.QPushButton()
color8Btn.setStyleSheet( 'background-color:rgb({0},{1},{2}); width:20'.format( self.colorList[7][0], self.colorList[7][1], self.colorList[7][2] ) )
color8Btn.clicked.connect( lambda a=nodeName, b=8:self.colorChange( a, b ) )
colorRow.addWidget( color1Btn )
colorRow.addWidget( color2Btn )
colorRow.addWidget( color3Btn )
colorRow.addWidget( color4Btn )
#.........这里部分代码省略.........
示例13: createFrameModuleXML
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [as 别名]
def createFrameModuleXML():
# Browse for file to replace or new file to make.
moduleFilter = "*.xml"
dialogResults = cmds.fileDialog2( fileFilter=moduleFilter, dialogStyle=2, startingDirectory=XMLUtility.getPresetPath( XMLUtility.FRAME_PRESETS_PATH ) )
tempPath = dialogResults[0].split( '/' )
fullFileName = tempPath[ len( tempPath )-1 ]
filePath = dialogResults[0].rstrip( fullFileName )
fileName = fullFileName.split( '.' )[0]
# Get the name of the selected node and it's plugs.
selList = cmds.ls( selection=True )
node = selList[0]
nodeAttrs = getFrameBitSettings( node )
# Build a list with each entry representing a line in the XML file.
xmlList = []
xmlList.append( '<data>' ) # Set the first line
# Meta node.
xmlList.append( '\t<metanode name=\"{0}\" metaType=\"{1}\" metaClass=\"{2}\">'.format( node, nodeAttrs['metaType'], nodeAttrs['metaClass'] ) )
# Loop through the attributes.
for attr in nodeAttrs:
plug = NodeUtility.getPlug( node, attr )
if plug.isConnected():
connection = NodeUtility.getNodeAttrSource( node, attr )
types = getAttrTypes( node, attr )
xmlList.append( '\t\t<plug name=\"{0}\" connected=\"{1}\" attrType=\"{2}\" attrDataType=\"{3}\">{4}</plug>'.format( attr,
True,
types[0],
types[1],
connection[0]+'.'+connection[1] ) )
else:
types = getAttrTypes( node, attr )
xmlList.append( '\t\t<plug name=\"{0}\" connected=\"{1}\" attrType=\"{2}\" attrDataType=\"{3}\">{4}</plug>'.format( attr,
False,
types[0],
types[1],
NodeUtility.getPlugValue( plug ) ) )
xmlList.append( '\t</metanode>' )
# Get the root bit of the frame module.
rootBit = NodeUtility.getNodeAttrSource( node, 'rootBit' )
if not rootBit:
raise ValueError( 'The meta node\'s ({0}) ROOT BIT attribute is not connected.'.format(node) )
# Get the parent's full path. We need to remove the group name from the beginning as well.
parent = cleanParentFullName( rootBit[0] )
xmlList.append( '\t<bit name=\"{0}\" parent=\"{1}\">'.format( rootBit[0], parent ) )
rootAttrs = getFrameBitSettings( rootBit[0] )
for attr in rootAttrs:
types = getAttrTypes( rootBit[0], attr )
plug = NodeUtility.getPlug( rootBit[0], attr )
xmlList.append( '\t\t<plug name=\"{0}\" attrType=\"{1}\" attrDataType=\"{2}\">{3}</plug>'.format( attr,
types[0],
types[1],
NodeUtility.getPlugValue( plug ) ) )
wmRootBit = TransformUtility.getMatrix( rootBit[0], 'matrix' )
pos = TransformUtility.getMatrixTranslation( wmRootBit, OpenMaya.MFn.kWorld )
rot = TransformUtility.getMatrixRotation( wmRootBit, 'eulerVector' )
xmlList.append( '\t\t<plug name=\"translateX\">{0}</plug>'.format( pos.x ) )
xmlList.append( '\t\t<plug name=\"translateY\">{0}</plug>'.format( pos.y ) )
xmlList.append( '\t\t<plug name=\"translateZ\">{0}</plug>'.format( pos.z ) )
xmlList.append( '\t\t<plug name=\"rotateX\">{0}</plug>'.format( math.degrees(rot.x) ) )
xmlList.append( '\t\t<plug name=\"rotateY\">{0}</plug>'.format( math.degrees(rot.y) ) )
xmlList.append( '\t\t<plug name=\"rotateZ\">{0}</plug>'.format( math.degrees(rot.z) ) )
# Shape nodes attributes.
rootShape = NodeUtility.getDagPath( rootBit[0] ).child( 0 )
depFn = OpenMaya.MFnDependencyNode( rootShape )
shapeName = cmds.listRelatives( rootBit[0], shapes=True, fullPath=True )[0]
shapeType = depFn.typeName()
xmlList.append( '\t\t<shape name=\"{0}\">'.format( shapeType ) )
# Get the shape's local position and scale.
for attr in cmds.listAttr( shapeName, channelBox=True ):
types = getAttrTypes( shapeName, attr )
aPlug = NodeUtility.getPlug( shapeName, attr )
xmlList.append( '\t\t\t<plug name=\"{0}\" attrType=\"{1}\" attrDataType=\"{2}\">{3}</plug>'.format( attr,
types[0],
types[1],
NodeUtility.getPlugValue(aPlug) ) )
# Get the shape's custom attributes.
for attr in cmds.listAttr( shapeName, multi=True, keyable=True ):
if attr.find( '[' ) is not -1:
# Special case handle array attributes. The [] needs to be removed so we can get
# the base name for the attribute. From there we can then loop through it's children.
# First we get the connection since these plugs won't return a value, but rather a
# connected node.
connection = NodeUtility.getNodeAttrSource( shapeName, attr )
bitChildren = cmds.listRelatives( rootBit[0], type='transform', children=True, fullPath=True )
for child in bitChildren:
if child.find( connection[0] ):
plugValue = child
#.........这里部分代码省略.........
示例14: draw
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [as 别名]
def draw( self, view, path, style, status ):
socketNode = OpenMaya.MFnDependencyNode( self.thisMObject() )
trX= OpenMaya.MPlug( self.thisMObject(), self.localPositionX ).asFloat()
trY= OpenMaya.MPlug( self.thisMObject(), self.localPositionY ).asFloat()
trZ= OpenMaya.MPlug( self.thisMObject(), self.localPositionZ ).asFloat()
lw = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute( 'lineWidth' ) ).asInt()
rt = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute ( 'rotate' ) )
a = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute( 'transparency' ) ).asFloat()
ba = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute( 'backAlpha' ) ).asFloat()
cl = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute ( 'color' ))
dt = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute ( 'drawType' ) ).asInt()
width = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute( 'width' ) ).asFloat()#X
height = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute( 'height' ) ).asFloat()#Y
depth = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute( 'depth' ) ).asFloat()#Z
rotation = NodeUtility.getPlugValue( rt )
color = NodeUtility.getPlugValue( cl )
( r, g, b ) = tuple( color )[:3]
# Get the point attributes used to offset each corner of the cube.
tfr = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute ( 'topFrontRight' ) )
tfl = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute ( 'topFrontLeft' ) )
tbr = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute ( 'topBackRight' ) )
tbl = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute ( 'topBackLeft' ) )
bfr = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute ( 'botFrontRight' ) )
bfl = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute ( 'botFrontLeft' ) )
bbr = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute ( 'botBackRight' ) )
bbl = OpenMaya.MPlug( self.thisMObject(), socketNode.attribute ( 'botBackLeft' ) )
# Get the values of each point plug.
vTFR = NodeUtility.getPlugValue( tfr )
vTFL = NodeUtility.getPlugValue( tfl )
vTBR = NodeUtility.getPlugValue( tbr )
vTBL = NodeUtility.getPlugValue( tbl )
vBFR = NodeUtility.getPlugValue( bfr )
vBFL = NodeUtility.getPlugValue( bfl )
vBBR = NodeUtility.getPlugValue( bbr )
vBBL = NodeUtility.getPlugValue( bbl )
# Do the maths! For each point we factor in the width/height/depth, the point tweak value and the offset object offset position.
drawPoints = []
drawPoints.append( [ ( width/2 + vBFL[0] ) + trX, ( -height/2+vBFL[1] ) + trY, ( depth/2+vBFL[2] ) + trZ ] ) #bottomFrontLeft
drawPoints.append( [ ( -width/2 + vBFR[0] ) + trX, ( -height/2+vBFR[1] ) + trY, ( depth/2+vBFR[2] ) + trZ ] ) #bottomFrontRight
drawPoints.append( [ ( width/2+vBBL[0] ) + trX, ( -height/2+vBBL[1] ) + trY, ( -depth/2+vBBL[2] ) + trZ ] ) #bottomBackLeft
drawPoints.append( [ ( -width/2+vBBR[0] ) + trX, ( -height/2+vBBR[1] ) + trY, ( -depth/2+vBBR[2] ) + trZ ] ) #bottomBackRight
drawPoints.append( [ ( width/2 + vTFL[0] ) + trX, ( height/2+vTFL[1] ) + trY, ( depth/2+vTFL[2] ) + trZ ] ) #topFrontLeft
drawPoints.append( [ ( -width/2 + vTFR[0] ) + trX, ( height/2+vTFR[1] ) + trY, ( depth/2+vTFR[2] ) + trZ ] ) #topFrontRight
drawPoints.append( [ ( width/2+vTBL[0] ) + trX, ( height/2+vTBL[1] ) + trY, ( -depth/2+vTBL[2] ) + trZ ] ) #topBackLeft
drawPoints.append( [ ( -width/2+vTBR[0] ) + trX, ( height/2+vTBR[1] ) + trY, ( -depth/2+vTBR[2] ) + trZ ] ) #topBackRight
# Calculate bounding box min and max points. Basically bbp1 is the bottom or negative point
# while bbp2 is the top or positive point.
X, Y, Z = ( [] for i in range( 3 ) )
for point in drawPoints:
X.append( point[0] )
Y.append( point[1] )
Z.append( point[2] )
self.bbp1 = OpenMaya.MPoint( min( X ), min( Y ), min( Z ) )
self.bbp2 = OpenMaya.MPoint( max( X ), max( Y ), max( Z ) )
def drawObject( self ):
# Draw the box
glFT.glBegin( OpenMayaRender.MGL_QUADS )
# Front. Normal faces +Z.
glFT.glVertex3f( drawPoints[1][0], drawPoints[1][1], drawPoints[1][2] )#bottom right
glFT.glVertex3f( drawPoints[0][0], drawPoints[0][1], drawPoints[0][2] )#bottom left
glFT.glVertex3f( drawPoints[4][0], drawPoints[4][1], drawPoints[4][2] )#top left
glFT.glVertex3f( drawPoints[5][0], drawPoints[5][1], drawPoints[5][2] )#top right
# Back. Normal faces -Z.
glFT.glVertex3f( drawPoints[3][0], drawPoints[3][1], drawPoints[3][2] )#bottom right
glFT.glVertex3f( drawPoints[7][0], drawPoints[7][1], drawPoints[7][2] )#top right
glFT.glVertex3f( drawPoints[6][0], drawPoints[6][1], drawPoints[6][2] )#top left
glFT.glVertex3f( drawPoints[2][0], drawPoints[2][1], drawPoints[2][2] )#bottom left
# Right. Normal faces -X.
glFT.glVertex3f( drawPoints[3][0], drawPoints[3][1], drawPoints[3][2] )#bottom back
glFT.glVertex3f( drawPoints[1][0], drawPoints[1][1], drawPoints[1][2] )#bottom front
glFT.glVertex3f( drawPoints[5][0], drawPoints[5][1], drawPoints[5][2] )#top front
glFT.glVertex3f( drawPoints[7][0], drawPoints[7][1], drawPoints[7][2] )#top back
# Left. Normal faces +X.
glFT.glVertex3f( drawPoints[0][0], drawPoints[0][1], drawPoints[0][2] )#bottom front
glFT.glVertex3f( drawPoints[2][0], drawPoints[2][1], drawPoints[2][2] )#bottom back
glFT.glVertex3f( drawPoints[6][0], drawPoints[6][1], drawPoints[6][2] )#top back
glFT.glVertex3f( drawPoints[4][0], drawPoints[4][1], drawPoints[4][2] )#top front
# Top. Normal faces +Y.
glFT.glVertex3f( drawPoints[5][0], drawPoints[5][1], drawPoints[5][2] )#front right
glFT.glVertex3f( drawPoints[4][0], drawPoints[4][1], drawPoints[4][2] )#front left
glFT.glVertex3f( drawPoints[6][0], drawPoints[6][1], drawPoints[6][2] )#back left
glFT.glVertex3f( drawPoints[7][0], drawPoints[7][1], drawPoints[7][2] )#back right
# Bottom. Normal faces -Y.
glFT.glVertex3f( drawPoints[3][0], drawPoints[3][1], drawPoints[3][2] )#back right
glFT.glVertex3f( drawPoints[2][0], drawPoints[2][1], drawPoints[2][2] )#back left
glFT.glVertex3f( drawPoints[0][0], drawPoints[0][1], drawPoints[0][2] )#front left
glFT.glVertex3f( drawPoints[1][0], drawPoints[1][1], drawPoints[1][2] )#front right
glFT.glEnd()
def drawShaded(self):
glFT.glEnable( OpenMayaRender.MGL_CULL_FACE )
glFT.glFrontFace( OpenMayaRender.MGL_CCW )
drawObject( self )
glFT.glDisable( OpenMayaRender.MGL_CULL_FACE )
glFT.glPolygonMode(OpenMayaRender.MGL_FRONT_AND_BACK, OpenMayaRender.MGL_LINE)
drawObject( self )
#.........这里部分代码省略.........
示例15: writeModuleXML
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import getPlugValue [as 别名]
def writeModuleXML( inRootObjectName, inModuleType, inModuleName ):
'''
Function for writing module xml.
@param inRootObjectName: String. Name of module root object.
@param inModuleType: String. Type of module. This determines which sub-folder the XML is saved.
@param inModuleName: String. Name of the module XML file.
'''
# Get list of the module hierarchy. Root is always first
hierarchyList = NodeUtility.getFrameRootAllChildren( inRootObjectName )
hierarchyList.insert( 0, inRootObjectName )
# START: Writing XML
xmlLines = []
xmlLines.append( '<data>' )
for item in hierarchyList:
# BIT INFO
itemName = getObjectShortName( item )
itemParent = NodeUtility.cleanParentFullName( item )
itemMatrix = TransformUtility.getMatrix( item, 'matrix' )
itemPosition = TransformUtility.getMatrixTranslation( itemMatrix, OpenMaya.MSpace.kTransform )
itemRotation = TransformUtility.getMatrixRotation( itemMatrix, 'eulerVector' )
# START: Bit
xmlLines.append( '\t<bit name=\"{0}\" parent=\"{1}\">'.format( itemName, itemParent ) )
xmlLines.append( '\t\t<plug name=\"translateX\">{0}</plug>'.format( itemPosition.x ) )
xmlLines.append( '\t\t<plug name=\"translateY\">{0}</plug>'.format( itemPosition.y ) )
xmlLines.append( '\t\t<plug name=\"translateZ\">{0}</plug>'.format( itemPosition.z ) )
xmlLines.append( '\t\t<plug name=\"rotateX\">{0}</plug>'.format( math.degrees(itemRotation.x) ) )
xmlLines.append( '\t\t<plug name=\"rotateY\">{0}</plug>'.format( math.degrees(itemRotation.y) ) )
xmlLines.append( '\t\t<plug name=\"rotateZ\">{0}</plug>'.format( math.degrees(itemRotation.z) ) )
# SHAPE
itemShape = NodeUtility.getDagPath( itemName ).child( 0 )
depFn = OpenMaya.MFnDependencyNode( itemShape )
shapeType = depFn.typeName()
if shapeType.find( 'gl' ) != -1:
itemShapeName = cmds.listRelatives( itemName, shapes=True, fullPath=True )[0]
# Start shape
xmlLines.append( '\t\t<shape name=\"{0}\">'.format( shapeType ) )
# Get the shape's local position and scale.
for attr in cmds.listAttr( itemShapeName, channelBox=True ):
types = NodeUtility.getAttrTypes( itemShapeName, attr )
aPlug = NodeUtility.getPlug( itemShapeName, attr )
xmlLines.append( '\t\t\t<plug name=\"{0}\" attrType=\"{1}\" attrDataType=\"{2}\">{3}</plug>'.format( attr, types[0], types[1], NodeUtility.getPlugValue(aPlug) ) )
# Get the shape's custom attributes.
for attr in cmds.listAttr( itemShapeName, multi=True, keyable=True ):
types = NodeUtility.getAttrTypes( itemShapeName, attr )
if attr.find( '[' ) is not -1:
# Special case handle array attributes. The [] needs to be removed so we can get
# the base name for the attribute. From there we can then loop through it's children.
# First we get the connection since these plugs won't return a value, but rather a
# connected node.
connection = NodeUtility.getNodeAttrSource( itemShapeName, attr )
bitChildren = cmds.listRelatives( itemName, type='transform', children=True, fullPath=True )
for child in bitChildren:
childSplit = child.split('|')
if childSplit[-1] == connection[0]:
plugValue = child
# Now we get the compound attribute's name by removing the index brackets.
attrSplit = attr.split('[')
attr = attrSplit[0]
else:
aPlug = NodeUtility.getPlug( itemShapeName, attr )
plugValue = NodeUtility.getPlugValue( aPlug )
if types[0] is not False:
xmlLines.append( '\t\t\t<plug name=\"{0}\" attrType=\"{1}\" attrDataType=\"{2}\">{3}</plug>'.format( attr, types[0], types[1], plugValue ) )
# End shape
xmlLines.append( '\t\t</shape>' )
# BIT COMPONENTS
print 'item: {0}'.format( item )
bitComponents = components.getComponents( item )
for comp in bitComponents:
# Component info
compName = ''.join(i for i in comp if not i.isdigit())
# Start component.
xmlLines.append( '\t\t<component name=\"{0}\">'.format( compName ) )
compSettings = NodeUtility.getModuleComponentSettings( comp )
for attr in compSettings:
types = NodeUtility.getAttrTypes( comp, attr )
# Special case message plugs.
if types[1] == 'message':
messageValues = NodeUtility.getAttrMessageValue( comp, attr )
if isinstance( messageValues, unicode ):
plugValue = messageValues
elif isinstance( messageValues, list ):
plugValue = None
else:
#.........这里部分代码省略.........