def scrollField(self, executeField=0): # John Scrollfield if self.currentField == None: self.currentField = cmds.cmdScrollFieldExecuter( t = self.readFile( self.filePath ), opc=1, sln=1, exa=executeField, sourceType="python") else: cmds.cmdScrollFieldExecuter( self.currentField, e=True, t=self.readFile( self.filePath ), opc=1, sln=1, exa=executeField, sourceType="python")
def settingsGUI(curParent): frame = cmds.frameLayout(label="Menu Settings", w=450, la="center", parent=curParent) frm = cmds.formLayout() global rbSettings rbSettings = cmds.radioButtonGrp( nrb=2, labelArray2=["Python", "MEL"], sl=1, label="Language Type:", cw=[[1, 100], [2, 75], [3, 50]], w=250 ) global scrollGui scrollGui = cmds.cmdScrollFieldExecuter(width=450, height=200, sourceType="python") btnExeAll = cmds.button( label="Execute All", w=190, command=(lambda x: cmds.cmdScrollFieldExecuter(scrollGui, e=1, executeAll=1)) ) btnExeSel = cmds.button( label="Execute Selected", w=190, command=(lambda x: cmds.cmdScrollFieldExecuter(scrollGui, e=1, execute=1)) ) cmds.formLayout(frm, e=1, af=[[rbSettings, "left", 50], [rbSettings, "top", 0]]) cmds.formLayout( frm, e=1, af=[[scrollGui, "left", 3], [scrollGui, "right", 3]], ac=[scrollGui, "top", 0, rbSettings] ) cmds.formLayout(frm, e=1, af=[btnExeAll, "left", 50], ac=[btnExeAll, "top", 5, scrollGui]) cmds.formLayout(frm, e=1, ac=[[btnExeSel, "top", 5, scrollGui], [btnExeSel, "left", 10, btnExeAll]]) cmds.setParent(curParent) return frame
def _script_editor_save_to_project(*xargs): """Execute save to project.""" del xargs # Maya callbacks require args # Get current editor _cur_editor = [ _ui for _ui in cmds.lsUI(dumpWidgets=True, long=False) if cmds.cmdScrollFieldExecuter(_ui, query=True, exists=True) and not cmds.cmdScrollFieldExecuter(_ui, query=True, isObscured=True) ][0] # Get file path _src_type = cmds.cmdScrollFieldExecuter(_cur_editor, query=True, sourceType=True) _extn = {'mel': 'mel', 'python': 'py'}[_src_type] _text = cmds.cmdScrollFieldExecuter(_cur_editor, query=True, text=True) _file = get_single( cmds.fileDialog2( fileMode=0, # Single file doesn't need to exist caption="Save Script", okCaption='Save', startingDirectory=pipe.cur_project().maya_scripts_path, fileFilter='{} Files (*.{})'.format(_extn.upper(), _extn)), catch=True) # Write file to disk if _file: write_file(file_=_file, text=_text)
def setStringArea(self, elem, val): """ Set the current String area value of the string input elem @type elem: dictionary @param elem: the elem input dictionary @type val: string @param val: the new string value (multiline) """ cmds.cmdScrollFieldExecuter(elem["id"], e=1, tx=val)
def setStringArea(self,elem,val): """ Set the current String area value of the string input elem @type elem: dictionary @param elem: the elem input dictionary @type val: string @param val: the new string value (multiline) """ cmds.cmdScrollFieldExecuter(elem["id"],e=1,tx=val)
def syncSettings(self, **kwargs): _syncEditorOpt(kwargs, 'sln', 'showLineNumbers', 'commandExecuterShowLineNumbers') #_syncEditorOpt(kwargs, 'cco', 'commandCompletion', 'commandExecuterCommandCompletion') #_syncEditorOpt(kwargs, 'opc', 'objectPathCompletion', 'commandExecuterPathCompletion') #_syncEditorOpt(kwargs, 'sth', 'showTooltipHelp', 'commandExecuterToolTipHelp') _syncEditorOpt(kwargs, 'tfi', 'tabsForIndent', 'commandExecuterTabsForIndent') #_syncEditorOpt(kwargs, 'acb', 'autoCloseBraces', 'commandExecuterAutoCloseBraces') _syncEditorOpt(kwargs, 'spt', 'spacesPerTab', 'commandExecuterSpacesPerTab') cmds.cmdScrollFieldExecuter(self.mayaEditor, e=True, **kwargs)
def eventFilter(self, obj, event): if event == QtGui.QKeySequence.Paste and event.type() == QtCore.QEvent.KeyPress: if isinstance(obj, QtGui.QTextEdit): if obj.objectName().startswith('cmdScrollFieldExecuter'): #Paste clipboard text this way, more reliable than Maya's check. maya_widget = qt.widgetToPath(obj) cmds.cmdScrollFieldExecuter(maya_widget, e=True, it=QtGui.qApp.clipboard().text()) return True return False
def scriptWindow( document ): win = cmds.window( title='Code Reference - Python Script Editor ', wh=(700,300)) cmds.frameLayout(labelVisible=False, borderVisible=False) # ----------------------------------------------- cmds.cmdScrollFieldExecuter( sourceType="python", text=document ) # ----------------------------------------------- cmds.showWindow(win)
def __scriptEditorExecute(): executer = mel.eval("$temp = $gLastFocusedCommandExecuter") selected_text = cmds.cmdScrollFieldExecuter(executer,q=1,selectedText=1) if selected_text: exec(selected_text) else: text = cmds.cmdScrollFieldExecuter(executer,q=1,text=1) cmds.cmdScrollFieldExecuter(executer,e=1,clear=1) exec(text)
def script_execute(code, source_type): ''' Execute the script within maya :param code: string :param source_type: 'mel' or 'python' :return: ''' window = cmds.window() cmds.columnLayout() cmds.cmdScrollFieldExecuter(t=code, opc=1, sln=1, exa=1, sourceType=source_type) cmds.deleteUI(window)
def settingsGUI(curParent): frame = cmds.frameLayout(label="Menu Settings", w=450, la="center", parent=curParent) frm = cmds.formLayout() global rbSettings rbSettings = cmds.radioButtonGrp(nrb=2, labelArray2=["Python", "MEL"], sl=1, label="Language Type:", cw=[[1, 100], [2, 75], [3, 50]], w=250) global scrollGui scrollGui = cmds.cmdScrollFieldExecuter(width=450, height=200, sourceType="python") btnExeAll = cmds.button(label="Execute All", w=190, command=(lambda x: cmds.cmdScrollFieldExecuter( scrollGui, e=1, executeAll=1))) btnExeSel = cmds.button( label="Execute Selected", w=190, command=( lambda x: cmds.cmdScrollFieldExecuter(scrollGui, e=1, execute=1))) cmds.formLayout(frm, e=1, af=[[rbSettings, "left", 50], [rbSettings, "top", 0]]) cmds.formLayout(frm, e=1, af=[[scrollGui, "left", 3], [scrollGui, "right", 3]], ac=[scrollGui, "top", 0, rbSettings]) cmds.formLayout(frm, e=1, af=[btnExeAll, "left", 50], ac=[btnExeAll, "top", 5, scrollGui]) cmds.formLayout(frm, e=1, ac=[[btnExeSel, "top", 5, scrollGui], [btnExeSel, "left", 10, btnExeAll]]) cmds.setParent(curParent) return frame
def saveScriptAsFile(_scriptEditorId, *args): scriptSaveName = str(cmds.fileDialog2(fileMode=0)) scriptSaveName = scriptSaveName[3:-2] print(scriptSaveName) scriptFile = open(scriptSaveName, 'w') cmds.cmdScrollFieldExecuter(_scriptEditorId, e=True, sla=True) scriptText = str( cmds.cmdScrollFieldExecuter(_scriptEditorId, q=True, slt=True)) #print(scriptText) #trying to break down the lines in these commented out lines of code #because when i open the file that gets written out to in regular notepad all the text is on one line with no breaks #although when I open it in notepad++ its got seperate lines. newData = scriptText.split('\n') print(newData) #-----------OLD ISSUE THAT IS NOW RESOLVED--------------------- #okay new issue is that as is this loop will write with formatting except for one space per space between written text will be # ommited from the formating, which is wierd because all empty lines should be the same, and not inconsistent like that #probably not efficient but here Im storing the length of the new data from the for loop to be called later with # also storing it so that I can just take 1 off and use it as a var for the index of the final line in the code to be saved #commenting out the print statements until i need them again scriptLineCount = len(newData) scriptLastLine = int(scriptLineCount - 1) #print('the length of the new Data list is:' + str(scriptLineCount)) #print('the correct last line number is:' + str(scriptLastLine)) for i in range(len(newData)): if i == 0: writeLine = (newData[i] + '\r') elif i == (scriptLastLine): #checking if this elif is actually working #print('IT USED THE ELIF STATEMENT!!!!') writeLine = ('\n' + newData[i]) else: writeLine = ('\n' + (newData)[i] + '\r') print('line-' + str(i) + ' :' + writeLine) scriptFile.write(writeLine) #scriptFile.write('\n\r') #scriptFile.write(scriptText) scriptFile.close() return
def highlighterEditorWidget(sourceType, **kwargs): se_repo = toQtObject('cmdScrollFieldReporter1', widgetType=QtWidgets.QTextEdit) tmp = cmds.cmdScrollFieldExecuter(sourceType=sourceType, **kwargs) se_edit = toQtObject(tmp, widgetType=QtWidgets.QTextEdit) se_edit.nativeParentWidget() return se_edit, se_repo
def settingsGUI2(curParent): frm = cmds.formLayout(parent=curParent) txtGUI = cmds.text(label="----Settings----", w=400) global rbSettings rbSettings = cmds.radioButtonGrp(nrb=2, labelArray2=["Python", "MEL"], sl=1, label="Language Type:", cw=[[1, 100], [2, 75], [3, 50]], w=250) global scrollGui scrollGui = cmds.cmdScrollFieldExecuter(width=450, height=200, sourceType="python") cmds.formLayout(frm, e=1, af=[[txtGUI, "top", 5], [txtGUI, "left", 50]]) cmds.formLayout(frm, e=1, af=[rbSettings, "left", 50], ac=[rbSettings, "top", 5, txtGUI]) cmds.formLayout(frm, e=1, af=[scrollGui, "left", 0], ac=[scrollGui, "top", 0, rbSettings]) cmds.setParent(curParent) return frm
def createFromMaya(cls, data, control, controlType): btn = cls() if controlType == 'shelfButton': command = cmds.shelfButton(control, q=True, c=True) annotation = cmds.shelfButton(control, q=True, annotation=True) sType = cmds.shelfButton(control, q=True, sourceType=True) normal = cmds.shelfButton(control, q=True, image=True) over = cmds.shelfButton(control, q=True, highlightImage=True) pressed = cmds.shelfButton(control, q=True, selectionImage=True) normal = util.resolvePath(normal) over = util.resolvePath(over) btn.setIcon(util.makeIcon(normal, over or None)) btn.setText(command) btn.setToolTip(annotation or command) elif controlType == 'cmdScrollFieldExecuter': command = data.text() sType = cmds.cmdScrollFieldExecuter(control, q=True, sourceType=True) btn.setText(command) btn.setToolTip(command) if sType == 'python': btn.setIcon(util.makeIcon(':/pythonFamily.png')) else: btn.setIcon(util.makeIcon(':/commandButton.png')) else: log.warn('Unsuported drag and drop source: %s - %s'%(controlType, control)) return btn
def addScriptWidget(tempWindowName): '''Create a native Maya Script Widget Args: tempWindowName (str): Returns: QWidget ''' if not cmds.window(tempWindowName, q=True, ex=True): cmds.window(tempWindowName) cmds.formLayout("qtLayoutObjects") ptr = mui.MQtUtil.mainWindow() mayaWindow = shiboken2.wrapinstance(long(ptr), QWidget) for ind, el in enumerate(mayaWindow.children()): try: title = el.windowTitle() if title == tempWindowName: break except: continue cmds.setParent(tempWindowName + "|qtLayoutObjects") cmdsScriptEditor = cmds.cmdScrollFieldExecuter( sourceType="python", tabsForIndent=False, showTooltipHelp=False ) #, modificationChangedCommand=self.codeModified) widget = el.children()[-1] widget.show() return widget
def drawStringArea(self, elem, x, y, w=None, h=None): """ Draw a String Area input elem, ie multiline @type elem: dictionary @param elem: the string area input dictionary @type x: int @param x: position on x in the gui windows @type y: int @param y: position on y in the gui windows @type w: int @param w: force the width of the item @type h: int @param h: force the height of the item """ elem["id"] = cmds.cmdScrollFieldExecuter(w=elem["width"] * self.scale, h=elem["height"] * self.scale, sourceType="python") cmds.cmdScrollFieldExecuter(elem["id"], e=1, t=elem["value"])
def testScript(self): scriptText = open(self.codePath, 'r').read() scriptText += "\n\n\n#================Program Debugger================#" tmp = cmds.cmdScrollFieldExecuter(parent='mainNameSpace', text=scriptText.decode('utf-8'), execute=True, sourceType="python") cmds.deleteUI(tmp)
def drawStringArea(self,elem,x,y,w=None,h=None): """ Draw a String Area input elem, ie multiline @type elem: dictionary @param elem: the string area input dictionary @type x: int @param x: position on x in the gui windows @type y: int @param y: position on y in the gui windows @type w: int @param w: force the width of the item @type h: int @param h: force the height of the item """ elem["id"] = cmds.cmdScrollFieldExecuter(w=elem["width"]*self.scale, h=elem["height"]*self.scale, sourceType="python") cmds.cmdScrollFieldExecuter(elem["id"],e=1,t=elem["value"])
def testScript(self, flag=0): if flag == 1: if self.env == "maya.exe": import maya.cmds as cmds name = self.lineEdit_namefile.text() scriptText = self.textEdit_code_edit.toPlainText() type = name.split(".")[-1] if type == 'mel': type = "mel" else: type = 'python' if scriptText: print "Hello World" cmds.window("maya_script_windows") cmds.columnLayout(adjustableColumn=True) cmds.cmdScrollFieldExecuter('scriptTextTest', text=scriptText, execute=True, sourceType=type) cmds.showWindow() cmds.deleteUI('maya_script_windows') else: print self.textEdit_code_edit.toPlainText() elif flag == 2: if self.env == "maya.exe": import maya.cmds as cmds name = self.lineEdit_manage_name.text() scriptText = self.textEdit_code_edit_manage.toPlainText() type = name.split(".")[-1] if type == 'mel': type = "mel" else: type = 'python' if scriptText: cmds.window("maya_script_windows") cmds.columnLayout(adjustableColumn=True) cmds.cmdScrollFieldExecuter('scriptTextTest', text=scriptText, execute=True, sourceType=type) cmds.showWindow() cmds.deleteUI('maya_script_windows') else: print self.textEdit_code_edit_manage.toPlainText() else: pass
def w00_fun_executerAllButton(): tabNum = cmds.tabLayout('w00_02_tabLayout', q=True, sti=True) if tabNum == 1: cmds.cmdScrollFieldExecuter('w00_03_pythonWin', e=True, executeAll=True) cmds.cmdScrollFieldExecuter('w00_03_pythonWin', e=True, clear=True) elif tabNum == 2: cmds.cmdScrollFieldExecuter('w00_04_melWin', e=True, executeAll=True) cmds.cmdScrollFieldExecuter('w00_04_melWin', e=True, clear=True)
def getStringArea(self, elem): """ Return the current string area value of the String area Input elem @type elem: dictionary @param elem: the elem input dictionary @rtype: string @return: the current string area input value for this specific elem """ return cmds.cmdScrollFieldExecuter(elem["id"], q=1, t=1)
def getStringArea(self,elem): """ Return the current string area value of the String area Input elem @type elem: dictionary @param elem: the elem input dictionary @rtype: string @return: the current string area input value for this specific elem """ return cmds.cmdScrollFieldExecuter(elem["id"],q=1,t=1)
def __keyPress(self, mod, key): if key == 'Enter' or (key == 'Return' and mod & 4): # スクリプト実行を無効にする。 cmds.cmdScrollFieldExecuter(self.mayaEditor, e=True, it='\n') return 1 if key == '\x06': # 標準サーチウィンドウが利用可能ならそれを開く。 if _getCurrentExecuterControl: global _SEARCH_WINDOW_OWNER _SEARCH_WINDOW_OWNER = self.mayaEditor if cmds.window(_SEARCH_WINDOW_NAME, ex=True): mel.eval('createSearchAndReplaceWindow') else: mel.eval('createSearchAndReplaceWindow') if cmds.window(_SEARCH_WINDOW_NAME, ex=True): cmds.scriptJob(uid=(_SEARCH_WINDOW_NAME, _customSearchDone)) else: _SEARCH_WINDOW_OWNER = None return 1
def testScript2(self): codeName = cmds.textField('showTextName', text=True, q=True) codeType = codeName.split('.')[-1] if codeType == 'py': self.codeType = 'python' elif codeType == 'mel': self.codeType = 'mel' else: pass scriptText = cmds.scrollField('showText', q=True, text=True) if scriptText == 'Copy your code and paste here' or scriptText == '': pass else: cmds.cmdScrollFieldExecuter('scriptTextTest2', parent='tabsNameSpace', text=scriptText, execute=True, sourceType=self.codeType) cmds.deleteUI('scriptTextTest2')
def eventFilter(self, wd, event): if event.type() == QtCore.QEvent.FocusOut: # and wd == self.editor: txt = cmds.cmdScrollFieldExecuter(self.mayaEditor, q=True, t=True) if txt != self.__txt: self.__txt = txt cmds.undoInfo(ock=True) try: self.__textChangeHandler(txt) finally: cmds.undoInfo(cck=True) return super(ScriptEditorWidget, self).eventFilter(wd, event)
def scriptEditorExecuteAll(f_globals=None): import mpdb globals().update(mpdb.f_globals) locals().update(mpdb.f_locals) if f_globals: globals().update(f_globals) executer = mel.eval("$temp = $gLastFocusedCommandExecuter") text = cmds.cmdScrollFieldExecuter(executer,q=1,text=1) reporterSetText(text) # NOTE __name__ == "__main__" 改为判断 __name__ == "mpdb" text = re.sub(r"__name__ == [\',\"]__main__[\',\"]","__name__ == 'mpdb'",text.strip()) source = cmds.cmdScrollFieldExecuter(executer,q=1,sourceType=1) if source == "python": exec text in mpdb.f_globals, mpdb.f_locals elif source == "mel": mel.eval(text)
def testScript(self): codeName = cmds.textField('codeName', text=True, q=True) codeType = codeName.split('.')[-1] if codeType == 'py': self.codeType = 'python' elif codeType == 'mel': self.codeType = 'mel' else: pass scriptText = cmds.scrollField('copyText', q=True, text=True) if scriptText == 'Copy your code and paste here' or scriptText == '': return else: cmds.cmdScrollFieldExecuter('scriptTextTest', parent='mainLayout', text=scriptText, execute=True, sourceType=self.codeType) #~ cmds.deleteUI('scriptTextTest') cmds.deleteUI('scriptTextTest')
def m2nShowText(*args): window = "help" if cmds.window(window, ex=1): cmds.deleteUI(window) cmds.window(window) mianLayout = cmds.formLayout(nd=1000) control1 = cmds.scrollField() cmds.formLayout(mianLayout, e=1, attachPosition=[(control1, "left", 0, 0), (control1, "right", 0, 1000), (control1, "top", 0, 0), (control1, "bottom", 0, 1000)]) cmds.window(window, e=1, t="Nuke Script", widthHeight=(500, 500)) cmds.showWindow(window) text = cmds.cmdScrollFieldExecuter('copytext', q=1, t=1) if args[0] == "help": text = r'''maya2nuke v2.0.1 Now! Geometry can be exported. Usage is as simple as ever. Features: Export Geometry Export Camera Auto Export texture Animation switch Save as ". Nk" file Improved interface Smart Filter Workflow: 1. Copy maya2nuke.py to "My Documents\maya\20XX\scripts" 2. In python command port.Type "from maya2nuke import *". Open maya2nuke UI. 3. In Type menu. Select export type. Camera, mesh or all. 4. In Animation menu. Select animation type. Camera, mesh or all. 5. in Networks menu.Choose nuke networks type. None: Only the original node Base: Build basic 3d scene ContactSheet: Contact camera 6. Select the object you want to export. 8. Click Generator Button. 9. into nuke press ctr + v. Note: When the maya scene is changed. You need to update maya2nuke data. Click "edit / Calculate Maya Data". You can view and save nukeScript. Click "edit / Show Nuke Script", "edit / Save Nuke Script As". Good luck. 2010.6.17''' cmds.window(window, e=1, t="Help") cmds.scrollField(control1, e=1, tx=text)
def _getCurrentExecuterControl(): global _SEARCH_WINDOW_OWNER if _SEARCH_WINDOW_OWNER: if cmds.cmdScrollFieldExecuter(_SEARCH_WINDOW_OWNER, ex=True): return _SEARCH_WINDOW_OWNER _SEARCH_WINDOW_OWNER = None try: layout = mel.eval('$gCommandExecuterTabs=$gCommandExecuterTabs') except: return '' tabs = cmds.tabLayout(layout, q=True, ca=True) i = cmds.tabLayout(layout, q=True, selectTabIndex=True) - 1 return cmds.layout(tabs[i], q=True, ca=True)[0]
def saveNukeScript(*args): text = cmds.cmdScrollFieldExecuter('copytext', q=1, t=1) if not text: cmds.confirmDialog(title='Save Nuke Script', message='Nothing script to be saved!', button=['Ok']) return fileName = cmds.fileDialog(m=1, t='Save Nuke Script As', dm='.nk', dfn='maya2nuke.nk') f = file(fileName, 'w') f.write(text) f.close()
def newScriptEditor(): """ simpler script editor test """ win = cmds.window(t='New Script Editor', menuBar= True, w = 650, h = 300) form = cmds.formLayout() pane = cmds.paneLayout(configuration='horizontal2', paneSize=[[1,100,40],[2,100,60]]) # top layout formTop = cmds.formLayout() reporter = cmds.cmdScrollFieldReporter('reporter') cmds.setParent('..') cmds.formLayout(formTop, e=True, attachForm=\ [ (reporter, "top", 5), (reporter, "bottom", 5), (reporter, "left", 5), (reporter, "right", 5), ] ) cmds.paneLayout(pane, edit=True, setPane = [formTop, 2]) # bottom layout formBottom = cmds.formLayout() shelf = cmds.shelfTabLayout() tab1 = cmds.cmdScrollFieldExecuter('python1', sourceType="python") cmds.setParent('..') cmds.formLayout(formBottom, e=True, attachForm=\ [ (shelf, "top", 5), (shelf, "bottom", 5), (shelf, "left", 5), (shelf, "right", 5), ] ) cmds.paneLayout(pane, edit=True, setPane = [formTop, 1]) cmds.formLayout(form, e=True, attachForm=\ [ (pane, "top", 5), (pane, "bottom", 5), (pane, "left", 5), (pane, "right", 5), ] ) cmds.showWindow()
def scriptEditorExecute(f_globals=None,clear=True): import mpdb globals().update(mpdb.f_globals) locals().update(mpdb.f_locals) if f_globals: globals().update(f_globals) executer = mel.eval("$temp = $gLastFocusedCommandExecuter") selected_text = cmds.cmdScrollFieldExecuter(executer,q=1,selectedText=1) if selected_text: text = selected_text else: text = cmds.cmdScrollFieldExecuter(executer,q=1,text=1) if clear: cmds.cmdScrollFieldExecuter(executer,e=1,clear=1) reporterSetText(text) # NOTE __name__ == "__main__" 改为判断 __name__ == "mpdb" pattern = r"__name__\s*==\s*[\',\"]__main__[\',\"]" text = re.sub(pattern,"__name__ == 'mpdb'",text.strip()) source = cmds.cmdScrollFieldExecuter(executer,q=1,sourceType=1) if source == "python": if "\n" in text: exec text in mpdb.f_globals, mpdb.f_locals else: try: exec("import pprint;pprint.pprint(%s)" % text) except: exec text in mpdb.f_globals, mpdb.f_locals elif source == "mel": mel.eval(text)
def w00_fun_executerSelButton(): tabNum = cmds.tabLayout('w00_02_tabLayout', q=True, sti=True) if tabNum == 1: if cmds.cmdScrollFieldExecuter('w00_03_pythonWin', q=True, hsl=True): cmds.cmdScrollFieldExecuter('w00_03_pythonWin', e=True, execute=True) elif tabNum == 2: if cmds.cmdScrollFieldExecuter('w00_04_melWin', q=True, hsl=True): cmds.cmdScrollFieldExecuter('w00_04_melWin', e=True, execute=True)
def generator(*args): nuke = CNuke() m2nType = cmds.optionVar(q='m2nType') if m2nType == 0: m2nType = [] m2nAnim = cmds.optionVar(q='m2nAnim') if m2nAnim == 0: m2nAnim = [] m2nNet = cmds.optionVar(q='m2nNet') if m2nNet == 0: m2nNet = 'None' nuke.setOption({'type': m2nType, 'anim': m2nAnim, 'net': m2nNet}) nuke.setObj() nuke.generator() cmds.cmdScrollFieldExecuter('copytext', e=1, clr=1) cmds.cmdScrollFieldExecuter('copytext', e=1, t=nuke.nukeFile) cmds.cmdScrollFieldExecuter('copytext', e=1, selectAll=1) cmds.cmdScrollFieldExecuter('copytext', e=1, copySelection=1) msg = '''Succeed!\nTo Nuke and press ctr+v.''' cmds.confirmDialog(title='maya2nuke', message=msg, button=['OK'])
def settingsGUI2(curParent): frm = cmds.formLayout(parent=curParent) txtGUI = cmds.text(label="----Settings----", w=400) global rbSettings rbSettings = cmds.radioButtonGrp( nrb=2, labelArray2=["Python", "MEL"], sl=1, label="Language Type:", cw=[[1, 100], [2, 75], [3, 50]], w=250 ) global scrollGui scrollGui = cmds.cmdScrollFieldExecuter(width=450, height=200, sourceType="python") cmds.formLayout(frm, e=1, af=[[txtGUI, "top", 5], [txtGUI, "left", 50]]) cmds.formLayout(frm, e=1, af=[rbSettings, "left", 50], ac=[rbSettings, "top", 5, txtGUI]) cmds.formLayout(frm, e=1, af=[scrollGui, "left", 0], ac=[scrollGui, "top", 0, rbSettings]) cmds.setParent(curParent) return frm
def getScriptEditorSelection(): ''' this is a hack to bypass an issue with getting the data back from the ScriptEditorHistory scroll. We need to copy the selected text to the clipboard then pull it back afterwards. ''' import Red9.packages.pyperclip as pyperclip control = mel.eval("$v=$gLastFocusedCommandControl") executer = mel.eval("$v=$gLastFocusedCommandExecuter") reporter = mel.eval("$v=$gLastFocusedCommandReporter") func = "" if control == executer: func = cmds.cmdScrollFieldExecuter(control, q=True, selectedText=True) elif control == reporter: cmds.cmdScrollFieldReporter(reporter, e=True, copySelection=True) #func=Clipboard.getText() #pyperclip.py : IN TESTING : Platform independant clipboard support func = pyperclip.paste() log.info('command caught: %s ' % func) return func
def getScriptEditorSelection(): ''' this is a hack to bypass an issue with getting the data back from the ScriptEditorHistory scroll. We need to copy the selected text to the clipboard then pull it back afterwards. ''' import Red9.packages.pyperclip as pyperclip control=mel.eval("$v=$gLastFocusedCommandControl") executer=mel.eval("$v=$gLastFocusedCommandExecuter") reporter=mel.eval("$v=$gLastFocusedCommandReporter") func="" if control==executer: func=cmds.cmdScrollFieldExecuter(control, q=True, selectedText=True) elif control == reporter: cmds.cmdScrollFieldReporter(reporter, e=True, copySelection=True) #func=Clipboard.getText() #pyperclip.py : IN TESTING : Platform independant clipboard support func=pyperclip.paste() log.info('command caught: %s ' % func) return func
def __init__(self, name='scriptEditor', parent=None, textChangeHandler=None, **kwargs): super(ScriptEditorWidget, self).__init__(parent) self.setObjectName(name) self.__layout = QtWidgets.QVBoxLayout(self) self.__layout.setContentsMargins(0,0,0,0) self.mayaEditor = cmds.cmdScrollFieldExecuter( st='python', searchWraps=True, filterKeyPress=self.__keyPress, cco=False, opc=False, sth=False, # acb=False, **kwargs) self.__txt = '' p = MQtUtil.findControl(self.mayaEditor) self.editor = p and wrapInstance(long(p), QtWidgets.QTextEdit) if self.editor: self.editor.setParent(self) if textChangeHandler: self.__textChangeHandler = textChangeHandler self.editor.installEventFilter(self) #self.editor.textChanged.connect(self.__textChanged) self.__layout.addWidget(self.editor)
def get_exec_type(self): gCommandExecuterTabs= get_mel_global('$gCommandExecuterTabs') tabIdx = mc.tabLayout(gCommandExecuterTabs, q=1, st=1) cmd_executer = mc.layout(tabIdx,q=1,ca=1)[0] return mc.cmdScrollFieldExecuter(cmd_executer,q=1,st=1)