def shaveLink(self): ''' examine shave ''' self.allConnect() if 'shaveHair' in pm.allNodeTypes(): shaveNodeList = pm.ls(type='shaveHair') if shaveNodeList: if not pm.objExists('shave_G'): OpenMaya.MGlobal_displayError('Not shave_G Group') return if not pm.objExists('shave_setup_G'): OpenMaya.MGlobal_displayError('Not shave_setup_G Group') return shaveGroup = pm.PyNode('shave_G') if self.main.showMod not in shaveGroup.v.inputs(p=True): self.main.showMod.connect(shaveGroup.v, f=True) for shave in shaveNodeList: shaveAttrs = [ '.scale', '.rootThickness', '.tipThickness', '.displacement', '.rootSplay', '.tipSplay' ] shaveAttrsList = [shave + att for att in shaveAttrs] map(self.scaleLink, shaveAttrsList) OpenMaya.MGlobal_displayInfo('Character connected %s' % shave) self.setMesh('shaveHair') self.displayDialog('shave节点已关联总控的缩放属性! 蒙皮模型已设置不可渲染, 并隐藏锁定!') else: return False
def setModelNode(self): slm = QtGui.QStringListModel() slm.setStringList(pm.allNodeTypes()) self.completer.setModel(slm)
def _setup_data(self): """Check node classification, filter, save config file and return.""" classlist = ['utility', 'shader', 'transform', 'drawdb', 'general'] ignore = ['nexManip', 'xgmPatch'] nodes = [n for n in pm.allNodeTypes() for c in classlist if cmds.getClassification(n, satisfies=c) and cmds.getClassification(n) if not n in ignore] nodes = list(set(nodes + [n for n in pm.allNodeTypes() if (n.startswith('n_') or n == 'pointOnCurveInfo' or n == 'pointOnSurfaceInfo' or n == 'pointMatrixMult')])) data = dict() self._get_data(nodes, data) self._abbs = self._add_abbreviation(data) self._save_config_file(data) return data
def yetiLink(self): ''' examine yeti ''' self.allConnect() if 'pgYetiMaya' in pm.allNodeTypes(): yetiNodeList = pm.ls(type='pgYetiMaya') yetiList = [node.getParent() for node in yetiNodeList] if yetiList: if not pm.objExists('yeti_G'): OpenMaya.MGlobal_displayError('Not yeti_G Group') return if not pm.objExists('yeti_setup_G'): OpenMaya.MGlobal_displayError('Not yeti_setup_G Group') return yetiGroup = pm.PyNode('yeti_G') if self.main.showMod not in yetiGroup.v.inputs(p=True): self.main.showMod.connect(yetiGroup.v, f=True) if not self.main.hasAttr('abc'): self.main.addAttr('abc', at='enum', en="efx:anim:", k=True) self.main.abc.set(1) conAttrList = [] for yeti in yetiList: cons = yeti.listRelatives(type='parentConstraint') if not cons: OpenMaya.MGlobal_displayError( 'Not do %s node parentConstraint' % yeti) else: conAttrs = [attr.listAttr(ud=True)[0] for attr in cons] conAttrList += conAttrs for shape in yetiNodeList: if self.main.abc not in shape.fileMode.inputs(p=True): self.main.abc.connect(shape.fileMode, f=True) if conAttrList: for att in conAttrList: if self.main.abc not in att.inputs(p=True): self.main.abc.connect(att, f=True) self.setMesh('pgYetiMaya') if conAttrList: self.displayDialog( '总控abc属性已关联yeti的约束节点和cache属性! 蒙皮模型已设置不可渲染, 并隐藏锁定!') else: self.displayDialog( '总控abc属性已关联yeti的cache属性! 蒙皮模型已设置不可渲染, 并隐藏锁定! 约束节点没有!') else: return False
def _setup_data(self): """Check node classification, filter, save config file and return""" classlist = ['utility', 'shader', 'transform', 'drawdb', 'general'] nodes = [n for n in pm.allNodeTypes() for c in classlist if cmds.getClassification(n, satisfies=c) if n != 'nexManip'] data = dict() self._get_data(nodes, data) self._add_abbreviation(data) self._save_config_file(data) return data
def texlink(self): if pm.objExists('Main'): self.main = pm.PyNode('Main') else: OpenMaya.MGlobal_displayError('not Main ctrl') return if 'choice' in pm.allNodeTypes(): all = pm.ls(type='choice') if all: if len(all) == 1: pat = all[0] else: pat = [a for a in all if a.outputs(type='choice')][0] file1 = pat.input.inputs() num = [self.attrList[i] for i in range(len(file1))] enstr = ':'.join(num) if self.main.hasAttr('tex'): self.main.deleteAttr('tex') if not self.main.hasAttr('fileTextureName'): self.main.addAttr('fileTextureName', at='enum', en=enstr, k=True) self.rgbNode = self.getSG() self.deleConnect(self.rgbNode) if not self.rgbNode.hasAttribute('fileTextureName'): self.hsvAddAttr(self.rgbNode, num) if self.rgbNode.fileTextureName not in pat.selector.inputs( p=True): self.rgbNode.fileTextureName.connect(pat.selector, f=True) if not self.rgbNode.fileTextureName.inputs(): self.main.fileTextureName.connect( self.rgbNode.fileTextureName, f=True) else: OpenMaya.MGlobal_displayWarning('not choice Node') return else: OpenMaya.MGlobal_displayWarning('Thes is file not anamorphosis') return ctrName = self.main.name() try: rgbName = self.rgbNode.name() except: rgbName = None OpenMaya.MGlobal_displayWarning('not select RGB Node') self.win = AnamorphosisLinkUI(ctrName, rgbName)
def _setup_data(self): """Check node classification, filter, save config file and return""" classlist = ['utility', 'shader', 'transform', 'drawdb', 'general'] nodes = [ n for n in pm.allNodeTypes() for c in classlist if cmds.getClassification(n, satisfies=c) if n != 'nexManip' ] data = dict() self._get_data(nodes, data) self._add_abbreviation(data) self._save_config_file(data) return data
def test_lateNodeCreation(self): # makes sure that we can still access a node from pymel.core.nodetypes, # even if it's created outside of a plugin initialization # # This isn't just a hypothetical / academic possibility = ie, mtoa # creates nodes outside of it's initialize, due to it's plugin system allNodes = set(pm.allNodeTypes()) self.assertNotIn('initialNode', allNodes) self.assertNotIn('myLateCreatedNode', allNodes) self.assertFalse(hasattr(pm.nt, 'InitialNode')) self.assertFalse(hasattr(pm.nt, 'MyLateCreatedNode')) pm.loadPlugin(pluginPath) try: # first, check that the "initialNode" was created allNodes = set(pm.allNodeTypes()) self.assertIn('initialNode', allNodes) self.assertNotIn('myLateCreatedNode', allNodes) self.assertTrue(hasattr(pm.nt, 'InitialNode')) self.assertFalse(hasattr(pm.nt, 'MyLateCreatedNode')) myInitialNode = pm.nt.InitialNode() myInitialNode.attr('aFloat').set(5) self.assertEqual(pm.getAttr('{}.aFloat'.format(myInitialNode)), 5) pm.addDynamicNode('myLateCreatedNode') allNodes = set(pm.allNodeTypes()) self.assertIn('initialNode', allNodes) self.assertIn('myLateCreatedNode', allNodes) self.assertTrue(hasattr(pm.nt, 'InitialNode')) self.assertTrue(hasattr(pm.nt, 'MyLateCreatedNode')) myLateNode = pm.nt.MyLateCreatedNode() myLateNode.attr('aFloat').set(8) self.assertEqual(pm.getAttr('{}.aFloat'.format(myLateNode)), 8) finally: pm.newFile(f=1) pm.unloadPlugin(pluginName) allNodes = set(pm.allNodeTypes()) self.assertNotIn('initialNode', allNodes) self.assertNotIn('myLateCreatedNode', allNodes) self.assertFalse(hasattr(pm.nt, 'InitialNode')) self.assertFalse(hasattr(pm.nt, 'MyLateCreatedNode'))
def __init__(self, parent=None, editor=None): super(ScriptCompleter, self).__init__(parent) if dcc.is_maya(): import pymel.core as pm global NODE_TYPES_CACHE NODE_TYPES_CACHE = pm.allNodeTypes() self.setAlternatingRowColors(True) self.line_height = 18 self.editor = editor self.setAttribute(Qt.WA_ShowWithoutActivating) if osplatform.is_windows(): self.setWindowFlags(Qt.FramelessWindowHint | Qt.Window) else: self.setWindowFlags(Qt.FramelessWindowHint | Qt.Window | Qt.WindowStaysOnTopHint) self.itemDoubleClicked.connect(self._on_insert_selected)
def texlink(self): if pm.objExists('Main'): self.main = pm.PyNode('Main') else: OpenMaya.MGlobal_displayError('not Main ctrl') return if 'choice' in pm.allNodeTypes(): all = pm.ls(type='choice') if all: if len(all) == 1: pat = all[0] else: pat = [a for a in all if a.outputs(type='choice')][0] self.linksType(pat, 0) elif pm.ls(type='alSwitchColor'): pat = [ a for a in pm.ls(type='alSwitchColor') if a.mix.outputs(type='alSwitchColor') ] if not pat: OpenMaya.MGlobal_displayWarning( 'not choice and alSwitchColor Node') self.linksType(pat[0], 1) else: OpenMaya.MGlobal_displayWarning('not choice Node') return else: OpenMaya.MGlobal_displayWarning('Thes is file not anamorphosis') return ctrName = self.main.name() try: rgbName = self.rgbNode.name() except: rgbName = None OpenMaya.MGlobal_displayWarning('not select RGB Node')
def texlink(self): if pm.objExists('Main'): self.main = pm.PyNode('Main') else: OpenMaya.MGlobal_displayError('not Main ctrl') return if 'alSwitchColor' in pm.allNodeTypes(): all = pm.ls(type='alSwitchColor') if all: pat = [a for a in all if a.outputs(type='alSwitchColor')][0] file1 = pat.inputs(type='file') num = [str(i) for i in range(len(file1))] enstr = ':'.join(num) if not self.main.hasAttr('tex'): self.main.addAttr('tex', at='enum', en=enstr, k=True) if self.main.tex not in pat.mix.inputs(p=True): self.main.tex.connect(pat.mix, f=True) out = pat.outputs()[0] self.getSG(out) if self.SGNode: nodeList = self.SGNode.inputs()[0].inputs() for n in nodeList: if n.type() == 'remapHsv': self.rgbNode = n else: OpenMaya.MGlobal_displayWarning('Thes is file not anamorphosis') return ctrName = self.main.name() try: rgbName = self.rgbNode.name() except: rgbName = None OpenMaya.MGlobal_displayWarning('not select RGB Node') self.win = AnamorphosisLinkUI(ctrName, rgbName)
def __init__(self): """Class constructor function""" self._nodes = pm.allNodeTypes()
def yetiLink(self, outputNum=1): ''' examine yeti ''' self.allConnect() if 'pgYetiMaya' in pm.allNodeTypes(): yetiNodeList = pm.ls(type='pgYetiMaya') yetiList = [node.getParent() for node in yetiNodeList] if yetiList: if not pm.objExists('yeti_G'): OpenMaya.MGlobal_displayError('Not yeti_G Group') return if not pm.objExists('yeti_setup_G'): OpenMaya.MGlobal_displayError('Not yeti_setup_G Group') return yetiGroup = pm.PyNode('yeti_G') if self.main.showMod not in yetiGroup.v.inputs(p=True): self.main.showMod.connect(yetiGroup.v, f=True) if not self.main.hasAttr('yeti'): self.main.addAttr('yeti', at='long', min=0, max=1, dv=0, k=True) if pm.PyNode('yeti_show_G') not in self.main.yeti.outputs(): self.main.yeti.connect('yeti_show_G.v', f=True) if pm.objExists('hairMod_show_G'): self.modLowLink('yeti') conAttrList = [] for shape in yetiNodeList: if shape.cacheFileName.get(): yeti = shape.getParent() cons = yeti.listRelatives( type=['parentConstraint', 'scaleConstraint']) if cons: conAttrs = [ attr.listAttr(ud=True)[0] for attr in cons ] conAttrList += conAttrs else: if not pm.objExists('ass_G'): parCon = pm.parentConstraint('Head_M', yeti, mo=True) scaCon = pm.scaleConstraint('Head_M', yeti, mo=True) cons2 = [parCon, scaCon] conAttrs = [ attr.listAttr(ud=True)[0] for attr in cons2 ] conAttrList += conAttrs if not self.main.hasAttr('abc'): self.main.addAttr('abc', at='enum', en="efx:anim:", k=True) self.main.abc.set(1) if self.main.abc not in shape.fileMode.inputs(p=True): self.main.abc.connect(shape.fileMode, f=True) if conAttrList: for att in conAttrList: if self.main.abc not in att.inputs(p=True): self.main.abc.connect(att, f=True) if pm.objExists('ass_G'): self.linkAssGroup('yeti') chi = [ c for c in pm.PyNode('yeti_show_G').getChildren() if c.cacheFileName.get() ] for ch in chi: self.setNodeLocked(ch) nodeAttr = ch.listAttr(k=True) for att in nodeAttr: att.set(l=False) cons = ch.listRelatives( type=['parentConstraint', 'scaleConstraint']) for cn in cons: pm.delete(cn) pm.parentConstraint(self.loc, ch, mo=True) pm.scaleConstraint(self.loc, ch, mo=True) ch.v.set(0) for chr in chi: a_conAttrList = [] a_cons = chr.listRelatives( type=['parentConstraint', 'scaleConstraint']) a_conAttrs = [ attr.listAttr(ud=True)[0] for attr in a_cons ] a_conAttrList += a_conAttrs for att in a_conAttrList: if self.main.abc not in att.inputs(p=True): self.main.abc.connect(att, f=True) self.setMesh('pgYetiMaya') if outputNum: if conAttrList: self.displayDialog( '总控abc属性已关联yeti的约束节点和cache属性! 蒙皮模型已设置不可渲染, 并隐藏锁定!') else: self.displayDialog('蒙皮模型已设置不可渲染, 并隐藏锁定!') else: return False
def is_plugin_loaded(): """ Checks if Sol Handle plugin is loaded. :return bool """ return Vars.PLUGIN_NAME in pmc.allNodeTypes()
#!/usr/bin/python #-*-coding:gbk -*- ''' 这个模块中提供了createNodeMod模块的静态创建的自动代码生成 环境:maya2018及maya2018标准python ''' import pymel.core as pm node_list_str = 'except:\n' for i in pm.allNodeTypes(ia = False): node_list_str+=' def %s(*args,**kwargs):\n return createNode(\'%s\',*args,**kwargs)\n'%(i,i) print node_list_str