本文整理汇总了Python中marigold.utility.NodeUtility.setBitChild方法的典型用法代码示例。如果您正苦于以下问题:Python NodeUtility.setBitChild方法的具体用法?Python NodeUtility.setBitChild怎么用?Python NodeUtility.setBitChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类marigold.utility.NodeUtility
的用法示例。
在下文中一共展示了NodeUtility.setBitChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: doIt
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import setBitChild [as 别名]
def doIt( self, *args ):
# Window settings.
self.winWidth = 206
self.winHeight = 400
self.iconWidth = 32
self.iconHeight = 32
# Window colors
self.rowColors = [[0.4,0.4,0.4],[0.5,0.5,0.5]]
# Clean up old uis before opening a new one.
try:
cmds.deleteUI( self.winName )
except:
pass
# Setup the form layout.
self.mainWindow = cmds.window( self.winName, title=self.winTitle, sizeable=False, resizeToFitChildren=False )
self.form = cmds.formLayout()
self.tabs = cmds.tabLayout( innerMarginWidth=5, innerMarginHeight=5 )
# Attach the tabs layout to the form layout.
cmds.formLayout( self.form, edit=True, attachForm=( (self.tabs, 'top', 0), (self.tabs, 'left', 0), (self.tabs, 'bottom', 0), (self.tabs, 'right', 0) ) )
# Create each of the tabs.
# TAB: META NODES: START
self.tabMeta = cmds.rowColumnLayout( numberOfRows=2, width=self.winWidth )
self.colMeta = cmds.rowColumnLayout( numberOfColumns=1, height=self.winHeight/2 )
cmds.text( label='Meta Nodes', width=self.winWidth, wordWrap=True, align='center', font='boldLabelFont', backgroundColor=(0.15,0.15,0.15) )
cmds.separator( style='none', height=4 )
self.gridMeta = cmds.gridLayout( numberOfColumns=4, cellWidthHeight=( 50, 50 ) )
cmds.button( label='Basic', command=lambda b, a1='frameModule': metaNode.MetaNode( inNodeMetaType=a1 ) )
cmds.button( label='Character', command=lambda b, a1=False: metaNode.MetaCharacter( doModel=a1 ) )
cmds.setParent( '..' )#self.gridMeta
cmds.setParent( '..' )#self.colMeta
self.colMetaTools = cmds.rowColumnLayout( numberOfColumns=1 )
cmds.text( label='Tools', width=self.winWidth, wordWrap=True, align='center', font='boldLabelFont', backgroundColor=(0.15,0.15,0.15) )
cmds.separator( style='none', height=4 )
self.rowMetaTools = cmds.rowColumnLayout( numberOfRows=1 )
cmds.button( label='Meta Node List', annotation='meta node list',
command=lambda b: SelectMetaUI.selectMetaUI() )
cmds.setParent( '..' )#self.rowMetaTools
cmds.setParent( '..' )#self.colMetaTools
cmds.setParent( '..' )#self.tabMeta
# TAB: META NODES: END
# TAB: BITS, START
self.tabBits = cmds.rowColumnLayout( numberOfRows=3, width=self.winWidth )
self.bitsCol = cmds.rowColumnLayout( numberOfColumns=1, height=self.winHeight/3 )
cmds.text( label='Bit Primitives', width=self.winWidth, wordWrap=True, align='center', font='boldLabelFont', backgroundColor=(0.15,0.15,0.15) )
cmds.separator( style='none', height=4 )
self.bitsGrid = cmds.gridLayout( numberOfColumns=4, cellWidthHeight=( 50, 50 ) )
cmds.button( label='Sphere', command=lambda b, a1='glSphere': cmds.makeGLBit( objecttype=a1 ) )
cmds.button( label='Box', command=lambda b, a1='glBox': cmds.makeGLBit( objecttype=a1 ) )
cmds.button( label='Cylinder', command=lambda b, a1='glCylinder': cmds.makeGLBit( objecttype=a1 ) )
cmds.button( label='Cone', command=lambda b, a1='glCone': cmds.makeGLBit( objecttype=a1 ) )
cmds.button( label='Torus', command=lambda b, a1='glTorus': cmds.makeGLBit( objecttype=a1 ) )
cmds.setParent( '..' )#self.bitsGrid
cmds.setParent( '..' )#self.bitsCol
self.toolsCol = cmds.rowColumnLayout( numberOfColumns=1 )
cmds.text( label='Transform Tools', width=self.winWidth, wordWrap=True, align='center', font='boldLabelFont', backgroundColor=(0.15,0.15,0.15) )
cmds.separator( style='none', height=4 )
self.toolRow = cmds.rowColumnLayout( numberOfRows=1 )
cmds.iconTextButton( annotation='match translation', style='iconOnly',
width=self.winWidth/3, image1='icon_match_translation.png',
command=lambda a1='tran': TransformUtility.matchTransforms(a1) )
cmds.iconTextButton( annotation='match rotation', style='iconOnly',
width=self.winWidth/3, image1='icon_match_rotation.png',
label='match rotation', command=lambda a1='rot': TransformUtility.matchTransforms(a1) )
cmds.iconTextButton( annotation='match all', style='iconOnly',
width=self.winWidth/3, image1='icon_match_all.png',
label='match all', command=lambda a1='all': TransformUtility.matchTransforms(a1) )
cmds.setParent( '..' )#self.toolRow
cmds.setParent( '..' )#self.toolsCol
self.childCol = cmds.rowColumnLayout( numberOfColumns=1 )
cmds.text( label='General Tools', width=self.winWidth, wordWrap=True, align='center', font='boldLabelFont', backgroundColor=(0.15,0.15,0.15) )
cmds.separator( style='none', height=4 )
self.childRow = cmds.rowColumnLayout( numberOfColumns=2 )
cmds.button( label='Add Child', command=lambda b: NodeUtility.setBitChild() )
cmds.button( label='Remove Child', command=lambda b: NodeUtility.deleteBitChild() )
cmds.button( label='Copy Settings', command=lambda b: NodeUtility.copyBitSettings() )
cmds.setParent( '..' )#self.childRow
cmds.setParent( '..' )#self.childCol
cmds.setParent( '..' )#self.tabBits
# TAB: BITS, END
# TAB: ATTRIBUTES, START
self.tabAttrs = cmds.rowColumnLayout( numberOfRows=2 )
# Top
self.attrTop = cmds.rowColumnLayout( numberOfColumns=1 )
cmds.text( label='Attribute List', width=self.winWidth, wordWrap=True, align='center', font='boldLabelFont', backgroundColor=(0.15,0.15,0.15) )
cmds.separator( style='none', height=4 )
#.........这里部分代码省略.........
示例2: loadModule
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import setBitChild [as 别名]
def loadModule( inFolder, inFileName ):
'''
Loads a module into the scene.
@param inFolder: String. Name for the sub-folder the module XML is located.
@param inFileName: String. Name of the module XML.
'''
dirPath = getPresetPath( FRAME_PRESETS_PATH+inFolder )
fullPath = dirPath+'/'+inFileName+'.xml'
xmlFile = readModuleXML( fullPath )
# Create a temp group to put the module inside while creating.
moduleGroup = '|{0}'.format( cmds.group( em=True, name='TEMP' ) )
# Grab all the bits.
bits = xmlFile['bits']
# Make each bit.
tick = 0
storeBitConnections = []
while tick < len(bits):
if bits[0]['parent'] == 'None':
bitParent = moduleGroup
else:
bitParent = moduleGroup+bits[0]['parent']
bitName = bits[0]['name']
bitPlugs = bits[0]['plugs']
shapePlugs = bits[0]['shape']
bitComponents = bits[0]['components']
# Make the bit.
if cmds.objExists( bitParent ):
newBit = cmds.makeGLBit( name=bitName, objecttype=bits[0]['shapeType'] )
cmds.parent( newBit, bitParent )
# From this point we use the long name for the bit. This avoids any
# name clashes.
fullBitName = '{0}{1}'.format( bitParent, newBit )
# Setup plugs for transform and custom attributes.
for plug in bitPlugs:
if not NodeUtility.attributeCheck( fullBitName, plug['name'] ):
NodeUtility.addPlug( fullBitName, plug['name'], plug['attrType'], plug['attrDataType'] )
if plug['value'] is not None:
NodeUtility.setPlug( fullBitName, plug['name'], plug['value'], inAttrDataType=plug['attrDataType'] )
else:
# Setup position and rotation.
NodeUtility.setPlug( fullBitName, plug['name'], plug['value'] )
# Setup plugs for shape attributes.
shapeName = cmds.listRelatives( fullBitName, shapes=True )
fullShapeName = '{0}|{1}'.format( fullBitName, shapeName[0] )
for plug in shapePlugs:
if plug['attrDataType'] == 'TdataCompound' or plug['attrDataType'] == 'matrix':
# We skip compound nodes at this stage. They are for the child arrow drawing and must be
# hooked up after all the objects are created.
connectionChild = '{0}{1}'.format( moduleGroup, plug['value'] )
storeBitConnections.append( { 'parent':fullBitName, 'child':connectionChild } )
elif plug['attrDataType'] == 'message':
print 'MESSAGE'
else:
NodeUtility.setPlug( fullShapeName, plug['name'], plug['value'], inAttrDataType=plug['attrDataType'] )
# Setup bit components.
for comp in bitComponents:
compType = comp['name']
# We have to special case components that have additional kwargs.
if compType == 'CurveControlComponent':
# Handle curve control component type.
for plug in comp['plugs']:
if plug['name'] == 'curveType':
curveType = plug['value']
newComp = components.addComponentToObject( compType, inObject=fullBitName, curveType=curveType )
else:
# Handle basic component.
newComp = components.addComponentToObject( compType, inObject=fullBitName )
for plug in comp['plugs']:
# Bit of a hack with the parentName attribute. This attr is setup when the component is created.
# So there is no need to apply the stored plug value from the XML.
if plug['attrDataType'] == 'message':
if plug['name'] != 'parentName':
if plug['value'] != 'None':
sourcePlug = plug['value'].split('.')
NodeUtility.connectNodes( sourcePlug[0], sourcePlug[1], newComp.name(), plug['name'] )
else:
NodeUtility.setPlug( newComp.name(), plug['name'], plug['value'], inAttrDataType=plug['attrDataType'] )
# Remove the bit from the list
bits.remove( bits[0] )
#tick = tick+1
# Now do the hook ups for the child arrows.
for i in storeBitConnections:
NodeUtility.setBitChild( i['parent'], i['child'] )
示例3: __init__
# 需要导入模块: from marigold.utility import NodeUtility [as 别名]
# 或者: from marigold.utility.NodeUtility import setBitChild [as 别名]
def __init__( self ):
super( UIBitsTools, self ).__init__()
layout = QtGui.QVBoxLayout( self )
# Build bits controls
# Presets
moduleRootBtn = QTWidgets.imageButton( 'Create Module', ':/riggingUI/icons/preset_module.png', [32,32] )
moduleRootBtn.clicked.connect( lambda a=1:self.preset_buttons(a) )
characterRootBtn = QTWidgets.imageButton( 'Create Character', ':/riggingUI/icons/preset_character.png', [32,32] )
characterRootBtn.clicked.connect( lambda a=2:self.preset_buttons(a) )
# Primitive buttons.
sphereBtn = QTWidgets.imageButton( 'Sphere', ':/riggingUI/icons/bit_sphere.png', [32,32] )
sphereBtn.clicked.connect( self.primitive_buttons )
boxBtn = QTWidgets.imageButton( 'Box', ':/riggingUI/icons/bit_box.png', [32,32] )
boxBtn.clicked.connect( self.primitive_buttons )
cylinderBtn = QTWidgets.imageButton( 'Cylinder', ':/riggingUI/icons/bit_cylinder.png', [32,32] )
cylinderBtn.clicked.connect( self.primitive_buttons )
coneBtn = QTWidgets.imageButton( 'Cone', ':/riggingUI/icons/bit_cone.png', [32,32] )
coneBtn.clicked.connect( self.primitive_buttons )
torusBtn = QTWidgets.imageButton( 'Torus', ':/riggingUI/icons/bit_torus.png', [32,32] )
torusBtn.clicked.connect( self.primitive_buttons )
# Bit tools.
matchTranslationBtn = QTWidgets.imageTextButton( 'Match Translation', ':/riggingUI/icons/icon_match_translation.png', [16,16] )
matchTranslationBtn.clicked.connect( lambda a='tran':TransformUtility.matchTransforms( a ) )
matchRotationBtn = QTWidgets.imageTextButton( 'Match Rotation', ':/riggingUI/icons/icon_match_rotation.png', [16,16] )
matchRotationBtn.clicked.connect( lambda a='rot':TransformUtility.matchTransforms( a ) )
matchAllBtn = QTWidgets.imageTextButton( 'Match All', ':/riggingUI/icons/icon_match_all.png', [16,16] )
matchAllBtn.clicked.connect( lambda a='all':TransformUtility.matchTransforms( a ) )
copyBitSettingsBtn = QTWidgets.imageTextButton( 'Copy Bit Settings', ':/riggingUI/icons/bit_copy_settings.png', [16,16] )
copyBitSettingsBtn.clicked.connect( lambda:NodeUtility.copyBitSettings() )
addChildBtn = QTWidgets.imageTextButton( 'Add Child', ':/riggingUI/icons/bit_add_child.png', [16,16] )
addChildBtn.clicked.connect( lambda:NodeUtility.setBitChild() )
deleteChildBtn = QTWidgets.imageTextButton( 'Delete Child', ':/riggingUI/icons/bit_delete_child.png', [16,16] )
deleteChildBtn.clicked.connect( lambda:NodeUtility.deleteBitChild() )
# Build bits layout.
# Presets.
presetsHeader = QTWidgets.basicLabel( 'Bit Presets', 'bold', 14, 'white', '2B2B30' )
presetsHeader.setMinimumHeight( 30 )
presetsHeader.setAlignment( QtCore.Qt.AlignCenter )
presetsFrame = QTWidgets.basicFrame()
presetsLayout = QtGui.QHBoxLayout()
presetsLayout.addWidget( moduleRootBtn )
presetsLayout.addWidget( characterRootBtn )
presetsFrame.setLayout( presetsLayout )
# Primitive buttons
bitPrimitivesHeader = QTWidgets.basicLabel( 'Bit Primitives', 'bold', 14, 'white', '2B2B30' )
bitPrimitivesHeader.setMinimumHeight( 30 )
bitPrimitivesHeader.setAlignment( QtCore.Qt.AlignCenter )
primitiveFrame = QTWidgets.basicFrame()
primitiveLayout = QtGui.QHBoxLayout()
primitiveLayout.addWidget( sphereBtn )
primitiveLayout.addWidget( boxBtn )
primitiveLayout.addWidget( cylinderBtn )
primitiveLayout.addWidget( coneBtn )
primitiveLayout.addWidget( torusBtn )
primitiveFrame.setLayout( primitiveLayout )
# Bit tools.
bitToolsHeader = QTWidgets.basicLabel( 'Bit Tools', 'bold', 14, 'white', '2B2B30' )
bitToolsHeader.setMinimumHeight( 30 )
bitToolsHeader.setAlignment( QtCore.Qt.AlignCenter )
bitToolsGrid = QtGui.QGridLayout()
bitToolsGrid.setColumnMinimumWidth( 0, 100 )
bitToolsGrid.setColumnMinimumWidth( 1, 100 )
bitToolsGrid.setColumnMinimumWidth( 2, 100 )
bitToolsGrid.setSpacing( 2 )
bitToolsGrid.setContentsMargins( 0,0,0,0 )
# widget, row, col
bitToolsGrid.addWidget( matchTranslationBtn, 0, 0 )
bitToolsGrid.addWidget( matchRotationBtn, 0, 1 )
bitToolsGrid.addWidget( matchAllBtn, 0, 2 )
bitToolsGrid.addWidget( copyBitSettingsBtn, 1, 0 )
bitToolsGrid.addWidget( addChildBtn, 1, 1 )
bitToolsGrid.addWidget( deleteChildBtn, 1, 2 )
# Added the bits widgets to the sub-layout of the main window.
layout.addWidget( presetsHeader )
layout.addWidget( presetsFrame )
layout.addWidget( bitPrimitivesHeader )
layout.addWidget( primitiveFrame )
layout.addWidget( bitToolsHeader )
#.........这里部分代码省略.........