def _isPanelVisible(panelName): ''' Determines if the given panel is open. Minimized panels are considered closed. ''' # Sanity Check: if not (panelName and cmd.scriptedPanel(panelName, query=True, exists=True)): return False # cmd.scriptedPanel does not provide a way to query what window # it uses. cmd.lsUI(windows=1) appears to be broken in maya # 2018, only returning 'MayaWindow', even when more windows are # open. Which means it's no longer possible to search for # windows by name. Therefore, the ONLY way to query a window # AFAIK is the most fragile - to simply hope it's at the top # level of the UI path (I suppose we might be able to trace it # using QT, but that comes with the small risk of segfaulting # instead of simply erroring). So much for good coding # standards. #ThanksMaya! # Get full path to panel panelPath = cmd.scriptedPanel(panelName, query=True, control=True) if not panelPath: # The docs say scriptedPanels may not have controls return False # But I don't realistically think this will happen. # Use root path as window. window = panelPath.split('|')[0] if not window: return False # Return if the window is visible and not minimized. return (cmd.window(window, query=True, visible=True) and not cmd.window(window, query=True, iconify=True))
def __init__(self, parent, panelname, *args, **kwargs): super(GraphEditor, self).__init__(parent) self.panelname = panelname self.paneName = "GE_ui_paneLayout" cmds.setParent('MayaWindow') if cmds.paneLayout( self.paneName, ex=True ): ###This paneLayout is required for findPanelPopupParent.mel### cmds.deleteUI(self.paneName) paneLayout = cmds.paneLayout(self.paneName, configuration="single") if cmds.scriptedPanel(self.panelname, ex=True): cmds.deleteUI(self.panelname) graphEditor = cmds.scriptedPanel(self.panelname, type='graphEditor', unParent=True) cmds.scriptedPanel(self.panelname, e=True, parent=paneLayout) ptr = omui.MQtUtil.findControl(paneLayout) widget = wrapInstance(long(ptr), QWidget) layout = QVBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(widget)
def __init__(self): mel.eval("source \"AEfileTemplate.mel\";") self.windowId = 'bpj_shaderAndTextureListerWindow' self.toolbarId = 'bpj_shaderAndTextureListerToolbar' self.listLayoutId = 'bpj_shaderAndTextureListerFormId' # self.toolbarWidth = 280 self.toolbarWidth = 68 # creating a scriptedPanelType if cmds.scriptedPanelType('bpj_shaderAndTextureListerScriptedPanelType', exists = 1) == 0: cmds.scriptedPanelType( 'bpj_shaderAndTextureListerScriptedPanelType', unique=True, createCallback = 'bpj_shaderAndTextureListerCreateCallback', initCallback = 'bpj_shaderAndTextureListerInitCallback', addCallback = 'bpj_shaderAndTextureListerAddCallback', removeCallback = 'bpj_shaderAndTextureListerRemoveCallback', deleteCallback = 'bpj_shaderAndTextureListerDeleteCallback', saveStateCallback ='bpj_shaderAndTextureListerSaveStateCallback' ) # creating an unparented scripted panel if cmds.scriptedPanel('bpj_shaderAndTextureListerScriptedPanel', exists = 1): cmds.deleteUI('bpj_shaderAndTextureListerScriptedPanel', panel = 1) cmds.scriptedPanel( 'bpj_shaderAndTextureListerScriptedPanel', unParent = 1, type = 'bpj_shaderAndTextureListerScriptedPanelType', menuBarVisible = 0, label = 'Shader/Texture Lister' )
def switchToPanel(self): # fullUiPath = cmds.layout(self.mainLayout, q = 1, fullPathName = 1) # fullUiPathList = fullUiPath.split('|') curPanel = cmds.getPanel(withFocus = 1) if curPanel != "": cmds.scriptedPanel("bpj_shaderAndTextureListerScriptedPanel", edit = 1, rp = curPanel)
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 view_render(): panel_window = "renderViewWindow" if cmds.window(panel_window, q=True, exists=True): cmds.deleteUI(panel_window, window=True) else: panel = cmds.getPanel(withLabel="Render View") cmds.scriptedPanel(panel, e=True, tearOff=True)
def hyperWindow(): if cmds.window('hyperGraphPanel1Window', query=True, exists= True): if cmds.window('hyperGraphPanel1Window', query = True, vis = True) == True: cmds.window('hyperGraphPanel1Window', edit = True, vis = False) else: cmds.window('hyperGraphPanel1Window', edit = True, vis = True) else: if cmds.scriptedPanel('hyperGraphPanel1', query = True, exists = True): cmds.scriptedPanel('hyperGraphPanel1', edit = True, tearOff = True) cmds.showWindow('hyperGraphPanel1Window')
def calibrateSpineStretch(self, raw=True): nullGrp = self.spine.spineAnimCurve cmds.select(nullGrp) if raw: sender = 'graphEditor' for panel in cmds.getPanel(sty="%s" % (sender)) or []: cmds.scriptedPanel(panel, e=True, to=True) cmds.FrameAll()
def graphWindow(): graphEditor = cmds.getPanel(scriptType = 'graphEditor') print graphEditor, ' this is graphEditor' for editors in graphEditor: graphEditorWindow = (editors + 'Window') print graphEditorWindow, ' this is graphEditorWindow' if cmds.window(graphEditorWindow, exists = True): cmds.deleteUI(graphEditorWindow, window =True) else: cmds.scriptedPanel(editors, edit=True, to = True)
def createUI(*args): if mc.window('UVDeluxe', exists=True): #remove when not in dev mode mc.deleteUI('UVDeluxe') mc.window('UVDeluxe', s=True, width=440, title='UV Deluxe %s' % version, toolbox=False) #Create Scriptjobs jobNumber1 = mc.scriptJob( parent='UVDeluxe', event=['linearUnitChanged', lambda *args: updateUI('units_text')]) ### Define texture panel ### # Figure out percentage pnSize = (220 / float(uis.widthHeight[0])) * 100 try: #swp flag only available in 2011 and beyond pane = mc.paneLayout('textureEditorPanel', paneSize=[1, pnSize, 1], cn='vertical2', swp=1) except: pane = mc.paneLayout('textureEditorPanel', paneSize=[1, pnSize, 1], cn='vertical2') uvTextureViews = mc.getPanel(scriptType='polyTexturePlacementPanel') if len(uvTextureViews): mc.scriptedPanel(uvTextureViews[0], e=True, unParent=True) #Load main ui elements# mc.columnLayout('MainColumn', columnWidth=220) ui_Settings(0) ui_Mover() ui_Scaler() ui_Ratio() ui_MatchUV() ui_Straighten() ui_Align() #ui_SelectionSet() ui_QuickSnap() #Add texture panel to window mc.scriptedPanel(uvTextureViews[0], e=True, parent=pane) # SHOW WINDOW # mc.showWindow('UVDeluxe') mc.window('UVDeluxe', edit=True, mnb=True, widthHeight=uis.widthHeight)
def SpeedUpBake_1_Store(sName): # store a temporary panel configuration. layout = cmds.panelConfiguration(l=sName, sc=0) evalStr = 'updatePanelLayoutFromCurrent "'+name+'"' mel.eval(evalStr) # switch to fast "hidden" layout evalStr = 'setNamedPanelLayout "Single Perspective View"' mel.eval(evalStr) perspPane = cmds.getPanel(vis=1) cmds.scriptedPanel('graphEditor1',e=1,rp=perspPane[0]) return sName
def dropTool(*args): cmds.undoInfo(swf=False) if currentRender == 'arnold': if cmds.arnoldIpr(q=1, mode='start'): cmds.arnoldIpr(mode='stop') #if currentRender == 'mentalRay': #iprRender() cmds.layout('scrollBarForm', e=1, vis=1) cmds.deleteUI('vpRenderWindow') cmds.optionVar(iv=('renderViewDisplayToolbar', 1)) cmds.scriptedPanel(renderViews, e=True, mbv=1) cmds.setAttr(camera0 + '.preScale', 1) cmds.setAttr(camera0 + '.filmTranslateH', 0) cmds.setAttr(camera0 + '.filmTranslateV', 0) # center of interest camPivot = cmds.getAttr('Viewport_RenderShape.centerOfInterest') cmds.setAttr(camera0 + '.centerOfInterest', camPivot) cmds.parent(camera1, w=True) cmds.delete('Viewport_Render') cmds.select(clear=True) mel.eval('lookThroughModelPanel ' + camera1 + ' ' + currentPanel + ';') # delete expression if exists if cmds.camera(camera1, q=1, o=1): cmds.delete("vprexpression") cmds.delete("OverScanExpression") if oldRez != []: cmds.setAttr('defaultResolution.width', oldRez[0]) cmds.setAttr('defaultResolution.height', oldRez[1]) cmds.setAttr('defaultResolution.deviceAspectRatio', oldRez[2]) if currentRender == 'vray': cmds.setAttr('vraySettings.width', oldRez[0]) cmds.setAttr('vraySettings.height', oldRez[1]) mel.eval('vraySetPixelDeviceAspect();') cmds.setAttr(camera0 + '.cameraScale', 1) cmds.setAttr(camera0 + ".horizontalFilmOffset", 0) cmds.setAttr(camera0 + ".verticalFilmOffset", 0) cmds.undoInfo(swf=True)
def bakeSkins(objects, *args): # for each object (transform), create a duplicate, unlock channels, move to world space, freeze xforms, then wrap deform it to the original. # disable all display smoothing to speed things up and prevent max from interpreting the points incorrectly. print '\nRUNNING bakeSkins' polys = cmds.ls(type='mesh') cmds.displaySmoothness(polys, du=0, dv=0, pw=4, ps=1, po=1) start = cmds.playbackOptions(q=1, min=1) end = cmds.playbackOptions(q=1, max=1) # create a quick select set to house the deforming geometry. all duplicates will be added to this set for the fbx plugin. cmds.select(cl=1) exportSet = cmds.sets(text='gCharacterSet', n='FBXExportSet') cacheDir = os.path.join(cmds.workspace(q=1, fn=1), 'data', 'FBX', os.path.splitext(cmds.file(q=1, sn=1, shn=1))[0], 'pointCache').replace('\\', '/') if not os.path.exists(cacheDir): os.makedirs(cacheDir) # block the viewport mel.eval('setNamedPanelLayout "Single Perspective View"') perspPane = cmds.getPanel(vis=1) cmds.scriptedPanel('graphEditor1', e=1, rp=perspPane[0]) # wraps = [] # cycle through objects for obj in objects: dupe = cmds.duplicate(obj, rc=1, rr=1)[0] chans = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'] for i in chans: cmds.setAttr(dupe + '.' + i, lock=False) try: dupe = cmds.parent(dupe, w=1)[0] except RuntimeError: pass cmds.delete(dupe, ch=1) blend = cmds.blendShape(obj, dupe, foc=1, origin='world') cmds.blendShape(blend, e=1, w=[0, 1.0]) cmds.sets(dupe, add=exportSet) dupeShape = cmds.listRelatives(dupe, s=1, ni=1)[0] # next run the MEL export commands for FBX. # the FBX plugin will automatically create the geocache, so there's no reason for me to write them out manually. mel.eval('FBXResetExport;') mel.eval('FBXExportCacheFile -v true;') evalStr = 'FBXExportQuickSelectSetAsCache -v ' + exportSet + ';' mel.eval(evalStr) mel.eval('FBXExportInputConnections -v false;') # select the objects to export from the selection set. cmds.select(exportSet) cmds.select(exportSet, add=1, ne=1) fbxFile = os.path.join( cacheDir, os.path.splitext(cmds.file(q=1, sn=1, shn=1))[0] + '_SKINS.fbx').replace('\\', '/') evalStr = 'FBXExport -f "' + fbxFile + '" -s' mel.eval(evalStr) print('Exported skins and point caches to %s') % (fbxFile)
def viewport(self,value): if value==0: layout=mc.panelConfiguration(l='tempLayout',sc=0) evalStr='updatePanelLayoutFromCurrent "' +'tempLayout'+'"' mel.eval(evalStr) evalStr = 'setNamedPanelLayout "Single Perspective View" ' mel.eval(evalStr) perspPane=mc.getPanel(vis=1) mc.scriptedPanel('graphEditor1',e=1,rp=perspPane[0]) return 'tempLayout' if value==1: evalStr= 'setNamedPanelLayout "'+ 'tempLayout' + '"' mel.eval(evalStr) killMe=mc.getPanel(cwl='tempLayout') mc.deleteUI(killMe,pc=1)
def changeRowColumn(parent=None, panelname=None, *args): paneName = panelname + "CustomPane" if cmds.paneLayout(paneName, exists=True): cmds.deleteUI(paneName) cmds.paneLayout(paneName, parent=parent) if cmds.optionVar(q="customGraphEditorLayout") == "column": cmds.paneLayout(paneName, e=True, configuration="vertical2") else: cmds.paneLayout(paneName, e=True, configuration="horizontal2") if cmds.scriptedPanel(panelname, exists=True): cmds.deleteUI(panelname) cmds.scriptedPanel(panelname, parent=paneName, type="graphEditor") return paneName
def frameGraphEditor(centerCurrentTime=False): ''' If graph editor has focus, frame the selected or visible animation curves. ''' panel = mc.getPanel(up=True) if not panel: panel = mc.getPanel(withFocus=True) if not panel: return False panelType = mc.getPanel(to=panel) if panelType != 'scriptedPanel': return False scriptedType = mc.scriptedPanel(panel, query=True, type=True) if scriptedType != 'graphEditor': return False graphEditor = panel + 'GraphEd' keySel = utl.KeySelection() if keySel.selectedKeys(): pass elif keySel.visibleInGraphEditor(): pass if keySel.selected: times = keySel.getSortedKeyTimes() start = times[0] end = times[-1] else: keySel.frameRange() start = keySel._timeRangeStart end = keySel._timeRangeEnd values = sorted(keySel.keyframe(query=True, valueChange=True)) minValue = values[0] maxValue = values[-1] if start == end: start = start - 1 end = end + 1 if maxValue == minValue: minValue = minValue - 0.5 maxValue = maxValue + 0.5 #add a 10% padding timePadding = (end - start) / 10.0 valuePadding = (maxValue - minValue) / 10.0 mc.animView(graphEditor, startTime=start - timePadding, endTime=end + timePadding, minValue=minValue - valuePadding, maxValue=maxValue + valuePadding) if centerCurrentTime: mc.animCurveEditor(graphEditor, edit=True, lookAt='currentTime') return True
def isGraphEditorActive(): '''Returns a tuple of (graphEditorState, graphEditorPanel). GraphEditorState is true if the cursor is over the graph editor, and false if it is not, or if the cursor can not be queried. The graphEditorPanel will default to 'graphEditor1' if no graph editor is found under the mouse.''' # Find out if the graph editor is under cursor graphEditorActive = 0 panel = '' try: panel = cmd.getPanel(underPointer=True) except TypeError: # Maya is being bitchy again. Default to channelBox and warn # the user that Maya is a bitch. Yes, I've had this fail here # before. Maya told me underPointer needed to be passed a bool. # Well, I hate to tell you Maya, but True is a bool. panel = None om.MGlobal.displayWarning("Defaulting to channelBox because Maya doesn't know where your cursor is.") if panel and cmd.getPanel(typeOf=panel) == 'scriptedPanel': # I assume that testing for the type will be more accurate than matching the panel strings if cmd.scriptedPanel(panel, q=1, type=1) == 'graphEditor': graphEditorActive = 1 # A graph editor panel should always be passed, even if we couldn't find a specific one. if not graphEditorActive: panel = 'graphEditor1' return graphEditorActive, panel
def bakeKeys(objs, start, end, windowOff=1, smartBake=0, *args): # bake out all channels for selected objects. # first, switch to graph editor to speed up baking. if windowOff == 1: mel.eval('setNamedPanelLayout "Single Perspective View"') perspPane = cmds.getPanel(vis=1) cmds.scriptedPanel('graphEditor1', e=1, rp=perspPane[0]) # prevent file save after baking. cmds.file(rts=1) cmds.select(objs) start = float(start) end = float(end) cmds.bakeResults(simulation=1, smart=smartBake, cp=0, s=0, sb=1.0, t=(start, end))
def isGraphEditorVisible(panel='graphEditor1'): '''Determines if the provided graph editor panel is open by finding the associated window. Minimized graph editors are considered closed.''' if panel and cmd.getPanel(typeOf=panel) == 'scriptedPanel': # I assume that testing for the type will be more accurate than matching the panel strings if cmd.scriptedPanel(panel, q=1, type=1) == 'graphEditor': # Find full path to the panel window = cmd.scriptedPanel(panel, q=1, ctl=1) if window: # If the panel exists, derrive the window name from the full path window = window.split('|')[0] if cmd.window(window, q=1, vis=1) and not cmd.window(window, q=1, i=1): # If the panel is visible and not minimized. return True # graphEditor1Window # window -vis -i return False
def frameGraphEditor(centerCurrentTime=False): ''' If graph editor has focus, frame the selected or visible animation curves. ''' panel = mc.getPanel(up=True) if not panel: panel = mc.getPanel(withFocus=True) if not panel: return False panelType = mc.getPanel(to=panel) if panelType != 'scriptedPanel': return False scriptedType = mc.scriptedPanel(panel, query=True, type=True) if scriptedType != 'graphEditor': return False graphEditor = panel+'GraphEd' keySel = utl.KeySelection() if keySel.selectedKeys(): pass elif keySel.visibleInGraphEditor(): pass if keySel.selected: times = keySel.getSortedKeyTimes() start = times[0] end = times[-1] else: keySel.frameRange() start = keySel._timeRangeStart end = keySel._timeRangeEnd values = sorted(keySel.keyframe(query=True, valueChange=True)) minValue = values[0] maxValue = values[-1] if start == end: start = start-1 end = end+1 if maxValue == minValue: minValue = minValue-0.5 maxValue = maxValue+0.5 #add a 10% padding timePadding = (end-start)/10.0 valuePadding = (maxValue-minValue)/10.0 mc.animView(graphEditor, startTime=start-timePadding, endTime=end+timePadding, minValue=minValue-valuePadding, maxValue=maxValue+valuePadding) if centerCurrentTime: mc.animCurveEditor(graphEditor, edit=True, lookAt='currentTime') return True
def getRenderWindowPanel(): renderPanels = cmds.getPanel(scriptType="renderWindowPanel") if renderPanels == []: renderPanel = cmds.scriptedPanel(type="renderWindowPanel", unParent=True) #cmds.scriptedPanel(e=True, label=`interToUI $renderPanel` $renderPanel; else: renderPanel = renderPanels[0] return renderPanel
def popsimnodes(): nodes = selectsimnodes() nucleus = selectnucleus() cmds.select(nodes, nucleus) cmds.window(t='Sim Nodes') form = cmds.formLayout() p = cmds.scriptedPanel(type="nodeEditorPanel", label="Node Editor") cmds.formLayout(form, e=True, af=[(p, s, 0) for s in ("top", "bottom", "left", "right")]) cmds.showWindow() return 'node editor containing my sim nodes'
def initUI(self): self.setMinimumSize(200, 100) # self.resize(600,400) # layout self.setLayout(QtGui.QVBoxLayout()) self.layout().setSpacing(0) self.layout().setContentsMargins(2, 2, 2, 2) self.nodeEditor = cmds.scriptedPanel(type="nodeEditorPanel", label="Node Editor") pySideNodeEditor = utils.mayaWindowToPySideWidget(self.nodeEditor) self.layout().addWidget(pySideNodeEditor)
def getValidPanel(editor): """ This function checks the given editor to make sure it is an editor that we recognize. If it is not an known editor then we try to find an editor that will work. """ panel = cmds.modelEditor(editor, query=True, panel=True) ttype = cmds.getPanel(typeOf=panel) if ttype == 'scriptedPanel': stype = cmds.scriptedPanel(panel, query=True, type=True) if stype == 'Stereo': return editor # We don't recognize this panel type. Try to find one we like. # spanel = cmds.getPanel(scriptType='Stereo') if spanel and spanel[0]: cmds.scriptedPanel(spanel[0], edit=True, replacePanel=editor) return spanel[0] + "Editor" else: stereoCameraErrors.displayError('kNoValidPanelsFound')
def getRvStatus(): # has the renderview been opened already? if cmds.layout('editorForm', q=1, ex=1): ## is it in a window or in a panel?? rView = 'renderView' if rView in cmds.getPanel(vis=1): if cmds.panel(rView, q=1, to=1): # 'it is in a window!' cmds.deleteUI('renderViewWindow', wnd=1) else: #'is in a panel' rvv = cmds.getPanel(sty='renderWindowPanel') visibleModelPanels = [] camerasVisible = [] allCameras = [] possibleCams = [] for i in cmds.ls(ca=1): allCameras.append(cmds.listRelatives(i, p=1)[0]) for i in cmds.getPanel(vis=1): if i in cmds.getPanel(typ="modelPanel"): visibleModelPanels.append(i) for i in visibleModelPanels: camerasVisible.append(cmds.modelPanel(i, q=True, cam=True)) for i in allCameras: if i not in camerasVisible: possibleCams.append(i) if possibleCams >= 1: mel.eval('lookThroughModelPanel ' + str(possibleCams[0]) + ' ' + str(rvv[0]) + ';') #else: cmds.scriptedPanel('renderView', e=1, up=1) cmds.scriptedPanel('renderView', q=1, ctl=1) else: cmds.scriptedPanel('renderView', e=1, up=1) cmds.scriptedPanel('renderView', q=1, ctl=1) else: return False
def getValidEditor(panel): if panel: ttype = cmds.getPanel(typeOf=panel) if ttype == 'scriptedPanel': stype = cmds.scriptedPanel(panel, query=True, type=True) if stype == 'Stereo': return panel + 'Editor' # We don't recognize this panel type. Try to find one we like. # spanel = cmds.getPanel(scriptType='Stereo') if spanel and spanel[0]: return spanel[0] + "Editor" else: stereoCameraErrors.displayError('kNoValidPanelsFound') return None
def swapCameras(*args): """ Toggle the swap bit on the view. """ if not stereoCameraUtil.runCallbackChecks(): return if len(args): editor = args[0] cmds.stereoCameraView(editor, edit=True, swapEyes=True) else: panels = cmds.lsUI(panels=True) for panel in panels: ttype = cmds.getPanel(typeOf=panel) if ttype == 'scriptedPanel': stype = cmds.scriptedPanel(panel, query=True, type=True) if stype == 'Stereo': editor = panel + 'Editor' cmds.stereoCameraView(editor, edit=True, swapEyes=True)
def detect(cls, restrictToCursor=False, restrictToFocus=False, restrictToVisible=False): scriptedPanels = cmd.getPanel(type='scriptedPanel') or [] graphPanels = set(panel for panel in scriptedPanels if cmd.scriptedPanel(panel, query=True, type=True) == 'graphEditor') focusedPanel = cls._getPanelWithFocus() cursorPanel = cls._getPanelUnderCursor() if restrictToFocus: graphPanels = set([focusedPanel ]) if focusedPanel in graphPanels else set() if restrictToCursor: graphPanels = set([cursorPanel ]) if cursorPanel in graphPanels else set() if restrictToVisible: graphPanels = set(filter(cls._isPanelVisible, graphPanels)) graphPanel = None if len(graphPanels) == 1: graphPanel = graphPanels.pop() elif len(graphPanels) > 1: # Restrictions have not narrowed down a possibility # Magical preference order kicks in here. if focusedPanel in graphPanels: graphPanel = focusedPanel elif cursorPanel in graphPanels: graphPanel = cursorPanel else: visiblePanels = filter(cls._isPanelVisible, graphPanels) if visiblePanels: graphPanel = sorted(visiblePanels)[0] else: graphPanel = sorted(graphPanels)[0] return cls(graphPanel)
def _isPanelGraphEditor(panelName): return (panelName and cmd.getPanel(typeOf=panelName) == 'scriptedPanel' and cmd.scriptedPanel(panelName, query=1, type=1) == 'graphEditor')
def view_script_editor(direction="bottom", floating=False): """ Toggle the script output as a dock window to the given side of the viewport, if floating is true then toggle outliner to a floating window. makes sure to delete the dockControl UI when visibility is lost to ensure the name is available for maya. """ 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 create_script_output(): """ Create the dock window. """ if cmds.window(SCRIPT_OUTPUT_WINDOW, ex=True): main_win = SCRIPT_OUTPUT_WINDOW else: main_win = cmds.window(SCRIPT_OUTPUT_WINDOW, title="Output Window") cmds.paneLayout(parent=main_win) context_menu() cmds.dockControl( SCRIPT_OUTPUT_DOCK, content=main_win, label="Output Window", area=direction, # height=500, floating=False, allowedArea=["bottom"], ) # Constants SCRIPT_OUTPUT_WINDOW = "MAM_SCRIPT_OUTPUT_WINDOW" SCRIPT_OUTPUT_DOCK = "MAM_SCRIPT_OUTPUT_DOCK" SCRIPT_OUTPUT_SCROLLFIELD = "MAM_SCRIPT_OUTPUT_SCROLLFIELD" SCRIPT_EDITOR_WINDOW = "scriptEditorPanel1Window" SCRIPT_EDITOR_PANE = "scriptEditorPanel1" if not floating: if not cmds.dockControl(SCRIPT_OUTPUT_DOCK, ex=True): create_script_output() else: state = not (cmds.dockControl(SCRIPT_OUTPUT_DOCK, q=True, vis=True)) cmds.dockControl(SCRIPT_OUTPUT_DOCK, e=True, vis=state) elif floating: if cmds.window(SCRIPT_EDITOR_WINDOW, q=True, exists=True): cmds.deleteUI(SCRIPT_EDITOR_WINDOW, window=True) else: cmds.scriptedPanel(SCRIPT_EDITOR_PANE, e=True, tearOff=True)
def createUI(self): myWindow = cmds.window( self.windowName, h=800, w=1000, menuBar=True, s=True) mainLayout = cmds.formLayout(numberOfDivisions=100) selectionLayout = cmds.columnLayout(adj=True, h=45) cmds.text(label="Selection Constraint") self.selectionModeRadioButton = cmds.radioButtonGrp( labelArray4=['None', 'Shell', 'Border', 'Internal'], numberOfRadioButtons=4, select=1, cw4=[100, 100, 100, 100], on1=partial(self.changeSelectionConstraint, 1), on2=partial(self.changeSelectionConstraint, 2), on3=partial(self.changeSelectionConstraint, 3), on4=partial(self.changeSelectionConstraint, 4)) cmds.setParent('..') # selectionLayout shaderLayout = cmds.formLayout() uvRepeatSlider = cmds.attrFieldSliderGrp( label="Repeat", min=0.0, max=20.0, parent=shaderLayout) if cmds.objExists("uvShaderPlace2dTexture"): cmds.attrFieldSliderGrp( uvRepeatSlider, edit=True, at='uvShaderPlace2dTexture.repeatU') else: pass uvShaderButton = cmds.button( label="Create UV shader", command=partial( commands.createUVshader, self.uvTexturePath, uvRepeatSlider)) uvShaderAssignButton = cmds.button( label="Assgin UV shader", command=partial( commands.assignUVshader)) cmds.setParent('..') cmds.formLayout( shaderLayout, edit=True, attachForm=[ (uvShaderButton, 'top', 2), (uvShaderButton, 'left', 2), (uvShaderAssignButton, 'top', 2), (uvRepeatSlider, 'bottom', 2), (uvRepeatSlider, 'left', 2), (uvRepeatSlider, 'right', 2) ], attachControl=[(uvShaderAssignButton, 'left', 2, uvShaderButton)]) # ### LEFT LAYOUT #### leftLayout = cmds.columnLayout(adj=True, w=120) cmds.gridLayout(numberOfColumns=3, cellWidthHeight=(40, 40)) cmds.iconTextButton( image="%s/upLeft.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u -1 -v 1;')") cmds.iconTextButton( image="%s/up.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 0 -v 1;')") cmds.iconTextButton( image="%s/upRight.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 1 -v 1;')") cmds.iconTextButton( image="%s/left.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u -1 -v 0;')") cmds.iconTextButton() cmds.iconTextButton( image="%s/right.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 1 -v 0;')") cmds.iconTextButton( image="%s/bottomLeft.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u -1 -v -1;')") cmds.iconTextButton( image="%s/bottom.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 0 -v -1;')") cmds.iconTextButton( image="%s/bottomRight.png" % self.iconDir, commandRepeatable=True, command="mel.eval('polyEditUV -u 1 -v -1;')") cmds.setParent('..') # gridLayout cmds.button( label="UV Centric", command="cmds.UVCentricUVLinkingEditor()") cmds.button(label="UV Set Editor", command="cmds.UVSetEditor()") cmds.button( label="Transfer Attr", command=miUvUtils.transferAttributesOptions) cmds.separator(h=20) cmds.text(label="Transfer UVs") uvSpaceTransferRadioButton = cmds.radioButtonGrp( labelArray2=["World", "Comp"], numberOfRadioButtons=2, select=2, cw2=[60, 60]) cmds.button( label="TRANSFER UVs", command=partial( self.radioButtonCommand, uvSpaceTransferRadioButton, commands.transferUVs)) cmds.text(label="*Select source mesh \nfirst, then targets") cmds.separator(h=20) cmds.text(label="Symmetrize UVs") uvSymRadioButton = cmds.radioButtonGrp( labelArray3=["X", "Y", "Z"], numberOfRadioButtons=3, select=1, cw3=[40, 40, 40]) cmds.text(label="*Select target \nvertices") cmds.button( label="MIRROR UVs", command=partial( self.radioButtonCommand, uvSymRadioButton, commands.mirroringUVs)) cmds.separator(h=20) cmds.button( label="Fix UV radio", command=partial(commands.fixUVscale)) cmds.button( label="Copy UVs to map1", command=partial(commands.copyUVsToMap1)) cmds.button( label="Flip UVs by world", command=partial(commands.flipUVsByWorld)) cmds.button( label="Flip selected UVs", command=miUvUtils.flipUVs) cmds.button( label="Grid UVs", enable=False) cmds.button( label="Delete History", command="cmds.DeleteHistory()") cmds.separator(h=20) cmds.text(label="Repeat UVs") self.uMax = cmds.textField(h=25, text="type number of U here") cmds.button( label="UV horizontal repeat", enable=True, command=self.repeatUVs) cmds.separator(h=20) cmds.gridLayout(numberOfColumns=3, cellWidthHeight=(40, 40)) cmds.iconTextButton( image="polyPlanProj.png", imageOverlayLabel="___X", olc=[1, 1, 0], command="cmds.polyPlanarProjection(md='x', ibd=True, kir=True)", commandRepeatable=True) cmds.iconTextButton( image="polyPlanProj.png", imageOverlayLabel="___Y", olc=[1, 1, 0], command="cmds.polyPlanarProjection(md='y', ibd=True, kir=True)", commandRepeatable=True) cmds.iconTextButton( image="polyPlanProj.png", imageOverlayLabel="___Z", olc=[1, 1, 0], command="cmds.polyPlanarProjection(md='z', ibd=True, kir=True)", commandRepeatable=True) cmds.iconTextButton( image="polyCylProj.png", imageOverlayLabel="___X", olc=[1, 1, 0], command=( "cmds.polyProjection(ch=1, kir=True, " "type='cylindrical', ibd=True, sf=True, rx=90)"), commandRepeatable=True) cmds.iconTextButton( image="polyCylProj.png", imageOverlayLabel="___Y", olc=[1, 1, 0], command=( "cmds.polyProjection(ch=1, kir=True, " "type='cylindrical', ibd=True, sf=True, ry=90)"), commandRepeatable=True) cmds.iconTextButton( image="polyCylProj.png", imageOverlayLabel="___Z", olc=[1, 1, 0], command=( "cmds.polyProjection(ch=1, kir=True, " "type='cylindrical', ibd=True, sf=True, rz=90)"), commandRepeatable=True) cmds.iconTextButton( image="polyAutoProj.png", imageOverlayLabel="Auto", olc=[1, 1, 0], commandRepeatable=True, command="mel.eval('performPolyAutoProj 0;')") cmds.iconTextButton( image="polyAutoProj.png", imageOverlayLabel="Cam", olc=[1, 1, 0], commandRepeatable=True, command="cmds.polyProjection(type='planar', md='p')") cmds.setParent('..') # gridLayout cmds.setParent('..') # leftLayout # #### BOTTOM LAYOUT ##### bottomLayout = cmds.rowColumnLayout( numberOfColumns=6, h=45, columnWidth=[ (1, 500), (2, 40), (3, 60), (4, 60), (5, 60), (6, 60)]) cmds.text(label="QuickSnapShot", align="left") cmds.text(label="Browes", align="left") cmds.text(label="Size", align="left") cmds.text(label="Tile Num", align="left") cmds.text(label="format", align="left") cmds.text(label="") self.uvImagePath = cmds.textField(h=2) initialPath = os.path.join(self.homeDir, "testImage.tif") cmds.textField(self.uvImagePath, edit=True, text=initialPath) cmds.symbolButton( w=25, h=25, image="menuIconFile.png", command=self.browseDirectoryPath) self.uvImageResolution = cmds.optionMenuGrp(enable=True) cmds.menuItem(label="8k") cmds.menuItem(label="4k") cmds.menuItem(label="2k") cmds.menuItem(label="1k") cmds.menuItem(label="512") self.uvImageTileNumber = cmds.optionMenuGrp(h=25, enable=True) for i in range(100): tileNumber = "1" + str(i + 1).zfill(3) cmds.menuItem(label=tileNumber) self.uvImageFormat = cmds.optionMenuGrp(enable=True) cmds.menuItem(label="tif") cmds.menuItem(label="jpg") cmds.menuItem(label="iff") cmds.menuItem(label="sgi") cmds.menuItem(label="pic") cmds.menuItem(label="als") cmds.menuItem(label="gif") cmds.menuItem(label="rla") cmds.button( label="Export", h=30, command=self.takeUvSnapshot) cmds.setParent('..') # #### TEXTURE WINDOW LAYOUT ##### textureLayout = cmds.paneLayout(configuration='single') pane = cmds.paneLayout(configuration="vertical2") cmds.paneLayout(pane, e=True, paneSize=(1, 0, 0)) cmds.modelPanel(cam="perspShape", tearOff=False) cmds.setParent('..') cmds.setParent('..') cmds.setParent('..') # mainLayout # ## UNPARENT CURRENT UV TEXTURE EDITOR AND RE-PARENT TO MY EIDTOR ### texturePanel = cmds.getPanel(scriptType='polyTexturePlacementPanel')[0] cmds.scriptedPanel(texturePanel, edit=True, unParent=True) mel.eval("fillEmptyPanes;") cmds.scriptedPanel(texturePanel, edit=True, parent=pane) # FORM LAYOUT cmds.formLayout( mainLayout, e=True, attachForm=[ (selectionLayout, 'top', 2), (shaderLayout, 'top', 2), (shaderLayout, 'right', 2), (shaderLayout, 'right', 2), (leftLayout, 'left', 2), (leftLayout, 'top', 2), (leftLayout, 'bottom', 2), (textureLayout, 'left', 2), (textureLayout, 'top', 2), (textureLayout, 'right', 2), (textureLayout, 'bottom', 2), (bottomLayout, 'bottom', 2), (bottomLayout, 'left', 2)], attachControl=[ (selectionLayout, 'left', 2, leftLayout), (leftLayout, 'bottom', 2, bottomLayout), (shaderLayout, 'left', 2, selectionLayout), (textureLayout, 'top', 2, selectionLayout), (textureLayout, 'bottom', 2, bottomLayout), (textureLayout, 'left', 2, leftLayout)]) # SHOW WINDOW cmds.showWindow(myWindow)
def bakeNonskins(objects, *args): # bake objects to world space. # create a locator constrained to each object, bake the constraints, then unparent objects, constrain to locators, and bake. print 'RUNNING bakeNonskins' locators = [] constraints = [] for x in range(0, len(objects)): loc = cmds.spaceLocator()[0] locators.append(loc) pc = cmds.parentConstraint(objects[x], loc) sc = cmds.scaleConstraint(objects[x], loc) constraints.append(pc) constraints.append(sc) # bake locators. mel.eval('setNamedPanelLayout "Single Perspective View"') perspPane = cmds.getPanel(vis=1) cmds.scriptedPanel('graphEditor1', e=1, rp=perspPane[0]) start = cmds.playbackOptions(q=1, min=1) end = cmds.playbackOptions(q=1, max=1) cmds.select(locators) cmds.bakeResults(simulation=1, cp=0, s=0, sb=1.0, t=(start, end)) # now, parent objects to world space, then constrain them to the locators in order. # need to delete all channel information first. # in order to run CBdeleteConnection, we need to source a particular MEL. mel.eval('source channelBoxCommand.mel;') for c in constraints: cmds.delete(c) chans = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v'] objectsWorldSpace = [] for x in range(0, len(objects)): for ch in chans: melstr = 'CBdeleteConnection "' + objects[x] + '.' + ch + '";' mel.eval(melstr) # unlock channel, in case it's locked cmds.setAttr(objects[x] + '.' + ch, lock=0) # try to parent to world space. if this fails, it's already in world space. try: renamed = cmds.parent(objects[x], w=1)[0] objectsWorldSpace.append(renamed) except RuntimeError: objectsWorldSpace.append(objects[x]) # now apply constraints from the locator with the same index x. cmds.parentConstraint(locators[x], objectsWorldSpace[x]) cmds.scaleConstraint(locators[x], objectsWorldSpace[x]) # now bake out the constraints on objectsWorldSpace. cmds.select(objectsWorldSpace) cmds.bakeResults(simulation=1, cp=0, s=0, sb=1.0, t=(start, end)) for l in locators: cmds.delete(l) # now export objectsWorldSpace as FBX. mel.eval('FBXResetExport;') mel.eval('FBXExportCacheFile -v false;') mel.eval('FBXExportCameras -v true;') cacheDir = os.path.join(cmds.workspace(q=1, fn=1), 'data', 'FBX', os.path.splitext(cmds.file(q=1, sn=1, shn=1))[0], 'keyframes').replace('\\', '/') if not os.path.exists(cacheDir): os.makedirs(cacheDir) fbxFile = os.path.join( cacheDir, os.path.splitext(cmds.file(q=1, sn=1, shn=1))[0] + '_NONSKINS.fbx').replace('\\', '/') cmds.select(objectsWorldSpace) evalStr = 'FBXExport -f "' + fbxFile + '" -s' mel.eval(evalStr) print 'Exported non-skins to %s' % (fbxFile)
def closeEvent(self, e): if cmds.paneLayout(self.paneName, ex=True): cmds.deleteUI(self.paneName) if cmds.scriptedPanel(self.panelname, ex=True): cmds.deleteUI(self.panelname)
#When Light Linker is expanded window gets larger def llExpand(*args): currentHeight = cmds.window(window, query = True, height = True) llHeight = 300 #want Light Linker to have height of 300 px newHeight = currentHeight + llHeight cmds.window(window, e = True, height = newHeight) # Make the window if cmds.window("LL_ui_window", exists=True): #If the window exists cmds.deleteUI("LL_ui_window") #Delete it window = cmds.window("LL_ui_window", title="Light Linker") cmds.frameLayout(p="LL_ui_window", lv= False) cmds.frameLayout("options_ui_frameLayout", p="LL_ui_window", label ="Options", cll = True, cl = False, collapseCommand = optionsCollapse, expandCommand = optionsExpand) cmds.columnLayout(adjustableColumn=True, rowSpacing=20) cmds.button (label = "Delink Everything", command = delinkEverything) cmds.button (label = "Link Everything", command = linkEverything) cmds.button (label = "Delink Selected Objects from all lights", command = delinkSelObj) cmds.button (label = "Link Selected Objects to all lights", command = linkSelObj) cmds.button (label = "Delink Everything from Selected Lights", command = delinkSelLight) cmds.button (label = "Link Everything to Selected Lights", command = linkSelLight) cmds.button (label = "Delink Selected Objects from Selected Lights", command = delinkSel) cmds.button (label = "Link Selected Objects to Selected Lights", command = linkSel) # Embed Light Linker cmds.frameLayout("LL_ui_frameLayout", p="LL_ui_window", label="Light Linking Editor", cll = True, cl = True, collapseCommand = llCollapse, expandCommand = llExpand) if cmds.scriptedPanel("LL_ui_scriptedPanel", exists=True): #If the scriptel panel already exists cmds.deleteUI("LL_ui_scriptedPanel") #Delete it cmds.scriptedPanel("LL_ui_scriptedPanel", unParent=True, type="relationshipPanel") cmds.scriptedPanel( "LL_ui_scriptedPanel", e=True, parent="LL_ui_frameLayout") #parent the scripted panel to your frame layout cmds.window(window, e=True, height = 380) #Want the window to open at this height cmds.showWindow(window)
def toggleNodeEditor(): if cmds.window('nodeEditorPanel1Window', ex=1): cmds.deleteUI('nodeEditorPanel1Window') else: cmds.scriptedPanel("nodeEditorPanel1", e=1, to=1)
def toggleHyperGraph(): if cmds.window('hyperGraphPanel1Window', ex=1): cmds.deleteUI('hyperGraphPanel1Window') else: cmds.scriptedPanel("hyperGraphPanel1", e=1, to=1)
icb='sampleInitCallback', \ acb='sampleAddCallback', \ rcb='sampleRemoveCallback', \ dcb='sampleDeleteCallback', \ scb='sampleSaveStateCallback', \ unique=True ) # This script will create an unparented scripted panel, place it # in one window, remove it, and place it in another window then # return it to the first window. # # # Create unparented scripted panel # cmds.scriptedPanel( 'sampleScriptedPanel', unParent=True, type='sampleScriptedPanelType', label='Sample' ) # Create a couple of windows and parent the scripted panel to the first. # cmds.window( 'sampleWin' ) cmds.frameLayout( 'frm', lv=False, bv=False ) cmds.scriptedPanel( 'sampleScriptedPanel', e=True, parent='sampleWin|frm' ) cmds.showWindow() cmds.window( 'sampleWin2', w=cmds.window('sampleWin', q=True, w=True), h=cmds.window('sampleWin', q=True, h=True) ) cmds.frameLayout( 'frm', lv=False, bv=False ) cmds.showWindow() # Reparent the scripted panel to the second window. # cmds.scriptedPanel( 'sampleScriptedPanel', e=True, unParent=True )
def test(): #################### # # # CleanUp # # # #################### if cmds.window(WINDOW_NAME, exists=True): cmds.deleteUI(WINDOW_NAME) for pan in cmds.lsUI(panels=True): if cmds.panel(pan, q=True, label=True).startswith("vuRenderTree_"): print "Delte: " + pan cmds.deleteUI(pan, panel=True) cmds.window(WINDOW_NAME) main = cmds.paneLayout(configuration='vertical3') #################### # # # Frame Left # # # #################### paneLeft = cmds.paneLayout(configuration='horizontal2', p=main) cmds.frameLayout(label="ShadingNodes:", li=3, borderVisible=False, p=paneLeft) cmds.nodeTreeLister('theTreeLister', expandToDepth=1, addItem=shaders) # Textures cmds.frameLayout(label="Textures:", li=3, borderVisible=False, p=paneLeft) panel = cmds.outlinerPanel(label="vuRenderTree_Outliner", menuBarVisible=False) outlinerEditor = cmds.outlinerPanel(panel, query=True,outlinerEditor=True) filterTextures = cmds.createNode("objectRenderFilter") cmds.setAttr(filterTextures + ".textures", True) cmds.outlinerEditor( outlinerEditor, edit=True, showDagOnly=False, filter=filterTextures) # # ToDo Later: # ######################################################################### # # # # # filterKeyable = cmds.createNode("objectAttrFilter") # # cmds.setAttr(filterKeyable + ".attrType ", 3) # # # # # ######################################################################### # # # #################### # # # Node Editor # # # #################### # formNodes = cmds.formLayout(p=main) # nEdit = cmds.scriptedPanel(type="nodeEditorPanel", label="Node Editor") # #cmds.formLayout(formNodes, e=True, af=[(centershelf,s,0) for s in ("top","left","right")]) # cmds.formLayout(formNodes, e=True, af=[(nEdit,s,0) for s in ("top", "bottom","left","right")]) formNodes = cmds.formLayout(p=main) nEdit = cmds.scriptedPanel(type="nodeEditorPanel", label="vuRenderTree_NodeEditor") centershelf = cmds.shelfLayout("vuRenderUtils", p=formNodes) #cmds.formLayout(formNodes, e=True, af=[(centershelf,s,0) for s in ("top","left","right")]) #cmds.formLayout(formNodes, e=True, af=[(nEdit,s,0) for s in ("bottom","left","right")]) cmds.formLayout(formNodes, e=True, attachForm=[ (centershelf,"top",0), (centershelf,"left",0), (centershelf,"right",0), (nEdit,"bottom",0), (nEdit,"left",0), (nEdit,"right",0) ], attachControl=[ (nEdit, "top", 0, centershelf) ]) #################### # # # Frame Right # # # #################### paneRight = cmds.paneLayout( configuration='horizontal3', p=main) # Shading Groups #rightTabs = cmds.tabLayout() cmds.frameLayout(label="ShadingGroups:", li=3, borderVisible=False, p=paneRight) outlinerShadingGroups = cmds.outlinerPanel(label="vuRenderTree_Outliner", menuBarVisible=False) outlinerEditor = cmds.outlinerPanel(outlinerShadingGroups, query=True,outlinerEditor=True) filterShadingGroups = cmds.createNode("objectTypeFilter") cmds.setAttr(filterShadingGroups + ".typeName", "shadingEngine", type="string") cmds.outlinerEditor( outlinerEditor, edit=True, showDagOnly=False, filter=filterShadingGroups) # Shaders cmds.frameLayout(label="Shaders:", li=3, borderVisible=False, p=paneRight) outlinerShaders = cmds.outlinerPanel(label="vuRenderTree_Outliner", menuBarVisible=False) outlinerEditor = cmds.outlinerPanel(outlinerShaders, query=True,outlinerEditor=True) filterShaders = cmds.createNode("objectRenderFilter") cmds.setAttr(filterShaders + ".shaders", True) cmds.outlinerEditor( outlinerEditor, edit=True, showDagOnly=False, filter=filterShaders) #cmds.tabLayout( rightTabs, edit=True, tabLabel=((outlinerShadingGroups, 'ShadingGroups'), (outlinerShaders, 'Shaders'))) # Outliner cmds.frameLayout(label="Outliner:", li=3, borderVisible=False, p=paneRight) cmds.outlinerPanel(label="vuRenderTree_Outliner", menuBarVisible=True) cmds.showWindow()
def forceHideRenderView(state=None, renderViewWindow="renderViewWindow", renderView="renderView", min_size=(999999, 999999), label="CLICK HERE TO KILL HIDE RENDER VIEW"): """ Hides the renderView in a dock control. This (force) hides the renderView in a dockControl in the right area of you Main Window. By doing that the renderView doesn't pop-up when you use the V-ray Framebuffer, sweet! HOW TO DISABLE: To disable just run this again with state=None (toggles), or force it by state=False. You could also right mouse click on the draggable part of that dockControl area, (which is normally the attribute editor / channel box area) and then click on the label: "CLICK HERE TO KILL HIDE RENDER VIEW" Note: This hack might spit out the following errors: // Error: line 1: No window found. // Yet as far as I know it's never doing any harm. A workaround for that error is depicted here: http://polygonspixelsandpaint.tumblr.com/post/68136553566 -- warning -- The code snippet on that website seems to be problematic under Windows, as it resizes the main window even with Auto Resize set to False. (tested on Maya 2014 ext 1, Windows 7 64 bit) This function has a work-around for that. Though the work-around should work similarly. :) :param state: The state to enable/disable the forceHideRenderView functionality. A True value will enable the hiding functionality A False value will disable the hiding functionality. A None value will toggle the hiding functionality. :type state: bool or None :param renderViewWindow: The name of the renderView window object to act upon. The maya default renderView window object is called: "renderViewWindow". This is the default value; normally this requires no changes. :type renderViewWindow: str :param renderView: The name of the renderView object to act upon. The maya default renderView object is called: "renderView". This is the default value; normally this requires no changes. :type renderViewWindow: str :param min_size: The minimum size enforced for the controls. Setting this very high avoids the main window being resized when rendering high resolution images. (A workaround for stupid Autodesk UI functionality.) :type min_size: (int, int) :param label: The label that will show in the dock control right menu as a label. :type label: str :rtype: bool :return: The resulting state """ UI_OBJ = "rendEditorDC" if state is None: state = not mc.dockControl(UI_OBJ, q=1, exists=True) if mc.dockControl(UI_OBJ, q=1, exists=True): mc.deleteUI(UI_OBJ) if state: # Show the render view so we can parent it to our dock control if not mc.window(renderViewWindow, q=1, exists=True): mc.RenderViewWindow() # Uses either the minimum size or the size of the render settings + 250 (just to be sure) size = [max(x, y+250) for x, y in zip(min_size, getRenderSize())] def __deleteRenderViewHideDockControl(*args): # If it's made visible we hide it and delete it. # We use executeDeferred because otherwise we'll get a fatal error. :) if mc.dockControl(UI_OBJ, q=1, visible=True): mc.dockControl(UI_OBJ, e=1, visible=False) mutils.executeDeferred(lambda: mc.deleteUI(UI_OBJ)) if not mc.dockControl(UI_OBJ, q=1, exists=True): lyt = mc.scrollLayout() dock = mc.dockControl(UI_OBJ, area="right", content=renderViewWindow, visible=False, epo=True, manage=False, vcc=__deleteRenderViewHideDockControl, label=label) # This is the same control the renderWindowPanel.mel script checks for the size . # We just need to make it big enough so it doesn't call a resize of the top UI element. renderWindowControl = mc.scriptedPanel(renderView, q=True, control=True) mc.control(renderWindowControl, e=1, w=size[0], h=size[1], visible=False) print "ENABLED HIDE RENDER VIEW" else: print "DISABLED HIDE RENDER VIEW"
def mk_view(name, values): mw = QMainWindow(getMayaWindow()) mw.setObjectName(name) # clean renderview controls cmds.optionVar(iv=('renderViewDisplayToolbar', 0)) cmds.scriptedPanel(renderViews, e=True, mbv=0) cmds.renderWindowEditor(renderViews, e=1, cap=0) cmds.renderWindowEditor(renderViews, e=1, rs=1) form = cmds.formLayout('ViewportRenderForm') pane = cmds.paneLayout(configuration='single', bgc=(0.1, 0.1, 0.1)) cmds.formLayout(form, e=1, af=[(pane, 'top', 1), (pane, 'left', 1), (pane, 'right', 1), (pane, 'bottom', 1)]) cmds.scriptedPanel(renderViews[0], e=1, p=pane) closeBtn = cmds.button('myClosebtn', label="x", w=20, h=20, p=form, c=dropTool, ebg=0, bgc=(0, 0, 0)) bReRender = cmds.button('bReRender', label="r", w=20, h=20, p=form, c=reRender) iprR = cmds.button('iprR', label="ir", w=20, h=20, p=form, c=iprRender) cmds.formLayout(form, e=True, af=[(closeBtn, 'top', 5), (closeBtn, 'left', 5)]) cmds.formLayout(form, e=True, af=[(bReRender, 'top', 5), (bReRender, 'left', 30)]) cmds.formLayout(form, e=True, af=[(iprR, 'top', 5), (iprR, 'left', 55)]) cmds.formLayout(form, e=True, af=[(closeBtn, 'top', 5), (closeBtn, 'left', 5)]) panel = getPanelAttach(form) mw.setCentralWidget(panel) mw.setWindowTitle(name) #mw.setWindowFlags(QtCore.Qt.Tool|QtCore.Qt.FramelessWindowHint) leftW = marLeft + values[0] topW = marTop + (formY - values[1]) resoX = values[2] - values[0] resoY = values[1] - values[3] mw.setGeometry(leftW, topW, resoX, resoY) mw.update() return mw
def isValid(self): return bool(self.panelName) and cmd.scriptedPanel( self.panelName, query=True, exists=True)
def custom_graph_editor(*args): invis_panel = cmds.getPanel(invisiblePanels=True) graphpanels = cmds.getPanel(scriptType='graphEditor') graphpanels.remove('graphEditor1') for o_graphp in graphpanels: if o_graphp in invis_panel: cmds.deleteUI(o_graphp, panel=True) grp_panel_no_a = str(len(cmds.getPanel(scriptType='graphEditor')) + 1) if cmds.window('custom_graphEditor' + grp_panel_no_a, exists=True): n_graphpanels = cmds.getPanel(scriptType='graphEditor') biggest_p = 1 for o_panel in n_graphpanels: if int(o_panel[len('graphEditor'):]) > biggest_p: biggest_p = int(o_panel[len('graphEditor'):]) grp_panel_no_a = str(biggest_p + 1) try: win1 = cmds.window('custom_graphEditor' + grp_panel_no_a, title='New CustomGraphEditor' + grp_panel_no_a, resizeToFitChildren=True, widthHeight=(1100, 450)) except: grp_panel_no_a = str(int(grp_panel_no_a) + 1) win1 = cmds.window('custom_graphEditor' + grp_panel_no_a, title='New CustomGraphEditor' + grp_panel_no_a, resizeToFitChildren=True, widthHeight=(1100, 450)) pane1 = cmds.paneLayout(configuration='horizontal2', paneSize=[2, 1, 1], parent=win1) graphmenu = 'graphEditor' + grp_panel_no_a cmds.scriptedPanel(graphmenu, label=graphmenu, type='graphEditor', parent=pane1) cmds.setParent('..') current_minimum_frame = cmds.playbackOptions(query=True, minTime=True) current_maxmum_frame = cmds.playbackOptions(query=True, maxTime=True) outline_ed_name = "graphEditor" + grp_panel_no_a + 'OutlineEd' mel.eval('string $outlineed_name = "%s"' % outline_ed_name) graph_ed_name = "graphEditor" + grp_panel_no_a + 'GraphEd' mel.eval('string $o_graph_ed_name = "%s"' % graph_ed_name) mel.eval('animCurveEditor -edit -displayInfinities true $o_graph_ed_name;') mel.eval('filterUISelectAttributesCheckbox translateX 0 $outlineed_name;') mel.eval('filterUISelectAttributesCheckbox translateY 0 $outlineed_name;') mel.eval('filterUISelectAttributesCheckbox translateZ 0 $outlineed_name;') mel.eval('filterUISelectAttributesCheckbox rotateX 0 $outlineed_name;') mel.eval('filterUISelectAttributesCheckbox rotateY 0 $outlineed_name;') mel.eval('filterUISelectAttributesCheckbox rotateZ 0 $outlineed_name;') mel.eval('filterUISelectAttributesCheckbox scaleX 0 $outlineed_name;') mel.eval('filterUISelectAttributesCheckbox scaleY 0 $outlineed_name;') mel.eval('filterUISelectAttributesCheckbox scaleZ 0 $outlineed_name;') mel.eval('filterUISelectAttributesCheckbox visibility 0 $outlineed_name;') cmds.columnLayout(adjustableColumn=True) cmds.rowLayout(numberOfColumns=19, adjustableColumn=19) cmds.text('t') cmds.button('b_c_tx' + grp_panel_no_a, label='X', bgc=[0.3, 0.0, 0.0], annotation='TranslateX', command=select_curve_tx, dragCallback=filter_tx, dropCallback=filter_tx2) cmds.button('b_c_ty' + grp_panel_no_a, label='Y', bgc=[0.0, 0.3, 0.0], annotation='TranslateY', command=select_curve_ty, dragCallback=filter_ty, dropCallback=filter_ty2) cmds.button('b_c_tz' + grp_panel_no_a, label='Z', bgc=[0.0, 0.0, 0.3], annotation='TranslateZ', command=select_curve_tz, dragCallback=filter_tz, dropCallback=filter_tz2) cmds.text(' r') cmds.button('b_c_rx' + grp_panel_no_a, label='X', bgc=[0.3, 0.0, 0.0], annotation='RotateX', command=select_curve_rx, dragCallback=filter_rx, dropCallback=filter_rx2) cmds.button('b_c_ry' + grp_panel_no_a, label='Y', bgc=[0.0, 0.3, 0.0], annotation='RotateY', command=select_curve_ry, dragCallback=filter_ry, dropCallback=filter_ry2) cmds.button('b_c_rz' + grp_panel_no_a, label='Z', bgc=[0.0, 0.0, 0.3], annotation='RotateZ', command=select_curve_rz, dragCallback=filter_rz, dropCallback=filter_rz2) cmds.text(' s') cmds.button('b_c_sx' + grp_panel_no_a, label='X', bgc=[0.3, 0.0, 0.0], annotation='ScaleX', command=select_curve_sx, dragCallback=filter_sx, dropCallback=filter_sx2) cmds.button('b_c_sy' + grp_panel_no_a, label='Y', bgc=[0.0, 0.3, 0.0], annotation='ScaleY', command=select_curve_sy, dragCallback=filter_sy, dropCallback=filter_sy2) cmds.button('b_c_sz' + grp_panel_no_a, label='Z', bgc=[0.0, 0.0, 0.3], annotation='ScaleZ', command=select_curve_sz, dragCallback=filter_sz, dropCallback=filter_sz2) cmds.text(' ') cmds.button('b_c_v' + grp_panel_no_a, label='V', bgc=[0.3, 0.3, 0.3], annotation='Visibility', command=select_curve_v, dragCallback=filter_v, dropCallback=filter_v2) cmds.text(' ') cmds.symbolButton('time_prev' + grp_panel_no_a, image='timeprev.xpm', command=o_prev_cmd, dragCallback=o_key_prev_cmd, dropCallback=o_key_prev_cmd2) cmds.symbolButton('time_next' + grp_panel_no_a, image='timenext.xpm', command=o_next_cmd, dragCallback=o_key_next_cmd, dropCallback=o_key_next_cmd2) cmds.text(' ') cmds.timePort(enableBackground=True, bgc=[0.2, 0.2, 0.2], width=500, height=20) cmds.setParent('..') cmds.rowLayout(numberOfColumns=16) cmds.text(' ') cmds.button('mirror' + grp_panel_no_a, label='Mirror', command=mirror_x, dragCallback=mirror_y, dropCallback=mirror_y2) cmds.button('Cycle_ON' + grp_panel_no_a, label='Cycle_ON', command=Cycle_On) cmds.button('Cycle_OFF' + grp_panel_no_a, label='Cycle_OFF', command=Cycle_Off) cmds.text(' ') cmds.button('Retime' + grp_panel_no_a, label='Retime', command=RetimeHelper) cmds.button('Out_l' + grp_panel_no_a, label='Outliner', command="mel.eval('OutlinerWindow;')") cmds.optionMenu(label='Speed', changeCommand=SetSpeed) cmds.menuItem(label='realtime') cmds.menuItem(label='2x') cmds.menuItem(label='1/2x') cmds.text(' ') cmds.symbolButton('time_rew' + grp_panel_no_a, image='timerew.xpm', command="mel.eval('playButtonStart;')") cmds.symbolButton('step_backward' + grp_panel_no_a, image='timeend.xpm', command=lambda x: step_backward(grp_panel_no_a)) cmds.symbolButton('play_forward' + grp_panel_no_a, image='timeplay.xpm', command=lambda x: play_forward(grp_panel_no_a)) cmds.symbolButton('step_forward' + grp_panel_no_a, image='timestart.xpm', command=lambda x: step_forward(grp_panel_no_a)) cmds.symbolButton('time_fwd' + grp_panel_no_a, image='timefwd.xpm', command="mel.eval('playButtonEnd;')") cmds.showWindow()
def forceHideRenderView(state=None, renderViewWindow="renderViewWindow", renderView="renderView", min_size=(999999, 999999), label="CLICK HERE TO KILL HIDE RENDER VIEW"): """ Hides the renderView in a dock control. This (force) hides the renderView in a dockControl in the right area of you Main Window. By doing that the renderView doesn't pop-up when you use the V-ray Framebuffer, sweet! HOW TO DISABLE: To disable just run this again with state=None (toggles), or force it by state=False. You could also right mouse click on the draggable part of that dockControl area, (which is normally the attribute editor / channel box area) and then click on the label: "CLICK HERE TO KILL HIDE RENDER VIEW" Note: This hack might spit out the following errors: // Error: line 1: No window found. // Yet as far as I know it's never doing any harm. A workaround for that error is depicted here: http://polygonspixelsandpaint.tumblr.com/post/68136553566 -- warning -- The code snippet on that website seems to be problematic under Windows, as it resizes the main window even with Auto Resize set to False. (tested on Maya 2014 ext 1, Windows 7 64 bit) This function has a work-around for that. Though the work-around should work similarly. :) :param state: The state to enable/disable the forceHideRenderView functionality. A True value will enable the hiding functionality A False value will disable the hiding functionality. A None value will toggle the hiding functionality. :type state: bool or None :param renderViewWindow: The name of the renderView window object to act upon. The maya default renderView window object is called: "renderViewWindow". This is the default value; normally this requires no changes. :type renderViewWindow: str :param renderView: The name of the renderView object to act upon. The maya default renderView object is called: "renderView". This is the default value; normally this requires no changes. :type renderViewWindow: str :param min_size: The minimum size enforced for the controls. Setting this very high avoids the main window being resized when rendering high resolution images. (A workaround for stupid Autodesk UI functionality.) :type min_size: (int, int) :param label: The label that will show in the dock control right menu as a label. :type label: str :rtype: bool :return: The resulting state """ UI_OBJ = "rendEditorDC" if state is None: state = not mc.dockControl(UI_OBJ, q=1, exists=True) if mc.dockControl(UI_OBJ, q=1, exists=True): mc.deleteUI(UI_OBJ) if state: # Show the render view so we can parent it to our dock control if not mc.window(renderViewWindow, q=1, exists=True): mc.RenderViewWindow() # Uses either the minimum size or the size of the render settings + 250 (just to be sure) size = [max(x, y + 250) for x, y in zip(min_size, getRenderSize())] def __deleteRenderViewHideDockControl(*args): # If it's made visible we hide it and delete it. # We use executeDeferred because otherwise we'll get a fatal error. :) if mc.dockControl(UI_OBJ, q=1, visible=True): mc.dockControl(UI_OBJ, e=1, visible=False) mutils.executeDeferred(lambda: mc.deleteUI(UI_OBJ)) if not mc.dockControl(UI_OBJ, q=1, exists=True): lyt = mc.scrollLayout() dock = mc.dockControl(UI_OBJ, area="right", content=renderViewWindow, visible=False, epo=True, manage=False, vcc=__deleteRenderViewHideDockControl, label=label) # This is the same control the renderWindowPanel.mel script checks for the size . # We just need to make it big enough so it doesn't call a resize of the top UI element. renderWindowControl = mc.scriptedPanel(renderView, q=True, control=True) mc.control(renderWindowControl, e=1, w=size[0], h=size[1], visible=False) print "ENABLED HIDE RENDER VIEW" else: print "DISABLED HIDE RENDER VIEW"