def nodesInTabs_fix(self, nodes, func_name, func_name_fix): fixed = 0 panels = cmds.getPanel(sty='nodeEditorPanel') for mypanel in panels: #Open window cmds.scriptedPanel(mypanel, e=True, to=True) ned = mypanel + 'NodeEditorEd' #Close all tabs cmds.nodeEditor(ned, e=True, closeAllTabs=True) #Close window control = cmds.control(ned, query=True, fullPathName=True) cmds.deleteUI(control.split('|')[0], window=True) fixed = 1 cmds.refresh() if fixed == 1: #Output message and restore state buttons self.reportOutputUI.insertHtml( '<br> Cleaned all nodes in Node Editor! <font color=#3da94d> [ SUCCESS ] <br>' ) restoreStateButtons(self, func_name) else: self.reportOutputUI.insertHtml( 'Error cleaning nodes in Node Editor <font color=#9c4f4f> [ FAILED ] <br>' )
def _onReplace(self, *args): # replace the selected bookmark txt = cmds.textScrollList(self._tsl, q=True, si=True) if txt and len(txt): txt = txt[0] info = self._findInfo(txt) cmds.nodeEditor(self._ed, e=True, createInfo=info) self.reset()
def addNodes(self, nodes): """Adds a list of nodes to the current node editor :param nodes: a list of maya mobject representing valid nodes :type nodes: list(:class:`om2.MObject`) """ for n in nodes: cmds.nodeEditor(self.objectName(), addNode=apiNodes.nameFromMObject(n))
def loadBookmark(ned, info, *args): """ apply the supplied bookmark """ name = _getDescriptionForInfo(info) # restore the info, clear the existing hud message and set the bookmark name # as the hud message for 3 seconds. cmds.nodeEditor(ned, e=True, hudMessage=("", 0, 0), restoreInfo=info) cmds.nodeEditor(ned, e=True, hudMessage=(name, 0, 3.0)) _panelInfos[ned] = info inst = _getInstance() if inst: inst.selectLastLoadedInfo()
def createBookmark(ned, *args): """ create a new bookmark """ n0 = set(cmds.ls(type='nodeGraphEditorBookmarkInfo')) cmds.nodeEditor(ned, e=True, createInfo='nodeView#') n1 = set(cmds.ls(type='nodeGraphEditorBookmarkInfo')) # find the new nodeGraphEditorBookmarkInfo and set its name attr newInfos = n1 - n0 if len(newInfos): newInfo = newInfos.pop() name = _getBookmarkName(newInfo) if name: cmds.setAttr(newInfo + '.name', name, type='string') _refreshWindow() else: # user cancelled, delete the new info _deleteBookmarks([newInfo])
def getPrimaryNodeEditor(): """Find and return the name of the primary node editor if it exists. :return: The node editor name :rtype: str """ allNEs = cmds.getPanel(scriptType="nodeEditorPanel") for oneNE in allNEs: ned = oneNE + "NodeEditorEd" if cmds.nodeEditor(ned, query=True, primary=True): return ned return ""
def exists(self): objName = self.objectName() if objName: return cmds.nodeEditor(objName, exists=True) return False