def defineSource(self, *a): sl = cmds.ls(selection=1, fl=1) s = '' for x in sl: s = s + x.split('.')[-1] if x != sl[-1]: s = s + ',' cmds.treeView('tree_apsbPL', e=1, addItem=(s, ''))
def treeViewButton_3_Action(item, state): if state == '0': cmds.setAttr(item+':proxyGeometryGrp.overrideDisplayType', 0) cmds.treeView('__MRT_treeView_SceneModulesUI', edit=True, buttonTransparencyColor=[item, 3, 0.68, 0.85, 0.90]) if state == '1': cmds.setAttr(item+':proxyGeometryGrp.overrideDisplayType', 2) cmds.treeView('__MRT_treeView_SceneModulesUI', edit=True, buttonTransparencyColor=[item, 3, 0.42, 0.87, 1.0])
def selectItemCmd(sel,state): if state: mc.treeView( 'familyTree', edit=True, si=[sel,1]) mc.select(sel,r=1) else: mc.treeView( 'familyTree', edit=True, si=[sel,0]) mc.select(sel,d=1)
def __init__(self, allowMultiSelection=True): self.items = [] selectCommand = self.selectionChanged editCommand = self.editLabelCommand if Utils.getMayaVersion() < Utils.MAYA2012: selectCommand = Utils.createMelProcedure(self.selectionChanged, [('int', 'item'), ('int', 'state')], returnType="int") editCommand = Utils.createMelProcedure(self.editLabelCommand, [('string', 'item'), ('string', 'newName')]) self.control = cmds.treeView( numberOfButtons=0, height=100, selectCommand=selectCommand, editLabelCommand=editCommand, dragAndDropCommand=self.handleDragDropCommand) cmds.treeView(self.control, e=True, enableKeys=True) # list of selected IDs self.selectedItems = [] self.onSelectionChanged = Signal() self.__selectionChanging = False self.__itemNameChanging = False
def heyWitch_addTargetMesh(self, basePass, tgtMshLabelTextFld): spawnMesh = basePass.mesh_spawn_name baseMesh = basePass.burn_group_label targetMeshName = "tgtMsh_" + tgtMshLabelTextFld cmds.duplicate(spawnMesh, name=targetMeshName) self.helper.heyWitch_blankSlate(targetMeshName) # outliner group cmds.select(clear=True) cmds.parent(targetMeshName, (baseMesh + '_tgt_grp')) ###CHECK IF BLEND NODE EXISTS FIRST! if cmds.objExists(baseMesh + "_blndNde"): tgtNo = len(cmds.listConnections(baseMesh + "_blndNde.it[0].iti")) + 1 cmds.blendShape((baseMesh + "_blndNde"), edit=True, t=(baseMesh, tgtNo, targetMeshName, 1)) else: cmds.blendShape(targetMeshName, baseMesh, n=(baseMesh + "_blndNde")) cmds.setAttr(baseMesh + "_blndNde." + targetMeshName, 1) targetMesh = TargetMesh() targetMesh.mesh_spawn_name = spawnMesh targetMesh.burn_group_label = baseMesh targetMesh.vert_vals = basePass.vert_vals targetMesh.target_mesh_label = str(targetMeshName) self.global_work_space['targetStorage'][targetMeshName] = targetMesh tree_layout = self.global_work_space['miscData']['switch_layouts']['msw_tree_layout'] cmds.treeView(tree_layout, edit=True, addItem=(targetMeshName, targetMesh.burn_group_label), cs=True) cmds.treeView(tree_layout, edit=True, selectItem=(targetMeshName, True)) self.helper.heyWitch_grabMesh(targetMeshName, targetMesh, self.global_work_space)
def showFileInfo(self,ppath,*args): pathA=self.pathA1[0:] getpath=cmds.textField('Path',q=True,tx=True) delto=getpath.replace('\\','/') path=delto+'/' trvsel=cmds.treeView('ok',q=True,si=True) trvselP=cmds.treeView('ok',q=True,ip=trvsel[0]) object=cmds.tabLayout('tuplistlayout',q=True,st=True) Path1=path+trvselP+'/'+trvsel[0]+'/'+object[0:]+'/' cmds.textField('dzlj',e=True,tx=ppath) tFpath=cmds.textField('dzlj',q=True,tx=True) amin=[w for w in os.listdir(tFpath) if w.endswith('.anim')] picc=[h for h in os.listdir(tFpath) if h.endswith('.jpg')] txt=[j for j in os.listdir(tFpath) if j.endswith('.txt')] cmds.textField('aniName',e=True,tx=amin[0]) cmds.image('Pic',e=True,image=tFpath+picc[0]) if len(txt)==0: cmds.scrollField('t6',e=True,text='没有txt文件!') else: fileId=open((tFpath+txt[0]),'r') filereadline=fileId.readline() if len(filereadline)==0: cmds.scrollField('t6',e=True,text='没备注') else: fileId1=open((tFpath+txt[0]),'r') for obj in fileId1: cmds.scrollField('t6',e=True,text=obj) fileId.close() fileId.close()
def cool(itemstring, state): cmds.treeView( control, e=True,buttonStyle=(itemstring,1,'2StateButton')) if state == '1': mode = 'buttonDown' else: mode = 'buttonUp' cmds.treeView( control, e=True,buttonState=(itemstring,1,mode)) print "%s on %s" % (mode, itemstring)
def deselect(self): from maya import cmds, mel tmp_var = "$_reveries_action_plugin_tmpvar_" fpe_window = mel.eval("%s = $gFPEWindowName;" % tmp_var) if cmds.window(fpe_window, query=True, exists=True): fpe_view = mel.eval("%s = $gFPETreeView;" % tmp_var) cmds.treeView(fpe_view, edit=True, clearSelection=True)
def p(self): pathA=self.pathA1[0:] getpath=cmds.textField('Path',q=True,tx=True) delto=getpath.replace('\\','/') path=delto+'/' trvsel=cmds.treeView('ok',q=True,si=True) trvselP=cmds.treeView('ok',q=True,ip=trvsel[0]) object=cmds.tabLayout('tuplistlayout',q=True,st=True) Path1=path+trvselP+'/'+trvsel[0]+'/'+object[0:]+'/' id1=cmds.getFileList(folder=Path1) slLc=cmds.scrollLayout(object[0:],q=True,ca=True) #cmds.rowColumnLayout('RowL',numberOfColumns=1,p=object[0:]) if slLc!=None: for slLcobj in slLc: cmds.deleteUI(slLcobj,control=True) else: print '没有' if cmds.formLayout('RowL',ex=True): cmds.deleteUI('RowL') #cmds.rowColumnLayout('RowL',numberOfColumns=1,p=object[0:]) cmds.formLayout('RowL',p=object[0:]) ksymbolButtonk=[] ktextk=[] k_tW=100 k_tH=100 k_tH=20 for i in range(len(id1)): pic=[w for w in os.listdir(Path1+id1[i]+'/') if w.endswith('.jpg')] pp=Path1+id1[i]+'/' #cmds.symbolButton(image=(Path1+id1[i]+'/'+pic[0]),ann='oo',p='RowL',w=100,h=100,c=partial(self.showFileInfo,(Path1+id1[i]+'/'))) #增加图片按钮 ksymbolButtonk.append(cmds.symbolButton(image=(Path1+id1[i]+'/'+pic[0]),p='RowL',w=k_tW,h=k_tH,c=partial(self.showFileInfo,(Path1+id1[i]+'/'))))#增加图片按钮 cmds.popupMenu() cmds.menuItem(l=u'导入动画数据',c = partial(self.eidtpath,(Path1+id1[i]+'/'))) cmds.menuItem(l=u'观看视频!',c=self.OPENVIDEO) cmds.menuItem(l=u'打开文件夹!',c=self.OPENFILE) cmds.menuItem(l=u'打开文件!',c=self.OPENMB) cmds.menuItem(l=u'信息查看与动画截取',c=self.editaniwin) #cmds.text(l=id1[i],p='RowL') ktextk.append(cmds.iconTextButton (style=('textOnly'),enable=0,l=id1[i],w=k_tW,h=k_tH,p='RowL')) self.editSBsize() for o in range(len(id1)): if o==0: cmds.formLayout('RowL',e=True,attachPosition=((ksymbolButtonk[o],'top',0,0),(ksymbolButtonk[o],'left',0,0))) elif o==1: cmds.formLayout('RowL',e=True,attachPosition=(ksymbolButtonk[o],'top',0,0),attachControl=(ksymbolButtonk[o],'left',0,ksymbolButtonk[o-1])) elif o%2==1: cmds.formLayout('RowL',e=True,attachControl=((ksymbolButtonk[o],'top',0,ktextk[o-2]),(ksymbolButtonk[o],'left',0,ksymbolButtonk[o-1]))) else: cmds.formLayout('RowL',e=True,attachControl=(ksymbolButtonk[o],'top',k_tH,ksymbolButtonk[o-2]),attachPosition=(ksymbolButtonk[o],'left',0,0)) for u in range(len(id1)): if u%2==1: cmds.formLayout('RowL',e=True,attachControl=((ktextk[u],'top',0,ksymbolButtonk[u]),(ktextk[u],'left',0,ktextk[u-1]))) else: cmds.formLayout('RowL',e=True,attachControl=(ktextk[u],'top',0,ksymbolButtonk[u]),attachPosition=(ktextk[u],'left',0,0))
def treeViewButton_2_Action(item, state): itemVisibility = cmds.getAttr(item+':moduleGrp.visibility') if itemVisibility: if state == '0': cmds.setAttr(item+':proxyGeometryGrp.visibility', 0) cmds.treeView('__MRT_treeView_SceneModulesUI', edit=True, buttonTransparencyColor=[item, 2, 0.65, 0.71, 0.90]) if state == '1': cmds.setAttr(item+':proxyGeometryGrp.visibility', 1) cmds.treeView('__MRT_treeView_SceneModulesUI', edit=True, buttonTransparencyColor=[item, 2, 0.57, 0.66, 1.0])
def __init__(self): #liste des attributs self.listNamespace = [] self.listEmptyNamespace = [] self.listSelectedNamespace = [] #If the window already exists, erase it if cmds.window('InE_NSMWin', exists=True): cmds.deleteUI('InE_NSMWin') #Create the window #s : Can window be resized? #rtf : Resize to fit childrens? self.window = cmds.window('InE_NSMWin', title = "Namespace Manager", widthHeight=(520, 435), s = False, rtf=True) #Main layout cmds.formLayout("InE_NSMFlowLayout", p = 'InE_NSMWin', w = 50, h = 50) cmds.image(image="R:\Benoit\Scripts\maya\icons\NSMBackground.png") #Layout that draws an empty space at the top to see the beautyful flowers cmds.columnLayout('InE_NSMEmptyLayout', p = "InE_NSMFlowLayout", columnAttach=('both', 14), rowSpacing=5, columnWidth=520, cal="left" ) cmds.text(label = "", p = 'InE_NSMEmptyLayout') cmds.text(label = "", p = 'InE_NSMEmptyLayout') cmds.text(label = "", p = 'InE_NSMEmptyLayout') cmds.text(label = "", p = 'InE_NSMEmptyLayout') cmds.text(label = "", p = 'InE_NSMEmptyLayout') #Real main layout containing all the UI cmds.rowColumnLayout( 'InE_NSMMainLayout', p = "InE_NSMEmptyLayout", numberOfColumns=2, columnWidth=[(1, 300), (2, 190)], h = 330, ro = [[1, "both", 20], [2, "both", 10]], co = [[1, "both", 10], [2, "both", 0]]) cmds.treeView('InE_NSMTextScrollList', parent = "InE_NSMMainLayout", numberOfButtons = 0, h= 150, abr = False, ams = True, adr = True, arp = True, idc = self.emptyMethod, sc = self.selectNamespace ) cmds.treeView('InE_NSMTextScrollList', edit = True, enk = True) cmds.columnLayout('InE_NSMInformations', p = "InE_NSMMainLayout", columnAttach=('both', 0), cw = 250, rowSpacing=5, cal="left" , ebg = True) cmds.text(p = 'InE_NSMInformations', label = "Informations") cmds.text('InE_NSMNameInformations', p = 'InE_NSMInformations', label = "") cmds.text('InE_NSMEmptyInformations', p = 'InE_NSMInformations', label = "") cmds.columnLayout('InE_NSMModifications', p = "InE_NSMMainLayout", columnAttach=('both', 20), co = ("both", 10), cw = 250, rowSpacing=6, cal="left" , ebg = True) cmds.text(p = 'InE_NSMModifications', label = "Rename selected to: ") cmds.textField('InE_NSMNameInput', p = 'InE_NSMModifications') cmds.radioCollection('InE_NSMRadioCollection', p = 'InE_NSMModifications') cmds.radioButton('InE_NSMRadioButton1', label='and keep namespace hierarchy', select=True ) cmds.radioButton('InE_NSMRadioButton2', label='and move namespace to root' ) cmds.button('InE_NSMRenameSelected', p = 'InE_NSMModifications', label = "Rename selected", en = True, command = self.renameSelected) cmds.columnLayout('InE_NSMButtons', p = "InE_NSMMainLayout", columnAttach=('both', 20), co = ("both", 10), rowSpacing=23, cal="left" , ebg = True) cmds.button('InE_NSMRemoveSelected', p = 'InE_NSMButtons', label = "Remove selected", w = 128, en = True, command = self.removeSelected) cmds.button('InE_NSMRemoveEmpty', p = 'InE_NSMButtons', label = "Remove empty", w = 128, en = True, command = self.removeEmpty) cmds.button('InE_NSMRemoveAll', p = 'InE_NSMButtons', label = "Remove all", w = 128, en = True, command = self.removeAll) cmds.showWindow() self.updateTreeView() print self.listNamespace
def __init__(self, key=None, **kw): super(TreeView, self).__init__(key=key, **kw) buttonCount = kw.get('numberOfButtons', 0) self.buttons = [ TreeViewButtonProxy(self, n) for n in range(buttonCount) ] for idx, btn in enumerate(self.buttons): cmds.treeView(self, e=True, pressCommand=(idx + 1, btn.pressed)) cmds.treeView(self, e=True, rightPressCommand=(idx + 1, btn.rightPressed))
def slInfluence(self): skinMesh = rig.textScrollList(self.slSkinTV, q=True, si=True) index = rig.textScrollList(self.slSkinTV, q=True, sii=True) skin = SK_getSkinCluster(skinMesh) rig.treeView(self.slJointTV, e=True, ra=True) infs = rig.skinCluster(skin, q=True, inf=True) rig.treeView(self.slJointTV, e=True, addItem=[(inf, '') for inf in infs])
def msw_tab_builder(self): mswPane = cmds.paneLayout(configuration='right3', st=1, height=455) mswFormLayout = cmds.formLayout(parent=mswPane) mswTreeView = cmds.treeView(parent=mswFormLayout, abr=False) cmds.formLayout(mswFormLayout, e=True, attachForm=(mswTreeView, 'top', 2)) cmds.formLayout(mswFormLayout, e=True, attachForm=(mswTreeView, 'left', 2)) cmds.formLayout(mswFormLayout, e=True, attachForm=(mswTreeView, 'bottom', 2)) cmds.formLayout(mswFormLayout, e=True, attachForm=(mswTreeView, 'right', 2)) msw_switch_Layout = cmds.frameLayout( parent=mswPane, label='Mesh Skinning Workspace Toolkit') msw_switch_Scroll = cmds.scrollLayout(backgroundColor=[0.2, 0.2, 0.2]) msw_switch_Grid = cmds.gridLayout(numberOfColumns=2, cellWidthHeight=(120, 25)) self.global_work_space['miscData']['switch_layouts'][ 'msw_switch'] = msw_switch_Grid self.global_work_space['miscData']['switch_layouts'][ 'msw_tree_layout'] = mswTreeView cmds.setParent('..') cmds.setParent('..') cmds.setParent('..') cmds.setParent('..') msw_grab_tabs = cmds.tabLayout(innerMarginWidth=5, innerMarginHeight=5, parent=mswPane) testtext = cmds.text(label='nothing to see here') cmds.tabLayout(msw_grab_tabs, edit=True, tabLabel=(testtext, '')) self.global_work_space['miscData']['switch_layouts'][ 'msw_grab_tabs'] = msw_grab_tabs cmds.setParent('..') cmds.setParent('..') spwnScan = self.global_work_space['spawnStorage'] for k, v in spwnScan.items(): if v.object_type == "Spawn": msw_name = k + "'s Mesh Skinning Workspace" self.add_to_tree(mswTreeView, msw_name, '') homePass = v.mesh_skinning_workspace self.send_burn_group_scout(homePass, mswTreeView, msw_name) self.send_utility_scout(homePass, mswTreeView, msw_name) cmds.treeView(mswTreeView, edit=True, scc=partial( self.burn_group_manager.sort_skinning_mingler, mswTreeView, msw_switch_Scroll, msw_switch_Layout, mswPane)) return mswPane
def internalEditLabelCommand(self, item, newName): ''' implements layer in-place rename ''' # do not allow empty layer names if newName.strip() == '': return '' LayerDataModel.getInstance().setLayerName(int(item), newName) cmds.treeView(self.control, e=True, displayLabel=(item, newName)) return item
def selectByID(self, id): if self.__selectionChanging: return if self.selectedID == id: return self.selectedItems.add(id) for i in self.items: cmds.treeView(self.control, e=True, si=(i.id, int(i.id == id)))
def internalEditLabelCommand(self, item, newName): ''' implements layer in-place rename ''' # do not allow empty layer names if newName.strip()=='': return '' LayerDataModel.getInstance().setLayerName(int(item),newName) cmds.treeView(self.control,e=True,displayLabel=(item,newName)) return item
def lock_unLock(self, jnt, but): slItem = cmds.treeView('JointTV_JellyBean', q=1, si=1) if not slItem or len(slItem) == 1: slItem = [jnt] if cmds.getAttr(jnt + '.liw'): for i in slItem: cmds.setAttr(i + '.liw', 0) cmds.treeView('JointTV_JellyBean', e=1, i=(i, 1, 'Lock_OFF_grey.png')) else: for i in slItem: cmds.setAttr(i + '.liw', 1) cmds.treeView('JointTV_JellyBean', e=1, i=(i, 1, 'Lock_ON.png'))
def selectedMembers(self,*args): setList = self.listLgtGrpSets() setTreeName = self.setTreeName selMemberList = [] for node in setList: memberList = mc.treeView(setTreeName, q = True, ch = node) for member in memberList: if member not in setList: selValue = mc.treeView(setTreeName, q = True, isl = member) if selValue == 1: selMemberList.append(member) return selMemberList
def mulObjWeights(self): sourceMeshs = rig.textScrollList(self.skinTV, q=True, si=True) sourceJointIndexs = rig.textScrollList(self.jointTV, q=True, sii=True) targetMeshs = rig.textScrollList(self.slSkinTV, q=True, si=True) targetJointNames = rig.treeView(self.slJointTV, q=True, si=True) if targetMeshs and sourceMeshs and targetJointNames and sourceJointIndexs: sourceMeshIndexs = rig.textScrollList(self.skinTV, q=True, sii=True) mainIndex = sourceMeshIndexs[0] - 1 skin = SK_getSkinCluster(targetMeshs) #获得SkinCluster infs = rig.treeView(self.slJointTV, q=True, si=True) #获得目标物体的影响体 sourData = self.allData[mainIndex][1] #获得权重数据 if len(rig.ls(targetMeshs[0] + '.vtx[*]', fl=True)) == len(sourData): if len(sourceJointIndexs) == len(infs): lockInfs = self.getLockInfs(infs) #解锁 rig.progressBar(self.infsPB, e=True, maxValue=len(infs), vis=True) #显示进度条 for num, jnt in enumerate(infs): #迭代选择影响体 if not ('NONE_JOINT_X' in jnt): #骨骼是否被忽略 Index = sourceJointIndexs[num] - 1 print 'complele:' + jnt for i, data in enumerate(sourData): #迭代所有的点 rig.skinPercent( skin, targetMeshs[0] + '.vtx[' + str(i) + ']', transformValue=[(jnt, data[Index])]) rig.setAttr(jnt + '.liw', 1) #锁定已完成的影响体 rig.progressBar(self.infsPB, edit=True, step=1) #设置进度条 else: print u'忽略.......' + jnt self.setUnLockInfs(lockInfs) rig.progressBar(self.infsPB, e=True, vis=False) #隐藏进度条 else: SM_warning(u'选择的影响体个数不一样') else: SM_warning(u'物体拓扑不一样,请选择正确的物体') else: SM_warning(u'请确定已经正确的选择')
def removeItemFromSet(self,*args): selMemberList = self.selectedMembers() setTreeName = self.setTreeName for member in selMemberList: if len(member.split('(')) > 1: memberName = member.split('(') parentSet = mc.treeView(setTreeName, q = True, ip =member) mc.sets(memberName[0], rm = parentSet) else: parentSet = mc.treeView(setTreeName, q = True, ip =member) mc.sets(member, rm = parentSet) self.rebuildSetTree()
def selectByID(self,id): if self.__selectionChanging: return if self.selectedID==id: return self.selectedItems.add(id) for i in self.items: cmds.treeView(self.control,e=True,si=(i.id,int(i.id==id)))
def setItems(self,newItems,selectedID): ''' sets new items in the ID list; :param list newItems: list of IdToNameEntry :param selectedID: item to select in the list after setting the items ''' log.debug("set items: {0},selected id: {1}".format(newItems,selectedID)) if self.items!=newItems: if self.__selectionChanging: raise Exception("cannot change items while selection is changing") if self.__itemNameChanging: # raise Exception("cannot change items while item name is changing") # silently exit: should be no harm ignoring new items as the only thing that changed # is label name, and we already reflect that in UI return self.selectedItems = [] cmds.treeView(self.control,e=True,clearSelection=True) cmds.treeView(self.control,e=True,removeAll=True) for i in newItems: cmds.treeView(self.control,e=True,addItem=(i.id,'')) cmds.treeView(self.control,e=True,displayLabel=(i.id,i.displayName),displayLabelSuffix=(i.id,i.suffix)) self.items = newItems self.selectByID(selectedID)
def setItems(self, newItems, selectedID): ''' sets new items in the ID list; :param list newItems: list of IdToNameEntry :param selectedID: item to select in the list after setting the items ''' log.debug("set items: {0},selected id: {1}".format( newItems, selectedID)) if self.items != newItems: if self.__selectionChanging: raise Exception( "cannot change items while selection is changing") if self.__itemNameChanging: # raise Exception("cannot change items while item name is changing") # silently exit: should be no harm ignoring new items as the only thing that changed # is label name, and we already reflect that in UI return self.selectedItems = [] cmds.treeView(self.control, e=True, clearSelection=True) cmds.treeView(self.control, e=True, removeAll=True) for i in newItems: cmds.treeView(self.control, e=True, addItem=(i.id, '')) cmds.treeView(self.control, e=True, displayLabel=(i.id, i.displayName), displayLabelSuffix=(i.id, i.suffix)) self.items = newItems self.selectByID(selectedID)
def setSelectedIDs(self, ids): log.debug("selecting by IDs: {0}".format(ids)) if self.__selectionChanging: return # remove any null items ids = [str(i) for i in ids if i is not None] if self.selectedItems == ids: return self.selectedItems = ids for i in self.items: cmds.treeView(self.control, e=True, si=(i.id, int(i.id in ids)))
def setSelectedIDs(self,ids): log.debug("selecting by ID: {0}".format(id)) if self.__selectionChanging: return # remove any null items ids = [i for i in ids if i is not None] if self.selectedItems == ids: return self.selectedItems = ids for i in self.items: cmds.treeView(self.control,e=True,si=(i.internalId,int(i.id in ids)))
def createLocator(self, tis, *a): self.executeCondition() tis = cmds.treeView('tree_apsbPL', q=1, children=1) # tree items sl = cmds.ls(selection=1) cll = [] # created locator name list for mn in sl: # mesh name if (cmds.nodeType(mn) == 'transform'): c = cmds.listRelatives(mn, shapes=1, noIntermediate=1) if (len(c) == 0): cmds.warning('Selection most be polygon.') else: mn = c[0] elif (cmds.nodeType(mn) == 'mesh'): mns = mn.split('.') if len(mns) > 1: mn = mns[0] else: cmds.warning('Selection most be polygon.') for ti in tis: # tree item xList = ti.split(',') xx = 0.0 xy = 0.0 xz = 0.0 for sti in xList: # splited tree item vn = mn + '.' + sti # vertex name if cmds.objExists(vn): yPos = cmds.xform(vn, q=1, translation=1, worldSpace=1) xx = xx + yPos[0] xy = xy + yPos[1] xz = xz + yPos[2] xx = xx / len(xList) xy = xy / len(xList) xz = xz / len(xList) loc = cmds.spaceLocator(position=[xx, xy, xz]) cll.append(loc[0]) cmds.select(cll, replace=1)
def insertKeyToAnimLayer(): ''' inserts key to all animcurves in anim layer, wont key if objects has not been keyed but is in anim layer ''' currentLayer = cmds.treeView ('AnimLayerTabanimLayerEditor', q=True, selectItem=True) curves = cmds.animLayer(currentLayer[0], q=True, anc=True) cmds.setKeyframe(curves, i=True)
def setVrayMat(self, args): if mc.rowColumnLayout('vrayRow', q=True, ex=True): mc.deleteUI('vrayRow') name = mc.treeView('control', q=True, itemSelected=True) listRowColum = mc.rowColumnLayout('vrayRow', numberOfColumns=4, p='vray')
def toggleAssembly(self, var, *args): for item in self.items: cmds.treeView(self.ui, e=True, buttonState=(item, 2, 'buttonUp' if var else 'buttonDown')) itemData = self.items[item] itemData.visibility = var assembly = itemData.assembly for a in assembly: try: cmds.setAttr('{}.v'.format(a), var) except: pass return
def slVtx(self): slJnt = cmds.treeView('JointTV_JellyBean', q=1, si=1) vtxList = [] for i in slJnt: cmds.skinCluster(self.tempcluster, e=1, siv=i) vtxList.append(cmds.filterExpand(cmds.ls(sl=1, fl=1), sm=[28, 31, 36, 40, 46])) cmds.select(vtxList, r=1)
def doubleClickCmd(item): allItems=mc.treeView( 'familyTree', q=True, ch=True) for i in allItems: if item==i: try: mc.setAttr(i+'.visibility',1) except: pass else: try: mc.setAttr(i+'.visibility',0) except: pass if mc.getAttr(i+'.v'): mc.treeView( 'familyTree', e=True, ch=True,tc=[i,1,1,1]) else: mc.treeView( 'familyTree', e=True, ch=True,tc=[i,0.3,0.3,0.3])
def loadAllReferences(self, *args): loadAllReferences(True) for item in self.items: cmds.treeView(self.ui, e=True, buttonState=(item, 1, 'buttonUp')) itemData = self.items[item] itemData.loaded = True itemData.assembly = [ x for x in getAllTopLevelNodes() if x.split(':')[0] == itemData.namespace ] try: itemData.namespace = cmds.referenceQuery(item, namespace=True)[1:] except: itemData.namespace = None return
def createSetTreeLayout(self): setTreeName = self.setTreeName layout = mc.formLayout() setTree = mc.treeView(setTreeName, parent = layout, abr = False) mc.formLayout(layout, e = True, attachForm=(setTree,'top',2)) mc.formLayout(layout, e = True, attachForm=(setTree,'left',2)) mc.formLayout(layout, e = True, attachForm=(setTree,'bottom',2)) mc.formLayout(layout, e = True, attachForm=(setTree,'right',2))
def _weightfloat(self): treesl = cmds.treeView('JointTV_JellyBean', q=1, si=1) sel = cmds.ls(sl=1, fl=1) if not treesl or not sel: return selobj = cmds.ls(sl=1, o=1)[0] clusterName = mel.eval('findRelatedSkinCluster("%s")' % selobj) cmds.floatField('weighrfloat_JellyBean', e=1, v=float('%.4f' % cmds.skinPercent(clusterName, sel[0], ib=.000000001, q=1, t=treesl[0])))
def heyWitch_addUtilityShop(self, homePass, utlMshLabelTextFld, needsBase, *args): spwnScan = self.global_work_space['spawnStorage'] for x in spwnScan.values(): if x.mesh_spawn_name == homePass.mesh_spawn_name: spawnMesh = x utlMeshName = "utlMsh_" + utlMshLabelTextFld utlBseMeshName = "utlBseMsh_" + utlMshLabelTextFld # making the burn base mesh # should add function to duplicate other meshes than the spawn cmds.duplicate(str(spawnMesh.mesh_spawn_name), name=utlMeshName) self.helper.heyWitch_blankSlate(utlMeshName) cmds.select(clear=True) if needsBase == True: cmds.duplicate(str(spawnMesh.mesh_spawn_name), name=utlBseMeshName) self.helper.heyWitch_blankSlate(utlBseMeshName) homeGroup = homePass.mesh_spawn_name + "_msw_grp" else: homeGroup = homePass.burn_group_label + '_tgt_grp' # outliner group utlWkshpNme = 'utlWkshp_' + utlMshLabelTextFld cmds.group(empty=True, name=utlWkshpNme + '_grp') cmds.parent(utlMeshName, (utlWkshpNme + '_grp')) cmds.setAttr(utlMeshName + '.visibility', 1) tree_layout = self.global_work_space['miscData']['switch_layouts'][ 'msw_tree_layout'] if cmds.objExists(utlBseMeshName): cmds.parent(utlBseMeshName, (utlWkshpNme + '_grp')) cmds.setAttr(utlBseMeshName + '.visibility', 0) cmds.treeView(tree_layout, edit=True, addItem=(utlWkshpNme, homePass.mesh_spawn_name + "'s Mesh Skinning Workspace"), cs=True) cmds.treeView(tree_layout, edit=True, selectItem=(utlWkshpNme, True)) else: cmds.treeView(tree_layout, edit=True, addItem=(utlWkshpNme, homePass.target_mesh_label), cs=True) cmds.treeView(tree_layout, edit=True, selectItem=(utlWkshpNme, True)) cmds.parent((utlWkshpNme + '_grp'), homeGroup) # no point in making objects if the type is not really available yet unlikelyString = 'veryunlikelynamenothingmustreallybeselected' self.helper.heyWitch_grabMesh(unlikelyString, homePass, self.global_work_space) cmds.select(utlMeshName) tempUtlLst = [] tempUtlLst = deepcopy(homePass.utility_nest) tempUtlLst.append(utlWkshpNme) homePass.utility_nest = deepcopy(tempUtlLst)
def show(self): self.close() win = mc.window(self._windowName, wh=self._windowSize, t=u'材质质感库', sizeable=False) layout = mc.formLayout() control = mc.treeView('control', parent=layout, abr=False) tabs = mc.tabLayout("tabs") arnoldScroll = mc.scrollLayout('arnold', p=tabs) vrayScroll = mc.scrollLayout('vray', p=tabs) mc.formLayout(layout, e=True, attachForm=[(control, 'top', 2), (control, 'left', 2), (control, 'bottom', 2), (tabs, 'top', 2), (tabs, 'right', 2), (tabs, 'bottom', 2)], attachPosition=[(control, 'left', 0, 0), (control, 'right', 0, 25), (tabs, 'left', 0, 25), (tabs, 'right', 0, 99)]) for key in assertText.keys(): mc.treeView(control, e=True, addItem=(key, '')) for typeName in assertText[key]: mc.treeView(control, e=True, addItem=(typeName, key)) mc.treeView(control, e=True, selectCommand=self.selectTreeCallBack) mc.showWindow(win) if not mc.pluginInfo('mtoa.mll', q=True, l=True): mc.loadPlugin('mtoa.mll')
def executeCondition(self, *a): tis = cmds.treeView('tree_apsbPL', q=1, children=1) # tree items if tis is None: cmds.warning('Position List Empty') return 0 sl = cmds.ls(selection=1) if (len(sl) == 0): cmds.warning('Select some polygons.') return 0
def shuai_creatSubCtrls(): if mc.window('createSubCtrlWin',ex=1): mc.deleteUI('createSubCtrlWin') mc.window('createSubCtrlWin',t='创建次级控制器面板',h=500,w=300,sizeable=1) mc.rowLayout('mainLayout',numberOfColumns=2,adjustableColumn=1,adjustableColumn2=1,rat=[(1,'both',1),(2,'both',1)]) mc.columnLayout('treeLayout',adjustableColumn=1) mc.treeView('familyTree', numberOfButtons = 0, allowDragAndDrop = False ,allowHiddenParents = False,allowMultiSelection = False,allowReparenting=False,w=200,h=400,selectCommand=selectItemCmd,idc=doubleClickCmd) mc.button('getFamilyTreeBt',w=200,h=50,l='获取层级关系',c='shuai_creatSubCtrls.getFamilyTreeCmd()') mc.button('cleanViewBt',w=200,h=50,l='清除',c='shuai_creatSubCtrls.cleanViewCmd()') mc.setParent('..') mc.columnLayout('buttonLayout',adjustableColumn=1) mc.button('addNewLavelBt',l='创建新次级模型',w=100,h=100,c='shuai_creatSubCtrls.addNewLavelCmd()') mc.button('createSubCtrlBt',l='创建控制器',w=100,h=100,c='shuai_creatSubCtrls.createSubCtrlButtonCmd()') mc.setParent('..') mc.showWindow('createSubCtrlWin')
def get_top_anim_layer(*args, **kwargs): index_dict = {} index_list = [] anim_layers = cmds.treeView('AnimLayerTabanimLayerEditor', q=True, children=True) if anim_layers: for layer in anim_layers: index = cmds.treeView('AnimLayerTabanimLayerEditor', q=True, idx=layer) index_list.append(index) index_dict[index] = layer return index_dict[max(index_list)] return
def selectedSets(self,*args): setList = self.listLgtGrpSets() setTreeName = self.setTreeName selSetList = [] for node in setList: selValue = mc.treeView(setTreeName, q = True, isl = node) if selValue == 1: selSetList.append(node) return selSetList
def __init__(self,allowMultiSelection=True): self.items = [] selectCommand = self.selectionChanged editCommand = self.editLabelCommand if Utils.getMayaVersion()<Utils.MAYA2012: selectCommand = Utils.createMelProcedure(self.selectionChanged, [('int','item'),('int','state')],returnType="int") editCommand = Utils.createMelProcedure(self.editLabelCommand, [('string','item'),('string','newName')]) self.control = cmds.treeView(numberOfButtons=0, height=100, selectCommand=selectCommand, editLabelCommand=editCommand,dragAndDropCommand=self.handleDragDropCommand) cmds.treeView(self.control,e=True,enableKeys=True) # list of selected IDs self.selectedItems = [] self.onSelectionChanged = Signal() self.__selectionChanging = False self.__itemNameChanging = False
def show(self): self.close() win = mc.window(self._windowName, wh = self._windowSize, t = u'灯光库', sizeable = False) layout = mc.formLayout() control = mc.treeView('control', parent = layout, abr = False ) lightScroll = mc.scrollLayout('light', p=layout) mc.formLayout(layout, e=True, attachForm = [(control,'top', 2), (control,'left', 2), (control,'bottom', 2), (lightScroll,'top', 2), (lightScroll,'right', 2), (lightScroll,'bottom', 2)], attachPosition = [(control, 'left', 0, 0), (control, 'right', 0, 25), (lightScroll, 'left', 0, 25), (lightScroll, 'right', 0, 99)]) for key in self.info.keys(): mc.treeView(control, e = True, addItem = (key, '')) # for typeName in assertText[key]: # mc.treeView(control, e = True, addItem = (typeName, key)) mc.treeView(control, e = True, selectCommand = self.setLightList) mc.showWindow(win)
def ren(self): pathA=self.pathA1[0:] getpath=cmds.textField('Path',q=True,tx=True) delto=getpath.replace('\\','/') path=delto+'/' tabLayoutlist=cmds.tabLayout('tuplistlayout',q=True,tabLabel=True) if tabLayoutlist==None: print 'no!' else: for tabLayoutlistobj in tabLayoutlist: cmds.deleteUI(tabLayoutlistobj,control=True) trvsel=cmds.treeView('ok',q=True,si=True) trvselP=cmds.treeView('ok',q=True,ip=trvsel[0]) Path=path+trvselP+'/'+trvsel[0]+'/' id=cmds.getFileList(folder=Path) for k in id: cmds.scrollLayout(k,p='tuplistlayout',nch=2)#布局 cmds.tabLayout('tuplistlayout',edit=True,tabLabel=(k, k ),sc=self.P) self.P()
def moduleSelectionFromTreeView(): active_selection = [] selection = cmds.treeView('__MRT_treeView_SceneModulesUI', query=True, selectItem=True) if selection: for select in selection: if 'SplineNode' in select: select = select+':splineStartHandleTransform' else: select = select+':module_transform' active_selection.append(select) cmds.select(active_selection, replace=True) cmds.setToolTo('moveSuperContext') else: cmds.select(clear=True)
def updateTreeView(self): cmds.treeView( 'InE_NSMTextScrollList', edit=True, removeAll = True ) self.retrieveListNamespaces(":") for namespace in self.listNamespace: if ":" in namespace: cmds.treeView( 'InE_NSMTextScrollList', e=True, addItem = (namespace, ":".join(namespace.split(":")[0:-1]) )) else: cmds.treeView( 'InE_NSMTextScrollList', e=True, addItem = (namespace, ""))
def doSetItems(self,newItems): if self.__selectionChanging: raise Exception("cannot change items while selection is changing") if self.__itemNameChanging: # raise Exception("cannot change items while item name is changing") # silently exit: should be no harm ignoring new items as the only thing that changed # is label name, and we already reflect that in UI return self.selectedID = None self.selectedItems.clear() #cmds.treeView(self.control,e=True,clearSelection=True) cmds.treeView(self.control,e=True,removeAll=True) for i in newItems: cmds.treeView(self.control,e=True,addItem=(i.id,'')) cmds.treeView(self.control,e=True,displayLabel=(i.id,i.displayName),displayLabelSuffix=(i.id,i.suffix))
import maya.cmds as cmds from maya import cmds window = cmds.window() layout = cmds.formLayout() control = cmds.treeView( parent = layout, numberOfButtons = 3, abr = False ) def cool(itemstring, state): cmds.treeView( control, e=True,buttonStyle=(itemstring,1,'2StateButton')) if state == '1': mode = 'buttonDown' else: mode = 'buttonUp' cmds.treeView( control, e=True,buttonState=(itemstring,1,mode)) print "%s on %s" % (mode, itemstring) def great(itemstring,state): cmds.treeView( control, e=True,selectItem=(itemstring,state)) print "great, selected %s" %itemstring cmds.treeView( control, e=True, pressCommand=(1, cool)) cmds.treeView( control, e=True, selectCommand=great) cmds.formLayout(layout,e=True, attachForm=(control,'top', 2)) cmds.formLayout(layout,e=True, attachForm=(control,'left', 2)) cmds.formLayout(layout,e=True, attachForm=(control,'bottom', 2)) cmds.formLayout(layout,e=True, attachForm=(control,'right', 2)) cmds.showWindow( window ) cmds.treeView( control, e=True, addItem = ("layer 1", "")) cmds.treeView( control, e=True, addItem = ("layer 2", "")) cmds.treeView( control, e=True, addItem = ("layer 3", "")) cmds.treeView( control, e=True, addItem = ("layer 4", "")) cmds.treeView( control, e=True, addItem = ("layer 5", "")) cmds.treeView( control, e=True, addItem = ("layer 6", "")) cmds.treeView( control, e=True, addItem = ("layer 7", "layer 2"))
def buildSetTree(self): setList = self.listDispSets() setTreeName = self.setTreeName setColor = self.setColor warningColor = self.warningColor idx = 1 for node in setList: mc.treeView (setTreeName, e = True, addItem = (node,'')) mc.treeView (setTreeName, e = True, fn = (node,"boldLabelFont"), tc = (node,setColor[0],setColor[1],setColor[2])) memberList = mc.sets(node,q=True) if memberList: for member in memberList: memberExist = mc.treeView(setTreeName, q = True, iex=member) if memberExist == 1: memberAdj = member + ' ('+str(idx+1)+ ')' idx += 1 mc.treeView (setTreeName, e = True, addItem = (memberAdj,node)) mc.treeView (setTreeName, e = True, tc = (memberAdj,warningColor[0],warningColor[1],warningColor[2])) else: mc.treeView (setTreeName, e = True, addItem = (member,node))
def great(itemstring,state): cmds.treeView( control, e=True,selectItem=(itemstring,state)) print "great, selected %s" %itemstring
def treeViewButton_1_Action(item, state): cmds.lockNode(item+':module_container', lock=False, lockUnpublished=False) if state == '0': cmds.setAttr(item+':moduleGrp.visibility', 0) if cmds.objExists(item+':proxyGeometryGrp'): cmds.setAttr(item+':proxyGeometryGrp.visibility', 0) cmds.treeView('__MRT_treeView_SceneModulesUI', edit=True, buttonState=[item, 2, 'buttonUp']) cmds.treeView('__MRT_treeView_SceneModulesUI', edit=True, buttonTransparencyColor=[item, 2, 0.65, 0.71, 0.90]) cmds.treeView('__MRT_treeView_SceneModulesUI', edit=True, buttonTransparencyColor=[item, 1, 0.71, 0.66, 0.56]) if state == '1': cmds.setAttr(item+':moduleGrp.visibility', 1) if cmds.objExists(item+':proxyGeometryGrp'): cmds.setAttr(item+':proxyGeometryGrp.visibility', 1) cmds.treeView('__MRT_treeView_SceneModulesUI', edit=True, buttonState=[item, 2, 'buttonDown']) cmds.treeView('__MRT_treeView_SceneModulesUI', edit=True, buttonTransparencyColor=[item, 2, 0.57, 0.66, 1.0]) cmds.treeView('__MRT_treeView_SceneModulesUI', edit=True, buttonTransparencyColor=[item, 1, 0.85, 0.66, 0.27]) cmds.lockNode(item+':module_container', lock=True, lockUnpublished=True)
selectedItemID = cmds.textScrollList( UI_Widgets['LayersList'], query=True, selectIndexedItem = True)[0] currentLayer = layers[selectedItemID - 1] cmds.textField(UI_Widgets['LayerNameInput'], edit=True, text=currentLayer.name) cmds.textField(UI_Widgets['MinHeightInput'], edit=True, text=currentLayer.minHeight) cmds.textField(UI_Widgets['MaxHeightInput'], edit=True, text=currentLayer.maxHeight) for i in range(cmds.optionMenu(UI_Widgets['InterpType'], q=True, numberOfItems=True)): cmds.optionMenu(UI_Widgets['InterpType'], e=True, numberOfItems=True) print def generateTerrain(): print "Generating terrain..." cmds.intSlider(UI_Widgets['FeatureSizeSlider'], query=True, v=True) if 'window' in globals(): if (cmds.window(window, exists=True)): cmds.deleteUI(window) cmds.treeView(UI_Widgets['LayersList'], e=True, removeAll=True) window = cmds.loadUI(uiFile="/home/i7245143/maya/2014-x64/resources/terrain_gui.ui") cmds.textScrollList(UI_Widgets['LayersList'], e=True, selectCommand = layerSelectionChanged) cmds.showWindow(window)
def rebuildSetTree(self,*args): setTreeName = self.setTreeName mc.treeView(setTreeName, e = True, ra = True) self.buildSetTree()
def buildSetTree(self): setList = self.listLgtGrpSets() setTreeName = self.setTreeName setColorList = self.setColorList warningColor = self.warningColor newSetList = [] newColorDict = {} for i in range(1,self.lightGroupNum+1): if self.lgtGrpSetPrefix + str(i) in setList: newSetList.append(self.lgtGrpSetPrefix + str(i)) colorNum = (i-1) - ((i-1)/10)*10 newColorDict.update({self.lgtGrpSetPrefix + str(i) : setColorList[colorNum]}) idx = 1 for node in newSetList: setColor = newColorDict[node] mc.treeView (setTreeName, e = True, addItem = (node,'')) mc.treeView (setTreeName, e = True, fn = (node,"boldLabelFont"), tc = (node,setColor[0],setColor[1],setColor[2])) memberList = mc.sets(node,q=True) if memberList: for member in memberList: memberExist = mc.treeView(setTreeName, q = True, iex=member) if memberExist == 1: memberAdj = member + ' ('+str(idx+1)+ ')' idx += 1 mc.treeView (setTreeName, e = True, addItem = (memberAdj,node)) mc.treeView (setTreeName, e = True, tc = (memberAdj,warningColor[0],warningColor[1],warningColor[2])) else: mc.treeView (setTreeName, e = True, addItem = (member,node))
def buildSetTree(self): setList = self.listIdSets() setTreeName = self.setTreeName idSetDict = self.buildIdSetDict() setColorList = self.setColorList warningColor = self.warningColor newSetList = [] newColorDict = {} for i in range(1,self.idGroupNum*3+1): if idSetDict['id_'+str(i)] in setList: newSetList.append(idSetDict['id_'+str(i)]) colorNum = (i-1)/3 - ((i-1)/3/10)*10 newColorDict.update({idSetDict['id_'+str(i)] : setColorList[colorNum]}) idx = 1 for node in newSetList: setColor = newColorDict[node] mc.treeView (setTreeName, e = True, addItem = (node,'')) mc.treeView (setTreeName, e = True, fn = (node,"boldLabelFont"), tc = (node,setColor[0],setColor[1],setColor[2])) memberList = mc.sets(node,q=True) if memberList: for member in memberList: memberExist = mc.treeView(setTreeName, q = True, iex=member) if memberExist == 1: memberAdj = member + ' ('+str(idx+1)+ ')' idx += 1 mc.treeView (setTreeName, e = True, addItem = (memberAdj,node)) mc.treeView (setTreeName, e = True, dl = (memberAdj, member), tc = (memberAdj,warningColor[0],warningColor[1],warningColor[2])) else: mc.treeView (setTreeName, e = True, addItem = (member,node))