def run(self, clear_script_editor=True, new_scene=True): if clear_script_editor is True: try: cmds.cmdScrollFieldReporter( mel.eval('string $tmp = $gCommandReporter;'), e=True, clear=True) except: pass if new_scene is True: self.steps.insert(0, setup_new_scene) start_build = time.time() info('Build starts', prefix=self.__class__.__name__, new_line_after=True) steps_names = '{0} > {1}'.format( 'Registered steps in order ({0})'.format(len(self.steps)), ', '.join([step.__name__ for step in self.steps])) info(steps_names, prefix=self.__class__.__name__, new_line_after=True) for step in self: start = time.time() info('Step \'{0}\' starts'.format(step.__name__), prefix=self.__class__.__name__) step() info('Step \'{0}\' ends'.format(step.__name__), prefix=self.__class__.__name__, suffix='Took {0} sec.'.format(time.time() - start), new_line_after=True) info('Build ends', prefix=self.__class__.__name__, suffix='Took {0} sec.'.format(time.time() - start_build), new_line_after=True)
def run(*args, **kwargs): """ prepare the scene for the tests converts scene to use centimeters set the grid to the default """ valid_kwargs = ['verbose'] for k, v in kwargs.iteritems(): if k not in valid_kwargs: raise TypeError("Invalid keyword argument %s" % k) # verbose defaults to False if verbose option not set in menu or set # as cmdline argument try: verbose = kwargs['verbose'] except KeyError: verbose = False if cmds.optionVar(exists='checkmateVerbosity'): verbose = cmds.optionVar(query='checkmateVerbosity') else: verbose = False batch = cmds.about(batch=True) # get the name of the script Editor's output control from maya import mel as mel # Turn off Echo All Commands in the Script Editor # Disable Stack Tracevin the Script Editor # Turn off Line Numbers in errors in the Script Editor # Reset the grid # Set the background color # Turn off the heads-up displays # Switch to wrireframe mode # Close all windows (except main) # Close ChannelBox, Attribute Editor and Outliner () if not batch: try: gCommandReporter = mel.eval("proc string f(string $g){return $g;}f($gCommandReporter);") except RuntimeError: gCommandReporter = '' pass try: cmds.cmdScrollFieldReporter(gCommandReporter, edit=True, echoAllCommands=False, lineNumbers=True, stackTrace=True, suppressResults=False, suppressInfo=False, suppressWarnings=False, suppressErrors=False, suppressStackTrace=False, ) except RuntimeError: if verbose: print 'No Script Editor' pass # convert scene to cm to fix crashes in nearestnormal cmds.currentUnit(linear='cm')
def trackingCommand(*args): if cmds.window('Command detect', query=True, exists=True): cmds.deleteUI('Command detect') cmds.window('Command detect') cmds.columnLayout() cmds.cmdScrollFieldReporter(width=400, height=100) cmds.showWindow('Command detect')
def copyTexturesToProject(object): texlistN = cmds.ls(type='RedshiftNormalMap') texlist = cmds.ls(type='file') textdestination = cmds.workspace(query=True, fullName=True) + "/" + 'sourceimages' textdestinationN = cmds.workspace(query=True, fullName=True) + "/" + 'sourceimages' si = 'sourceimages' window = cmds.window(title="SLiB | INFO:", iconName='Short Name', widthHeight=(400, 330), mxb=False, s=False) mc.columnLayout() progressControl = mc.progressBar(maxValue=100, width=400, height=40) cmds.cmdScrollFieldReporter(width=400, height=258, clear=True) cmds.button(label='CLOSE', width=400, height=30, command=('cmds.deleteUI(\"' + window + '\", window=True)')) cmds.setParent('..') cmds.showWindow(window) for i in texlist: fileName = cmds.getAttr("%s.fileTextureName" % i) finalName = fileName.split("/")[-1] finalPath = textdestination + "/" + finalName if si in fileName: pass else: shutil.copy(fileName, textdestination) cmds.setAttr("%s.fileTextureName" % i, finalPath, type="string") print 'copying: >>>' + ' ' + i for n in texlistN: fileNameN = cmds.getAttr("%s.tex0" % n) finalNameN = fileNameN.split("/")[-1] finalPathN = textdestination + "/" + finalNameN if si in fileNameN: pass else: shutil.copy(fileNameN, textdestinationN) cmds.setAttr("%s.tex0" % n, finalPathN, type="string") print 'copying: >>>' + ' ' + n for r in range(0, 100): progressInc = mc.progressBar(progressControl, edit=True, pr=r + 1) time.sleep(0.02) print '\nDONE! \n\nNew Texture Path set to:\n\n' + textdestination #copyTexturesToProject(object)
def pOpenFileCallback(*pArgs): mc.cmdScrollFieldReporter("outputField", e=True, clear=True) fileOutput = mc.fileDialog2(fileMode=1) fileContent = fileOutput[0] mm.eval('string $filePath = "' + str(fileContent) + '"') mm.eval('$fileId = `fopen $filePath "r"`') mm.eval("string $data = `fread $fileId $data`") transferMELVar = maya.mel.eval("$temp=$data") print transferMELVar test = str(transferMELVar)
def UI(): rlmAttrs() images=os.path.join(mc.workspace(q=1,rd=1),"images",mc.getAttr("renderLayerManager.shotName")) if (mc.window('rcFileManage',exists=True)): mc.deleteUI('rcFileManage') mc.window('rcFileManage', mxb=0,title=' ',tlb=False,) ###Main mc.columnLayout('renderLayers2Files')#,bgc=[0.2,0.2,0.2] mc.image(image=iconPath+'toptitle.png') mc.cmdScrollFieldReporter(clr=1,hf=0,w=700,h=80,bgc=[0,0,0]) print '//rc.Tools' mc.setParent('..') mc.rowColumnLayout(numberOfColumns=3,columnWidth=[(1,row1),(2,row2),(3,480)]) mc.text(al='right',font=ui.titleFont,label=' Image Prefix: ') mc.menuBarLayout() mc.menu(label='Shot Name/') mc.menuItem(label='<RenderLayer>/<RenderLayer>',c=partial(runMethod,'set.imagePrefix','("S__L__L")')) mc.menuItem(label='<RenderLayer>/<RenderLayer>.<RenderPass>',c=partial(runMethod,'set.imagePrefix','("S__L__L.P")')) mc.menuItem(label='<RenderLayer>/<RenderPass>/<RenderLayer>.<RenderPass>',c=partial(runMethod,'set.imagePrefix','("S__L__P__L.P")')) mc.menu(label='...') mc.menuItem(label='<RenderLayer>/<RenderLayer>',c=partial(runMethod,'set.imagePrefix','("L__L")')) mc.menuItem(label='<RenderLayer>/<RenderLayer>.<RenderPass>',c=partial(runMethod,'set.imagePrefix','("L__L.P")')) mc.menuItem(label='<RenderLayer>/<RenderPass>/<RenderLayer>.<RenderPass>',c=partial(runMethod,'set.imagePrefix','("L__P__L.P")')) mc.setParent('..') mc.textField('imageFilePrefix',font=ui.fieldFont,en=1,text=mc.getAttr('defaultRenderGlobals.imageFilePrefix')) mc.setParent('..') mc.setParent('..') ###ListsUI mc.rowColumnLayout('listLayout',numberOfColumns=3,columnWidth=[(1,102),(2,browselistWidth), (3, targetlistWidth)])#LISTS LAYOUT mc.columnLayout() mc.separator(h=10,style='in') mc.rowColumnLayout(numberOfColumns=2) mc.text('UNITS: ',align='right',fn='tinyBoldLabelFont') mc.text(str(mc.currentUnit(query=True)),align='left',fn='tinyBoldLabelFont') mc.text('FPS: ',align='right',fn='tinyBoldLabelFont') mc.text(str(sceneData.fps()),align='left',fn='tinyBoldLabelFont') mc.text('RENDER: ',align='left',fn='tinyBoldLabelFont') mc.text(str(mc.getAttr('defaultResolution.width'))+'x'+str(mc.getAttr('defaultResolution.height')),align='left',fn='tinyBoldLabelFont') mc.setParent('..') mc.setParent('listLayout') bldBrowseList() mc.setParent('listLayout') bldTargetList('browser') mc.setParent('listLayout') mc.showWindow()
def _initUI(self): layout = VBoxLayout(self) mc.window() mc.columnLayout() outputLog = mc.cmdScrollFieldReporter(clr=True) self.output_log_widget = convertMayaControl(outputLog) layout.addWidget(self.output_log_widget)
def pSaveFileCallback(*pArgs): filePathDir = mc.fileDialog2(fileMode=0) print filePathDir[0] if saveAsFilePath == None: mc.error("Didn't select a file to open.") print saveAsFilePath output = mc.cmdScrollFieldReporter("outputField", q=True, t=True)
def context_menu(): """ Create context menu for output window. """ # context menu output_win = cmds.cmdScrollFieldReporter(SCRIPT_OUTPUT_SCROLLFIELD, fst="") cmds.popupMenu(parent=output_win) cmds.menuItem( label="Clear Output", command=lambda c: cmds.cmdScrollFieldReporter(output_win, e=True, clear=True) ) # Echo all commands toggle cmds.menuItem( label="Toggle Echo Commands", command=lambda c: cmds.commandEcho(state=not (cmds.commandEcho(q=True, state=True))), ) # Go to python reference cmds.menuItem(label="Python Command Reference", command=lambda c: cmds.showHelp("DocsPythonCommands"))
def script_output(direction): """ Script output dock for layouts. """ dock_control = config['WINDOW_SCRIPT_OUTPUT_DOCK'] dock_window = config['WINDOW_SCRIPT_OUTPUT'] if cmds.dockControl(dock_control, ex=True): return cmds.dockControl(dock_control, e=True, vis=True, fl=False) if cmds.window(dock_window, ex=True): main_win = dock_window else: main_win = cmds.window(dock_window, title='Output Window') cmds.paneLayout(parent=main_win) # context menu output_win = cmds.cmdScrollFieldReporter(fst="") cmds.popupMenu(parent=output_win) cmds.menuItem( label='Clear Output', command=lambda c: cmds.cmdScrollFieldReporter( output_win, e=True, clear=True), ) # Echo all commands toggle cmds.menuItem( label='Toggle Echo Commands', command=lambda c: cmds.commandEcho( state=not(cmds.commandEcho(q=True, state=True))), ) # Go to python reference cmds.menuItem( label='Python Command Reference', command=lambda c: cmds.showHelp('DocsPythonCommands'), ) cmds.dockControl( dock_control, content=main_win, label='Output Window', area=direction, height=500, floating=False, allowedArea=['left', 'right'] )
def script_output(direction): """ Script output dock for layouts. """ dock_control = config['WINDOW_SCRIPT_OUTPUT_DOCK'] dock_window = config['WINDOW_SCRIPT_OUTPUT'] if cmds.dockControl(dock_control, ex=True): return cmds.dockControl(dock_control, e=True, vis=True, fl=False) if cmds.window(dock_window, ex=True): main_win = dock_window else: main_win = cmds.window(dock_window, title='Output Window') cmds.paneLayout(parent=main_win) # context menu output_win = cmds.cmdScrollFieldReporter(fst="") cmds.popupMenu(parent=output_win) cmds.menuItem( label='Clear Output', command=lambda c: cmds.cmdScrollFieldReporter( output_win, e=True, clear=True), ) # Echo all commands toggle cmds.menuItem( label='Toggle Echo Commands', command=lambda c: cmds.commandEcho(state=not (cmds.commandEcho( q=True, state=True))), ) # Go to python reference cmds.menuItem( label='Python Command Reference', command=lambda c: cmds.showHelp('DocsPythonCommands'), ) cmds.dockControl(dock_control, content=main_win, label='Output Window', area=direction, height=500, floating=False, allowedArea=['left', 'right'])
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 createUI(self,winName,dock): ##if Maya version is 2011 or above, create a doclable window, ##else create a floating window. if dock==True: if cmds.dockControl("%s_dock" % winName, q=True, exists=True): cmds.deleteUI("%s_dock" % winName) else: if cmds.window(winName, q=True, exists=True): cmds.deleteUI(winName) try: ###create window self.widgets["window"]=cmds.window(title="Render Wireframe", width=350, mnb=False,mxb=False) self.widgets["mainLayout"]=cmds.columnLayout("mainLayout",width=340,height=400,adj=True) self.widgets["scrolFldRprtr"]=cmds.cmdScrollFieldReporter("scrolFldRprtr",w=350,eac=False,fst="python") cmds.separator(h=5,style="none") cmds.separator(h=5,style="none") self.widgets["Amb_Occlus"]=cmds.text( label='Press CTRL button & hit the shelfbar button to render with AO' ) self.widgets["rowColumnLayout"]=cmds.rowColumnLayout(nc=2,cw=[(1,180),(2,140)],columnOffset=[(1,"both",5),(2,"both",2)]) self.widgets["aoCheck"]=cmds.checkBox("aoCheck",label='Render with Ambient Occlusion' , value=self.FLAG) self.widgets["mtrlSg_Attrib_Contrls"]= cmds.frameLayout('mtrlSg_Attrib_Contrls',w=340, label='Change Color and Wire Width', borderStyle='in',parent=self.widgets["mainLayout"] ) self.widgets["formLayout"] = cmds.formLayout("formLayout",numberOfDivisions=100) self.widgets["wireframeColor"]=cmds.attrColorSliderGrp('wireframeColor', sb=True, at='lambert1.outColor', l='Object Color') self.widgets["wireColorSlider"]=cmds.attrColorSliderGrp("wireColorSlider", l='Wire Color', at='initialShadingGroup.miContourColor', ann='the Wires will only show up in Render', sb=False) self.widgets["wirewidthControl"]=cmds.attrFieldSliderGrp("wirewidthControl",at=self.shadEngine+'.miContourWidth', ann='keep value between .5 and .8', min=0.0, max=1.50,l='Wire Width' ) self.widgets["antiAliasControl"]=cmds.floatSliderGrp("antiAliasControl", label='Anti Alias', cc=partial(self._change), field=True, minValue=0.01, maxValue=1.0, ann="change anti-alias contrast", value=cmds.getAttr("miDefaultOptions.contrastR") ) cmds.setParent('..') self.widgets["rowColumnRenLayout"]=cmds.rowColumnLayout( nc=2,cw=[(1,180),(2,140)],columnOffset=[(1,"both",5),(2,"both",2)]) self.widgets["renderSelected"]=cmds.iconTextButton('renderSelbtn', al='left',h=25,image='WireFrameOnShaded.png',ann='Wireframe selected object', style='iconAndTextHorizontal',label='Wireframe Selected',c=self._restrictUiReload) self.widgets["renderBtn"]=cmds.iconTextButton('renderBtn', align="right", h=25, width=100 , ann='Click here to take a test Render Preview\n For good quality use high resolution', c=cmds.RenderIntoNewWindow, style='iconAndTextHorizontal', image='menuIconRender.png', label='Render Preview') self.widgets["mainLayout_btns"]=cmds.columnLayout("mainLayout_btns", width=340, height=400) self.widgets["showSGbtn"]=cmds.button(c=self.showSGroup, l="Show Material", ann="Opens Attribute Editor and displays material of the selected object") self.widgets["formLayout"]=cmds.formLayout("formLayout", edit=True, af=[("wireframeColor",'top',0), ("wireframeColor",'left', -70)]) self.widgets["formLayout"]=cmds.formLayout("formLayout", edit=True, af=[("wireColorSlider",'top',20), ("wireColorSlider",'left', -70)]) self.widgets["formLayout"]=cmds.formLayout("formLayout", edit=True, af=[("wirewidthControl",'top',40), ("wirewidthControl",'left', -70)]) self.widgets["formLayout"]=cmds.formLayout("formLayout", edit=True, af=[("antiAliasControl",'top',60), ("antiAliasControl",'left', -70)]) cmds.scriptJob(parent=self.widgets["window"], e=["SelectionChanged",self.update]) except RuntimeError, err: print err
def SLiBFiXiT(): global slibTexPath slibTexPath = cmds.optionVar(query='SLiBLib') + '/' + '../' + '/' numTexfiles = len(rawlist) cleanList = [str(item) for item in missingFiles] window = cmds.window(title="SLiB | INFO:", iconName='Short Name', widthHeight=(400, 330), mxb=False, s=False) cmds.columnLayout() cmds.cmdScrollFieldReporter(width=400, height=298, clear=True) cmds.button(label='CLOSE', width=400, height=30, command=('cmds.deleteUI(\"' + window + '\", window=True)')) cmds.setParent('..') cmds.showWindow(window) missing = len(missingFiles) if missing: print 'Searching...' new(slibTexPath) else: pass #print 'Nothing to Fix!' missingN = len(missingFilesN) if missingN: print 'Searching...' newN(slibTexPath) else: pass #print 'Nothing to Fix!' print '\n' + str(missing) + ' Missing TextureFile(s) Found and Fixed!' print '\n' + str(missingN) + ' Missing NormalMap(s) Found and Fixed!'
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 floatingOutputReporter(): """ standalone script editor output floating window """ #windowName = cmds.window(t='floating output', w = 650, h = 300) controlName = 'dmptools_output_control' try: cmds.deleteUI(controlName, control=True) except: pass form = cmds.formLayout() # output reporter reporter = cmds.cmdScrollFieldReporter('reporter') cmds.formLayout(form, e=True, attachForm=\ [ (reporter, "top", 5), (reporter, "bottom", 5), (reporter, "left", 5), (reporter, "right", 5), ] ) cmds.dockControl(controlName, label='floating output', floating=True, area='right', content=form)
def clearTF(*pArgs): mc.cmdScrollFieldReporter("outputField", e=True, clear=True)
def pSaveFileCallback(*pArgs): #filePathDir = mc.fileDialog2(fileMode=0) #saveOutput = filePathDir[0] #if saveAsFilePath == None: #mc.error("Didn't select a file to open.") mc.cmdScrollFieldReporter("outputField", e=True, saveSelection=True)
def createUI(self, winName, dock): ##if Maya version is 2011 or above, create a doclable window, ##else create a floating window. if dock == True: if cmds.dockControl(winName + "_dock", q=True, exists=True): cmds.deleteUI(winName + "_dock") else: if cmds.window(winName, q=True, exists=True): cmds.deleteUI(winName) try: ###create window self.widgets["window"] = cmds.window(title="Render Wireframe", width=350, mnb=False, mxb=False) self.widgets["mainLayout"] = cmds.columnLayout("mainLayout", width=340, height=400, adj=True) self.widgets["scrolFldRprtr"] = cmds.cmdScrollFieldReporter("scrolFldRprtr", w=350, eac=False, fst="python") cmds.separator(h=5, style="none") cmds.separator(h=5, style="none") self.widgets["Amb_Occlus"] = cmds.text( label="Press CTRL button & hit the shelfbar button to render with AO" ) self.widgets["rowColumnLayout"] = cmds.rowColumnLayout( nc=2, cw=[(1, 180), (2, 140)], columnOffset=[(1, "both", 5), (2, "both", 2)] ) self.widgets["aoCheck"] = cmds.checkBox("aoCheck", label="Render with Ambient Occlusion", value=self.FLAG) self.widgets["mtrlSg_Attrib_Contrls"] = cmds.frameLayout( "mtrlSg_Attrib_Contrls", w=340, label="Change Color and Wire Width", borderStyle="in", parent=self.widgets["mainLayout"], ) self.widgets["formLayout"] = cmds.formLayout("formLayout", numberOfDivisions=100) self.widgets["wireframeColor"] = cmds.attrColorSliderGrp( "wireframeColor", sb=True, at="lambert1.outColor", l="Object Color" ) self.widgets["wireColorSlider"] = cmds.attrColorSliderGrp( "wireColorSlider", l="Wire Color", at="initialShadingGroup.miContourColor", ann="the Wires will only show up in Render", sb=False, ) self.widgets["wirewidthControl"] = cmds.attrFieldSliderGrp( "wirewidthControl", at=self.shadEngine + ".miContourWidth", ann="keep value between .5 and .8", min=0.0, max=1.50, l="Wire Width", ) self.widgets["antiAliasControl"] = cmds.floatSliderGrp( "antiAliasControl", label="Anti Alias", cc=partial(self.change), field=True, minValue=0.01, maxValue=1.0, ann="change anti-alias contrast", value=cmds.getAttr("miDefaultOptions.contrastR"), ) cmds.setParent("..") self.widgets["rowColumnRenLayout"] = cmds.rowColumnLayout( nc=2, cw=[(1, 180), (2, 140)], columnOffset=[(1, "both", 5), (2, "both", 2)] ) self.widgets["renderSelected"] = cmds.iconTextButton( "renderSelbtn", al="left", h=25, image="WireFrameOnShaded.png", ann="Wireframe selected object", style="iconAndTextHorizontal", label="Wireframe Selected", c=self.wfSeltd, ) self.widgets["renderBtn"] = cmds.iconTextButton( "renderBtn", align="right", h=25, width=100, ann="Click here to take a test Render Preview\n For good quality use high resolution", c=cmds.RenderIntoNewWindow, style="iconAndTextHorizontal", image="menuIconRender.png", label="Render Preview", ) self.widgets["mainLayout_btns"] = cmds.columnLayout("mainLayout_btns", width=340, height=400) self.widgets["showSGbtn"] = cmds.button( c=self.showSGroup, l="Show Material", ann="Opens Attribute Editor and displays material of the selected object", ) self.widgets["formLayout"] = cmds.formLayout( "formLayout", edit=True, af=[("wireframeColor", "top", 0), ("wireframeColor", "left", -70)] ) self.widgets["formLayout"] = cmds.formLayout( "formLayout", edit=True, af=[("wireColorSlider", "top", 20), ("wireColorSlider", "left", -70)] ) self.widgets["formLayout"] = cmds.formLayout( "formLayout", edit=True, af=[("wirewidthControl", "top", 40), ("wirewidthControl", "left", -70)] ) self.widgets["formLayout"] = cmds.formLayout( "formLayout", edit=True, af=[("antiAliasControl", "top", 60), ("antiAliasControl", "left", -70)] ) cmds.scriptJob(parent=self.widgets["window"], e=["SelectionChanged", self.update]) except RuntimeError, err: print err
def pUpdateOutputField(*pArgs): #outputField = mc.cmdScrollFieldExecuter(width= 395, height=400, showLineNumbers=True, sw=True, text= output) outputField = mc.cmdScrollFieldReporter(width=395, height=400, echoAllCommands=True)
def showNewEditorWindow(_show, *args): windowWidth = 400 windowHeight = 300 #window command to define the window cmds.window(newScriptEditorName, title='Script Editor', width=windowWidth, height=windowHeight, minimizeButton=True, maximizeButton=True) #define a form layout and store it in a variable form = cmds.formLayout() #define and save a cmdScrollFieldExecutor (basically maya equivelent to the pyqt editor command) as a variable scriptEditor = cmds.cmdScrollFieldExecuter(width=200, height=330, sourceType="python", showLineNumbers=True) #important to note that saving it as a variable returns the window number (correspoinding to the resulting object I assume), # a form layout number, and cmds scroll field executor all divided by an "|" character #print(scriptEditor) #calling the split command isolates the return from scriptEditor var into a list lst = scriptEditor.split('|') #use a simple list length -1 call on the list to store the last item (the cmdScrollFieldExecutorNumber) as a variable scriptEditorId = lst[len(lst) - 1] #real quickly going to try to store the reporter as a variable to be called and attached to the form layout scriptReporter = cmds.cmdScrollFieldReporter(width=900, height=70) rLst = scriptReporter.split('|') scriptReporterId = rLst[len(rLst) - 1] #making some row column layouts to call in, both fileRow = cmds.rowLayout() #for whatever reason maya cannot find this object when later referenced cmds.setParent('..') runRow = cmds.rowLayout() #form layout when used to attach forms needs to call a layout object? #and I'm using the form layout thats stored as for if _show == True: cmds.cmdScrollFieldExecuter(scriptEditor, edit=True) cmds.formLayout(form, edit=True, attachForm=[(scriptEditorId, "top", 35), (scriptEditorId, "bottom", 125), (scriptEditorId, "left", 5), (scriptEditorId, "right", 5), (scriptReporterId, "bottom", 40), (scriptReporterId, "left", 42), (scriptReporterId, "right", 5), (fileRow, "top", 5), (runRow, "bottom", 5), (runRow, "right", 20), (runRow, "left", 20)]) #start adding buttons for the functions #the row for the execute buttons cmds.rowLayout(runRow, numberOfColumns=2) cmds.columnLayout(adjustableColumn=True) cmds.button(label="Execute All", command=partial(executeAllInWindow, scriptEditorId), width=450) cmds.setParent('..') cmds.columnLayout(adjustableColumn=True) cmds.button(label="Execute Selection", command=partial(executeSelectionInWindow, scriptEditorId), width=450) #these set parents move the next ui element up the layout hierarchy cmds.setParent('..') cmds.setParent('..') cmds.setParent('..') cmds.setParent('..') #the row for the save and reporter buttons cmds.rowLayout(fileRow, numberOfColumns=4) saveScriptFileButton = cmds.button(label="Save To Shelf", command=partial( saveScriptAsFile, scriptEditorId), width=225) saveScriptFileButton = cmds.button(label="Save As File", command=partial( saveScriptAsFile, scriptEditorId), width=225) saveScriptFileButton = cmds.button(label="Toggle Echo All", command=partial( saveScriptAsFile, scriptEditorId), width=225) saveScriptFileButton = cmds.button(label="Clear Reporter", command=partial( saveScriptAsFile, scriptEditorId), width=225) #run window cmds.showWindow() return
def createUI(pWindowTitle): windowID = 'myWindowID' if mc.window(windowID, exists=True): mc.deleteUI(windowID) mc.window(windowID, title=pWindowTitle, sizeable=True, resizeToFitChildren=True, width=200) # OPENING ANS SAVING WINDOWS def pOpenFileCallback(*pArgs): mc.cmdScrollFieldReporter("outputField", e=True, clear=True) fileOutput = mc.fileDialog2(fileMode=1) fileContent = fileOutput[0] mm.eval('string $filePath = "' + str(fileContent) + '"') mm.eval('$fileId = `fopen $filePath "r"`') mm.eval("string $data = `fread $fileId $data`") transferMELVar = maya.mel.eval("$temp=$data") print transferMELVar test = str(transferMELVar) #myFile = "E:/Users/candrad6/Desktop/FinalTools/TestFiles/history.txt" #string $filePath = myFile; #$fileId = "`mm.fopen $filePath "r"`"; def pSaveFileCallback(*pArgs): filePathDir = mc.fileDialog2(fileMode=0) print filePathDir[0] if saveAsFilePath == None: mc.error("Didn't select a file to open.") print saveAsFilePath output = mc.cmdScrollFieldReporter("outputField", q=True, t=True) def pPastaCallback(*pArgs): mm.eval("sphere -radius 3;") mc.menuBarLayout('Meun') mc.menu('File') mc.menuItem('Open', command=pOpenFileCallback) mc.menuItem('Save As...', command=pSaveFileCallback) mc.rowColumnLayout(numberOfColumns=1, columnWidth=(1, 400), columnOffset=(1, 'left', 3)) # MENUBAR LAYOUT def pRecordCallback(*pArgs): print 'Recording...' fileHistDir = mc.fileDialog2(fileMode=0) savingDir = fileHistDir[0] userHist = mc.scriptEditorInfo(historyFilename=savingDir, writeHistory=True) def pClearCallback(*pArgs): print 'Clear button pressed.' outputField(clear=True, enable=True) def pStopCallback(*pArgs): print 'Stopped Recording.' mc.scriptEditorInfo(writeHistory=False) outputField(enable=False) def clearTF(*pArgs): mc.cmdScrollFieldReporter("outputField", e=True, clear=True) def pRunCallback(*pArgs): output = mc.cmdScrollFieldReporter("outputField", q=True, t=True) mm.eval(output) mc.separator(h=10, style="none") mc.rowLayout(numberOfColumns=2) mc.button(label='RECORD', width=195, backgroundColor=(1, 0, 0), command=pRecordCallback) # mc.button(label= 'CLEAR', width=195, backgroundColor=(1, 1, 0), command=pClearCallback) mc.button(label='STOP', width=195, backgroundColor=(1, 0, 0), command=pStopCallback) mc.setParent("..") mc.rowLayout(numberOfColumns=2) mc.button(label='CLEAR', width=195, backgroundColor=(1, 1, 0), command=clearTF) mc.button(label='RUN', width=195, backgroundColor=(0, 1, 0), command=pRunCallback) mc.setParent("..") # mc.text(label='SELECTED STEPS') # TABS form = mc.formLayout() tabs = mc.tabLayout(innerMarginWidth=5, innerMarginHeight=5) mc.formLayout(form, edit=True, attachForm=((tabs, 'top', 0), (tabs, 'left', 0), (tabs, 'bottom', 0), (tabs, 'right', 0))) clearValue = True child1 = mc.rowLayout(numberOfColumns=2) outputField = mc.cmdScrollFieldReporter("outputField", width=395, height=400, clear=clearValue, echoAllCommands=False, suppressInfo=True, suppressStackTrace=True, suppressResults=True, enable=False) mc.setParent('..') child2 = mc.rowLayout(numberOfColumns=2) inputField = mc.cmdScrollFieldExecuter(width=395, height=400, showLineNumbers=True) mc.setParent("..") mc.tabLayout(tabs, edit=True, tabLabel=((child1, 'Actions List'), (child2, 'Edit Actions'))) mc.setParent("..") mc.separator(h=10, style="none") #mc.button(label= 'Execute', width=395, backgroundColor=(0, 50, 0), command=pExecuteCallback) #mc.button(label= 'Clear', width=395) #mc.textScrollList(append=['']) mc.showWindow()
def createUI(pWindowTitle): windowID = 'myWindowID' if mc.window(windowID, exists=True): mc.deleteUI(windowID) mc.window(windowID, title=pWindowTitle, sizeable=True, resizeToFitChildren=True, width=200) # OPENING ANS SAVING WINDOWS def pOpenFileCallback(*pArgs): fileOutput = pm.fileDialog2(fileMode=1) #fileOutput[0] myFile = "X:/Documents/SchoolWork/LMU/Fall2016/PipelineCS/FinalTools/history.txt" #string $filePath = myFile; #$fileId = "`mm.fopen $filePath "r"`"; def pSaveFileCallback(*pArgs): pm.fileDialog2(fileMode=0) def pPastaCallback(*pArgs): mm.eval("sphere -radius 3;") mc.menuBarLayout('Meun') mc.menu('File') mc.menuItem('Open', command=pOpenFileCallback) mc.menuItem('Save As...', command=pSaveFileCallback) mc.menuItem('CloseMM') mc.menu('Edit') mc.menuItem('Copy') mc.menuItem('Pasta', command=pPastaCallback) mc.rowColumnLayout(numberOfColumns=1, columnWidth=(1, 400), columnOffset=(1, 'left', 3)) # MENUBAR LAYOUT def pRecordCallback(*pArgs): print 'Recording...' fileHistDir = "X:/Documents/SchoolWork/LMU/Fall2016/PipelineCS/FinalTools/history.txt" userHist = mc.scriptEditorInfo(historyFilename=fileHistDir, writeHistory=True) def pClearCallback(*pArgs): print 'Clear button pressed.' outputField(clear=True) def pStopCallback(*pArgs): mc.scriptEditorInfo(writeHistory=False) print 'Stopped Recording.' mc.separator(h=10, style="none") mc.rowLayout(numberOfColumns=2) mc.button(label='Record', width=195, backgroundColor=(1, 1, 0), command=pRecordCallback) # mc.button(label= 'CLEAR', width=195, backgroundColor=(1, 1, 0), command=pClearCallback) mc.button(label='STOP', width=195, backgroundColor=(1, 0, 0), command=pStopCallback) mc.setParent("..") # mc.text(label='SELECTED STEPS') # TABS form = mc.formLayout() tabs = mc.tabLayout(innerMarginWidth=5, innerMarginHeight=5) mc.formLayout(form, edit=True, attachForm=((tabs, 'top', 0), (tabs, 'left', 0), (tabs, 'bottom', 0), (tabs, 'right', 0))) clearValue = True child1 = mc.rowLayout(numberOfColumns=2) outputField = mc.cmdScrollFieldReporter(width=395, height=400, clear=clearValue, echoAllCommands=False, suppressStackTrace=True) mc.setParent('..') child2 = mc.rowLayout(numberOfColumns=2) inputField = mc.cmdScrollFieldExecuter(width=395, height=400, showLineNumbers=True) mc.setParent("..") mc.tabLayout(tabs, edit=True, tabLabel=((child1, 'Selected Steps'), (child2, 'Editor'))) mc.setParent("..") mc.separator(h=10, style="none") #mc.button(label= 'Execute', width=395, backgroundColor=(0, 50, 0), command=pExecuteCallback) #mc.button(label= 'Clear', width=395) #mc.textScrollList(append=['']) mc.showWindow()
def pRunCallback(*pArgs): output = mc.cmdScrollFieldReporter("outputField", q=True, t=True) mm.eval(output)
def w00_window_QSTools(*args, **kwargs): if cmds.window('w00', q=True, exists=True): #cmds.showWindow('w00') #return cmds.deleteUI('w00') iconDirs = [] for iconDir in args[0]: if os.path.exists(iconDir): iconDirs.append(iconDir) #---Collection nodeTreeLister Data funList = w00_fun_scriptList([('qsMaya','qm', 'pythonFamily.png'),\ #('hou_in_maya','HIM', '%s\houdini\cloudsubmit\houdini_icon.png'%(houdiniPath) ),\ ('window','qmw', 'pythonFamily.png')], iconDirs ) #melCmdList, melListData = getMelList() funList.extend(melCmdList) #Sort and remove same functions temp, funs = [], [] for i in funList[:]: if i[0] not in funs: funs.append(i[0]) fname = i[0].rsplit('/', 1)[-1] temp.append((fname, i)) temp.sort() funList = [f[1] for f in temp] #globals()['funList'] = funList del temp, funs cmds.window('w00', title='HQ Maya', menuBar=True, retain=True, sizeable=True, rtf=True) #Script Editor menuBar cmds.menu('w00_06_scrEditMenu', p='w00', label='Script Editor', tearOff=True) cmds.menuItem('w00_helpStringSwitch', p='w00_06_scrEditMenu', label='Help to script editor', checkBox=False) cmds.menuItem('w00_onlineHelpSwitch', p='w00_06_scrEditMenu', label='Open online help', checkBox=False) cmds.menuItem(p='w00_06_scrEditMenu', divider=True) cmds.menuItem( 'w00_07_comp', p='w00_06_scrEditMenu', label='Command Completion', checkBox=False, command= 'cmds.cmdScrollFieldExecuter("w00_03_pythonWin", e=True,commandCompletion=w00_fun_menuItemSet("w00_07_comp"))\ncmds.cmdScrollFieldExecuter("w00_04_melWin", e=True,commandCompletion=w00_fun_menuItemSet("w00_07_comp"))' ) cmds.menuItem( 'w00_08_toolTip', p='w00_06_scrEditMenu', label='show Tooltip Help', checkBox=False, command= 'cmds.cmdScrollFieldExecuter("w00_03_pythonWin", e=True,showTooltipHelp=w00_fun_menuItemSet("w00_08_toolTip"))\ncmds.cmdScrollFieldExecuter("w00_04_melWin", e=True,showTooltipHelp=w00_fun_menuItemSet("w00_08_toolTip"))' ) cmds.menuItem(p='w00_06_scrEditMenu', divider=True) cmds.menuItem( 'w00_08_linNum', p='w00_06_scrEditMenu', label='Line numbers in errors', checkBox=False, command= 'cmds.cmdScrollFieldReporter("w00_05, e=True,lineNumbers=w00_fun_menuItemSet("w00_08_linNum"))' ) cmds.menuItem( 'w00_09_echoAll', p='w00_06_scrEditMenu', label='Echo All Commands', checkBox=False, command= 'cmds.cmdScrollFieldReporter("w00_05", e=True,echoAllCommands=w00_fun_menuItemSet("w00_09_echoAll"))' ) cmds.menuItem(p='w00_06_scrEditMenu', divider=True) cmds.menuItem( 'w00_10_supCom', p='w00_06_scrEditMenu', label='Suppress Command Results', checkBox=False, command= 'cmds.cmdScrollFieldReporter("w00_05", e=True,suppressResults=w00_fun_menuItemSet("w00_10_supCom"))' ) cmds.menuItem( 'w00_11_supInfo', p='w00_06_scrEditMenu', label='Suppress Info Messages', checkBox=False, command= 'cmds.cmdScrollFieldReporter("w00_05", e=True,suppressInfo=w00_fun_menuItemSet("w00_11_supInfo"))' ) cmds.menuItem( 'w00_12_supWarn', p='w00_06_scrEditMenu', label='Suppress Warning Messages', checkBox=False, command= 'cmds.cmdScrollFieldReporter("w00_05", e=True,suppressWarnings=w00_fun_menuItemSet("w00_12_supWarn"))' ) cmds.menuItem( 'w00_13_supError', p='w00_06_scrEditMenu', label='Suppress Error Messages', checkBox=False, command= 'cmds.cmdScrollFieldReporter("w00_05", e=True,suppressErrors=w00_fun_menuItemSet("w00_13_supError"))' ) #meunu bar end #form Layout is main cmds.formLayout('w00_formLayout', p='w00', w=550, numberOfDivisions=100) #panelLayout UI cmds.paneLayout('w00_00_panelLayout', p='w00_formLayout', configuration='right3') cmds.nodeTreeLister('w00_01', p='w00_00_panelLayout', addItem=[(path, icon, cmd) for path, icon, cmd in funList]) #pop menu for treeLister cmds.popupMenu('w00_15_popMenu', p='w00_01') cmds.menuItem(p='w00_15_popMenu', label='CommandToScriptEditor', command='w00_fun_popCommand()') #cmds.menuItem(p='w00_15_popMenu',label='Online help/To Script editor', command='w00_online_help()' ) #script ediotrs tabLayout UI cmds.tabLayout('w00_02_tabLayout', p='w00_00_panelLayout', innerMarginWidth=5, innerMarginHeight=5) cmds.cmdScrollFieldExecuter('w00_03_pythonWin', p='w00_02_tabLayout', cco=False, sth=False, sourceType="python", sln=True) cmds.cmdScrollFieldExecuter('w00_04_melWin', p='w00_02_tabLayout', cco=False, sth=False, sourceType="mel", sln=True) #cmds.formLayout('w00_02_neFormLayout', p='w00_02_tabLayout') #if cmds.scriptedPanel('w00_02_nodeEditor', q=True, exists=True): #cmds.deleteUI('w00_02_nodeEditor') #cmds.scriptedPanel('w00_02_nodeEditor', p='w00_02_neFormLayout', type="nodeEditorPanel", label="Node Editor") #cmds.formLayout('w00_02_neFormLayout', e=True, p='w00_02_tabLayout', af=[('w00_02_nodeEditor',s,0) for s in ("top","bottom","left","right")]) #cmds.cmdScrollFieldExecuter( 'w00_04_houWin',p='w00_02_tabLayout', cco=False, sth=False, sourceType="python", sln=True) cmds.tabLayout( 'w00_02_tabLayout', e=True, tabLabel=(('w00_03_pythonWin', 'Python'), ('w00_04_melWin', 'MEL'))) #, ('w00_02_neFormLayout', 'Node Editor')) ) cmds.cmdScrollFieldReporter('w00_05', p='w00_00_panelLayout', ln=True, eac=False, sr=False, si=False, sw=False, se=False, clr=True) #buttons UI cmds.rowLayout('w00_14_rowLayout', p='w00_formLayout', numberOfColumns=6) cmds.iconTextButton(label='ProjectFolder', p='w00_14_rowLayout', width=50, style='iconOnly', image='fileOpen.png', command='w00_fun_openProjectFolder()') #cmds.button(label='ProjectFolder',p='w00_14_rowLayout', bgc=[1,.6,0], command='w00_fun_openProjectFolder()') cmds.iconTextButton(label='ClearInput', p='w00_14_rowLayout', width=50, style='iconOnly', image='clearHistory.png', command='w00_fun_clearExecuter()') cmds.iconTextButton(label='ExecuteAll', p='w00_14_rowLayout', width=50, style='iconOnly', image='executeAll.png', command='w00_fun_executerAllButton()') cmds.iconTextButton(label='Execute', p='w00_14_rowLayout', width=50, style='iconOnly', image='execute.png', command='w00_fun_executerSelButton()') #cmds.button(label='Execute', p='w00_14_rowLayout', command='w00_fun_executerSelButton()') cmds.iconTextButton( label='ClearDown', p='w00_14_rowLayout', width=50, style='iconOnly', image='clearInput.png', command='cmds.cmdScrollFieldReporter("w00_05",e=True,clr=True)') #cmds.button(label='ClearDown', p='w00_14_rowLayout', command='cmds.cmdScrollFieldReporter("w00_05",e=True,clr=True)') cmds.formLayout('w00_formLayout', e=True,\ af=[('w00_00_panelLayout', 'top', 0), ('w00_00_panelLayout', 'left', 0), ('w00_00_panelLayout', 'bottom', 0),('w00_00_panelLayout', 'right', 0), ('w00_14_rowLayout', 'top', 0), ('w00_14_rowLayout', 'right', 0) ],\ attachNone=[('w00_14_rowLayout', 'left'), ('w00_14_rowLayout', 'bottom')] ) cmds.showWindow('w00')