def create_temp_panel(self): # create panel for playblast self.viewport = pm.modelPanel(tearOff=True) pm.setFocus(self.viewport) pm.control(self.viewport, edit=True, w=self.output_dimentions[0]) pm.control(self.viewport, edit=True, h=self.output_dimentions[1]) pm.lookThru(self.current_camera)
def lcBake_convert_lightmap(bakeSetListDropdown, cameraListDropdown, *args, **kwargs): ''' ''' global lct_cfg global prefix global defaultString global defaultPath sel = pm.ls(sl=True) numItems = bakeSetListDropdown.getNumberOfItems() if numItems > 0: currentBakeSet = bakeSetListDropdown.getValue() if currentBakeSet != defaultString: currentCamera = cameraListDropdown.getValue() outputDirectory = pm.textField(prefix + '_textField_texture_path', query=True, text=True) if os.path.exists(outputDirectory) or pm.PyNode( currentBakeSet).nodeType() == 'vertexBakeSet': shadows = pm.checkBox(prefix + '_checkBox_shadows', query=True, value=True) if pm.control('bakeWindow', exists=True): pm.deleteUI('bakeWindow') bakeWindow = pm.window('bakeWindow', t='Batch Bake', widthHeight=[100, 100], rtf=True, mnb=False, mxb=False, s=False) pm.columnLayout() pm.text(l='') pm.text(l='') pm.text(l=' Bake In Progress ') pm.text(l=' ...... ') pm.text(l='') pm.text(l='') bakeWindow.show() pm.refresh() if pm.PyNode(currentBakeSet).nodeType() == 'vertexBakeSet': outputDirectory = 'None' convertString = lcBake.Bake.convertLightmap( currentBakeSet, currentCamera, outputDirectory, shadows) sys.stdout.write('Convert Command: {0}'.format(convertString)) pm.deleteUI('bakeWindow') pm.select(sel, replace=True) else: pm.warning('Path not found: {0}'.format(outputDirectory)) pm.setFocus(prefix + '_textField_texture_path')
def create_window(self): """Create a custom window with related modelEditor, as well as running the pre- and post-window methods. Returns: bool: Success of the window, modelEditor, and pre- and post- window methods. """ w_success = False # call various pre-window methods cam_check = self.set_camera() if cam_check: self.set_imageplanes_colorspace() self.set_vp2_globals() try: # create window (clean up first) self.destroy_window() window = pm.window(PLAYBLAST_WINDOW, titleBar=True, iconify=True, leftEdge=100, topEdge=100, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT, sizeable=False) # create window model editor layout = pm.formLayout() editor = pm.modelEditor(**MODEL_EDITOR_PARAMS) pm.setFocus(editor) pm.formLayout(layout, edit=True, attachForm=((editor, "left", 0), (editor, "top", 0), (editor, "right", 0), (editor, "bottom", 0))) # show window pm.setFocus(editor) pm.showWindow(window) pm.refresh() # call various post-window methods self.generate_all_uv_tile_previews() # success! w_success = True except Exception as e: m = '>> Failed to create playblast window > {}'.format(str(e)) self.logger.info(m) return w_success
def createWindow(): """ try to get data from shotgun project fields need to get context's project context's shotgun instance """ app = self.parent project = app.context.project sg = app.context.tank.shotgun # set filters and search fields for entity type "Project" filters=[["id", "is", project['id']],] fields=["sg_width", "sg_height"] result=sg.find_one("Project", filters, fields) # with result, set parameters accordingly or use default otherwise if result: videoWidth = result.get("sg_width", DEFAULT_WIDTH) videoHeight = result.get("sg_height", DEFAULT_HEIGHT) # Find first camera matching pattern and set as active camera # if not use default current active camera camera_name_pattern = app.get_setting( "camera_name_pattern", "persp" ) cameraList = [c.name() for c in pm.ls(type="camera", r=True) if re.search( camera_name_pattern, c.name() )] if not "cam" in MODEL_EDITOR_PARAMS.keys() and cameraList: MODEL_EDITOR_PARAMS["cam"] = cameraList[0] # Give Viewport 2.0 renderer only for Maya 2015++ # mayaVersionString = cmds.about(version=True) # mayaVersion = int(mayaVersionString[:4]) if len(mayaVersionString) >= 4 else 0 # if mayaVersion >= 2015: # params[ "rendererName" ] = "vp2Renderer" # Create window if pm.windowPref( PLAYBLAST_WINDOW, exists=True ): pm.windowPref( PLAYBLAST_WINDOW, remove=True ) window = pm.window( PLAYBLAST_WINDOW, titleBar=True, iconify=True, leftEdge = 100, topEdge = 100, width = videoWidth, height = videoHeight, sizeable = False) # Create editor area layout = pm.formLayout() editor = pm.modelEditor( **MODEL_EDITOR_PARAMS ) pm.setFocus( editor ) pm.formLayout( layout, edit=True, attachForm = ( ( editor, "left", 0 ), ( editor, "top", 0 ), ( editor, "right", 0 ), ( editor, "bottom", 0 ) ) ) # Show window pm.setFocus( editor ) pm.showWindow( window ) pm.refresh() try: yield True except: traceback.print_exc() finally: pm.deleteUI(window)
def bdSetCamera(camera,referenceCam): if referenceCam: pm.createReference(referenceCam,namespace="CAM") camera = pm.ls('CAM:*',type='camera')[0] perspModel = "".join(pm.getPanel(withLabel = 'Persp View')) pm.setFocus(perspModel) perspView = pm.getPanel(wf=1) pm.lookThru(perspView,camera) #pm.modelPanel (perspView, query=1,label=1) pm.modelEditor(perspView,e=1,alo=0) pm.modelEditor(perspView,e=1,polymeshes=1,grid=0) pm.modelEditor(perspView,e=1,displayAppearance='smoothShaded',displayTextures=1) perspCam = pm.ls('persp',type='transform')[0]
def bdSetCameraVP2(cam): pm.createReference("P:/smurfs/working_project/cameras/worldcup_cam.ma",ns='cam') pm.mel.eval('setNamedPanelLayout \"Single Perspective View\"'); perspModel = "".join(pm.getPanel(withLabel = 'Persp View')) pm.setFocus(perspModel) perspView = pm.getPanel(wf=1) pm.lookThru(perspView,cam) #pm.modelPanel (perspView, query=1,label=1) pm.modelEditor(perspView,e=1,alo=0) pm.modelEditor(perspView,e=1,polymeshes=1,imagePlane=1,grid=0) pm.modelEditor(perspView,e=1,displayAppearance='smoothShaded',displayTextures=1,wireframeOnShaded=0) consolidate = pm.mel.eval('checkMemoryForConsolidatedWorld()') if consolidate: pm.modelEditor(perspView,e=1,rnm="vp2Renderer",rom='')
def create_screenshot_layout(editor_, title_): """Creates a pymel window with the editor passed as an argument. Args: editor_: string defining the pymel.windows function to call title_: title of the widget Returns: Pymel Window UI: The layout window to take a screenshot of """ layout_window = pm.window(title_) pm.frameLayout(title_) pm.mel.eval(editor_ + '()') pm.showWindow() layout_window.asQtObject().showMaximized() pm.setFocus(layout_window) return layout_window
def do_playblast(self): self.do_backup() pm.setFocus(self.viewport) data = dict(filename=self.playblast_path, widthHeight=self.output_dimentions, forceOverwrite=True, format='qt', quality=100, percent=100, compression='H.264', clearCache=True, showOrnaments=True, offScreen=True) pm.playblast(**data) if pm.modelPanel(self.viewport, exists=True): cmds.deleteUI(self.viewport, panel=True) self.close()
def build(self): #splineIK UI self.win = pm.window(self.title, title=self.title) self.layout = pm.rowColumnLayout() self.control_scheme_options = ['fk', 'ik', '...something else'] self.tf_obj_start = self._build_name_input(label='Load Start Object', parent=self.layout) self.tf_obj_end = self._build_name_input(label='Load End Object', parent=self.layout) self.tf_obj_aim = self._build_name_input(label='Load Aim Object', parent=self.layout) self.tf_obj_parent = self._build_name_input(label='Load Parent Transform', parent=self.layout) self.slider_joints = pm.intSliderGrp(enable=True, field=True, label='number of joints', minValue=3, fieldMinValue=3, fieldMaxValue=50, value=5, parent=self.layout) self.slider_controls = pm.intSliderGrp(enable=True, field=True, label='number of controls', minValue=3, fieldMinValue=2, fieldMaxValue=20, value=3, parent=self.layout) self.tfg_ribbon_name = pm.textFieldGrp(enable=True, label='ribbon', placeholderText='name of ribbon', editable=True, tcc=self._on_change_tfg_ribbon_name, parent=self.layout) self.rbg_control_scheme = pm.radioButtonGrp(label='Control Scheme', labelArray3=self.control_scheme_options, numberOfRadioButtons=3) self.rbg_control_scheme.setSelect(2) self.btn_execute = pm.button(parent=self.layout, enable=False,w = 100, h = 24, label="Build", command=self._build_ribbon) self.btn_cancel = pm.button(parent=self.layout, enable=False,w = 100, h = 24, label="Cancel", command=self.close) pm.setFocus(self.btn_execute) self.win.show()
def restorePanes(self, panel, tearoff): # Delete TearOff panel if pc.windows.window(panel.split('|')[-1]+'Window', q=True, exists=True): pc.windows.deleteUI(panel.split('|')[-1]+'Window', window=True) # Update maya UI panels to avoid crashing # NOTE may not be necessary at all pc.mel.eval('switchPanes single 0') # Restore visible elements if self.isChecked(self.smarthud): self.toggleVisiblePanelElements(tearoff.split("|")[-1]) # Convert to output curr_frm = pc.animation.currentTime(q=True) max_plbopt = self.timerange_max() # Set focus to other panel (avoid crashing if called agani straight # after) for i in pc.getPanel(all=True): if i != panel: pc.setFocus() break hudobj = 'HUDObjectPosition', pc.headsUpDisplay(hudobj, rem=True)
def createLegRig(self): selection = pm.selected() newRig = LegRig(parent = self._rig, name = self._legNameInput.getText()) if selection and len(selection) == 2: try: first, last = selection boneChain = BoneChain(start = first, end = last) newRig.bones = boneChain.bones except Exception as error: self.log.error('Could not assign bones to new rig. {0}'.format(error.message)) self.populateLegList() pm.select(newRig.node) pm.setFocus(self._legNameInput)
def viewportCapture(cls, camera_node, model_panel, path=None, toSquare=False, height=600, width=960, file_format='jpg'): from tempfile import NamedTemporaryFile file_path = NamedTemporaryFile(suffix=".%s" % file_format, delete=False) pmc.setFocus(model_panel) pmc.modelPanel( model_panel, edit=True, camera=camera_node ) pmc.modelEditor( model_panel, edit=True, allObjects=False, polymeshes=True, wireframeOnShaded=False, displayAppearance='smoothShaded' ) pmc.camera( camera_node, edit=True, displayFilmGate=False, displayResolution=False, overscan=1 ) # Capture image pmc.playblast( frame=pmc.currentTime(query=True), format="image", completeFilename=file_path.name, compression=file_format, percent=100, quality=100, viewer=False, height=height, width=width, offScreen=True, showOrnaments=False ) # Store img var and delete file q_image = QtGui.QImage(file_path.name) image_width = q_image.size().width() image_height = q_image.size().height() file_path.close() os.unlink(file_path.name) # Crop image if toSquare is True: rect = cls.get_containedSquare(image_width, image_height) else: rect = QtCore.QRect(0, 0, image_width, image_height) cropped = q_image.copy(rect) # Save image File if path is not None: cropped.save(fullPath, file_format, quality) return cropped, path, rect
def setFocusPanel(panel): pm.setFocus(panel)
print max(h_dist,v_dist,zh_dist, zv_dist) cam[0].translateZ.set(max(h_dist,zh_dist,v_dist,zv_dist)) cam[0].translateY.set(ymid) cam[0].setParent(grp) if debug: pm.delete(locators) if centerCam: grp.translate.set([zmid,0,xmid]) pm.setKeyframe(grp.rotateY, t=pm.playbackOptions(q=True,ast=True), v=0) pm.setKeyframe(grp.rotateY, t=pm.playbackOptions(q=True,aet=True), v=360) model_screenshot(centerCam=True) ''' print "Current panel to get playblasted is: " + cmds.getPanel(withFocus=True) tempPanel = pm.modelPanel(tearOff=True) print "Tear off panel is: "+ tempPanel print "Playblast currently focused on panel: "+ pm.playblast(activeEditor=True) pm.setFocus(tempPanel) print "Now playblast focused on panel: " +pm.playblast(activeEditor=True) #cmds.evalDeferred("pm.playblast()") '''
def lcUVToolsUI(dockable=False, asChildLayout=False, *args, **kwargs): ''' ''' global lct_cfg global prefix global height windowName = 'lcUVTools' shelfCommand = 'import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI()'.format( windowName, prefix) commandString = 'import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI(asChildLayout=True)'.format( windowName, prefix) icon = os.path.join(basePath, 'lcUVTools.png') if pm.window(windowName, ex=True): pm.deleteUI(windowName) if not asChildLayout: lcUI.UI.lcToolbox_child_popout(prefix + '_columnLayout_main', windowName, height, commandString, iconPath, lct_cfg) mainWindow = lcUI.lcWindow(prefix=prefix, windowName=windowName, width=width, height=height, icon=icon, shelfCommand=shelfCommand, annotation=annotation, dockable=dockable, menuBar=True) mainWindow.create() # column for the uv tool bar pm.columnLayout(prefix + '_columnLayout_main') # build ui in parts # Row 1 - basic pm.rowColumnLayout(nc=4, cw=[(1, 95), (2, 35), (3, 35), (4, 35)]) pm.columnLayout() pm.checkBox( prefix + '_checkBox_shell', l=' Shell Mode', v=False, changeCommand=lambda *args: lct_cfg.set( 'lcUVToolsShell', pm.checkBox(prefix + '_checkBox_shell', query=True, v=True))) pm.button(l='Grab Shell', bgc=colorWheel.getNext(), h=20, w=93, command=lambda *args: lcGeometry.UV().grabShell()) pm.setParent('..') pm.symbolButton(image=os.path.join(srcPath, 'icons', 'temp.png'), enable=False, visible=False) button_snapshot = pm.symbolButton(image='polyUVSnapshot.png', annotation='Take UV Snapshot', command=lambda *args: uvmp_uv_snapshot()) popup_snapshot = pm.popupMenu(parent=button_snapshot) pm.menuItem( prefix + '_checkBox_antiAlias', l='Antialias', checkBox=False, parent=popup_snapshot, command=lambda *args: lct_cfg.set( 'lcUVToolsAntialias', pm.menuItem( prefix + '_checkBox_antiAlias', query=True, checkBox=True))) pm.menuItem( prefix + '_checkBox_openPS', l='Auto Open PS', checkBox=True, parent=popup_snapshot, command=lambda *args: lct_cfg.set( 'lcUVToolsOpenPS', pm.menuItem(prefix + '_checkBox_openPS', query=True, checkBox=True) )) pm.symbolButton(image='textureEditor.png', annotation='Open the UV Editor', command=lambda *args: pm.mel.eval('TextureViewWindow')) # pm.text(l='') pm.setParent(prefix + '_columnLayout_main') # Row 2 pm.separator(style='in', h=10, w=200) row2 = pm.rowColumnLayout(nc=3, cw=[(1, 66), (2, 66), (3, 66)]) ##MOVE pm.columnLayout() pm.text(l='Move', w=66, align='center') pm.separator(style='none', h=9) bgc = colorWheel.getNext() pm.rowColumnLayout(nc=3, cw=[(1, 15), (2, 34), (3, 15)]) pm.text(l='') pm.button( l='^', h=15, bgc=bgc, command=lambda *args: uvmp_move( [0, 1 * pm.floatField(prefix + '_move_value', q=True, v=True)])) pm.text(l='') pm.button( l='<', bgc=bgc, command=lambda *args: uvmp_move( [-1 * pm.floatField(prefix + '_move_value', q=True, v=True), 0])) pm.floatField(prefix + '_move_value', h=34, v=1.00, pre=2) pm.button( l='>', bgc=bgc, command=lambda *args: uvmp_move( [1 * pm.floatField(prefix + '_move_value', q=True, v=True), 0])) pm.text(l='') pm.button( l='v', h=15, bgc=bgc, command=lambda *args: uvmp_move( [0, -1 * pm.floatField(prefix + '_move_value', q=True, v=True)])) pm.text(l='') pm.setParent(row2) ##SCALE pm.columnLayout() pm.text(l='Scale', w=66, align='center') pm.separator(style='none', h=4) bgc = colorWheel.getNext() pm.rowColumnLayout(nc=3, cw=[(1, 25), (2, 14), (3, 25)]) pm.button('U+', bgc=bgc, c=lambda *args: uvmp_scale( [pm.floatField(prefix + '_scale_value', q=True, v=True), 1])) pm.button('+', bgc=bgc, c=lambda *args: uvmp_scale([ pm.floatField(prefix + '_scale_value', q=True, v=True), pm.floatField(prefix + '_scale_value', q=True, v=True) ])) pm.button( 'V+', bgc=bgc, c=lambda *args: uvmp_scale( [1, pm.floatField(prefix + '_scale_value', q=True, v=True)])) pm.setParent('..') pm.rowColumnLayout(nc=3, cw=[(1, 13), (2, 38), (3, 13)]) pm.text(l='') pm.floatField(prefix + '_scale_value', v=2.00, min=1.0, pre=2, h=25) pm.text(l='') pm.setParent('..') pm.rowColumnLayout(nc=3, cw=[(1, 25), (2, 14), (3, 25)]) pm.button( 'U-', bgc=bgc, c=lambda *args: uvmp_scale([ pm.floatField(prefix + '_scale_value', q=True, v=True) / pow( pm.floatField(prefix + '_scale_value', q=True, v=True), 2), 1 ])) # x/(x^2) pm.button( '-', bgc=bgc, c=lambda *args: uvmp_scale([ pm.floatField(prefix + '_scale_value', q=True, v=True) / pow( pm.floatField(prefix + '_scale_value', q=True, v=True), 2), pm.floatField(prefix + '_scale_value', q=True, v=True) / pow( pm.floatField(prefix + '_scale_value', q=True, v=True), 2) ])) # x/(x^2) pm.button( 'V-', bgc=bgc, c=lambda *args: uvmp_scale([ 1, pm.floatField(prefix + '_scale_value', q=True, v=True) / pow( pm.floatField(prefix + '_scale_value', q=True, v=True), 2) ])) # x/(x^2) pm.setParent(row2) ##ROTATE pm.columnLayout() pm.text(l='Rotate', w=66, align='center') pm.separator(h=2) bgc = colorWheel.getNext() pm.rowColumnLayout(nc=2, cw=[(1, 16), (2, 48)]) pm.columnLayout() pm.button(prefix + '_clockwise', l='>', bgc=bgc, w=15, h=20, c=lambda *args: uvmp_rotate(-pm.floatField( prefix + '_rotate_value', q=True, v=True))) pm.button(prefix + '_counter_clockwise', l='<', bgc=bgc, w=15, h=20, c=lambda *args: uvmp_rotate( pm.floatField(prefix + '_rotate_value', q=True, v=True))) pm.setParent('..') pm.floatField(prefix + '_rotate_value', v=45.00, pre=2, h=40) pm.setParent('..') pm.floatSlider(prefix + '_rotate_free', min=-1, max=1, v=0, w=64, dc=uvmp_rotate_interactive, cc=uvmp_reset_slider) pm.button(l='align', bgc=bgc, w=65, h=20, command=lambda *args: uvmp_align_cardinal()) pm.setParent(prefix + '_columnLayout_main') # Row 3 pm.separator(style='in', h=10, w=200) row3 = pm.rowColumnLayout(nc=2, cw=[(1, 100), (2, 100)]) uvmp_texture_range_UI() pm.setParent(row3) ##TOOLS pm.gridLayout(nrc=[2, 2], cwh=[48, 48]) pm.symbolButton(image='expandContainer.png', bgc=(0.25, 0.5, 0.25), command=lambda *args: uvmp_split_edges_at_UVs(), annotation='Enter UV Unfold') pm.symbolButton(image='collapseContainer.png', bgc=(0.5, 0.25, 0.25), command=lambda *args: uvmp_merge_special(), annotation='Exit UV Unfold') pm.symbolButton(image='polyMapCut.png', command=lambda *args: uvmp_cut_edge(), annotation='Cut UV Edge') pm.symbolButton(image='textureEditorUnfoldUVsLarge.png', command=lambda *args: uvmp_auto_layout(), annotation='Auto UV Layout') pm.setParent(prefix + '_columnLayout_main') # #Row 4 # pm.separator(style='in', h=10, w=200) # pm.rowColumnLayout(nc=2, cw=[(1,100), (2,100)]) # pm.setParent(prefix+'_columnLayout_main') # if not asChildLayout: mainWindow.show() pm.window(mainWindow.mainWindow, edit=True, h=height, w=width) else: pm.setParent('..') pm.setParent('..') # edit menus optionsMenu, helpMenu = lcUI.UI.lcToolbox_child_menu_edit( asChildLayout, windowName) # restore interface selections pm.checkBox(prefix + '_checkBox_shell', edit=True, value=lct_cfg.get('lcUVToolsShell')) # extra stuff pm.setFocus( prefix + '_move_value' ) # set cursor focus on move value, otherwise it sets to first available ui element lcPlugin.Plugin.reload_plugin(plugin='Unfold3D', autoload=True)
def switch_view(self): self.update_camera() self.apply_camera_setting() pm.setFocus(self.viewport) pm.lookThru(self.current_camera)
def addBtnPress(rmbtn1, rmbtn2, lay, pos=None): new = addTXF(lay, pos=pos) pm.setFocus(new) print new rmbtn1.setEnable(1) rmbtn2.setEnable(1)
def _do_playblast(self): MODEL_EDITOR_PARAMS = { "activeView": True, "cameras": False, "controlVertices": False, "deformers": False, "dimensions": False, "displayAppearance": "smoothShaded", "displayLights": "default", "displayTextures": True, "dynamicConstraints": False, "fogging": False, "follicles": False, "grid": False, "handles": False, "headsUpDisplay": True, "hulls": False, "ignorePanZoom": False, "ikHandles": False, "imagePlane": True, "joints": False, "lights": False, "locators": False, "manipulators": False, "nurbsCurves": False, "nurbsSurfaces": True, "pivots": False, "planes": False, "selectionHiliteDisplay": False, "shadows": False, "sortTransparent": True, "strokes": True, "textures": True, "useDefaultMaterial": False, "wireframeOnShaded": False, } windowName = "review_blast" try: _current_panel = pm.getPanel(wf=True) if pm.modelEditor(_current_panel, q=True, fogging=True) == True: MODEL_EDITOR_PARAMS["fogging"] = True except: pass try: if pm.windowPref(windowName, exists=True): pm.windowPref(windowName, remove=True) pm.deleteUI(windowName) except: pass _window = pm.window(windowName, titleBar=True, iconify=True, leftEdge=100, topEdge=100, width=800, height=600, sizeable=False) _layout = pm.formLayout() _editor = pm.modelEditor(**MODEL_EDITOR_PARAMS) pm.formLayout(_layout, edit=True, attachForm=((_editor, "left", 0), (_editor, "top", 0), (_editor, "right", 0), (_editor, "bottom", 0))) # Legacy viewport used try: mel.eval("setRendererInModelPanel ogsRenderer {};".format(_editor)) except: cmds.confirmDialog( message= 'You need to change your viewport as the legacy version', dismissString='No') # viewport 2.0 used # mel.eval( "setRendererInModelPanel \"vp2Renderer\" {};".format( _editor)) pm.setFocus(_editor) pm.lookThru(_editor, self._shot_cam) cmds.refresh() _labelColor = cmds.displayColor('headsUpDisplayLabels', q=True, dormant=True) _labelValue = cmds.displayColor('headsUpDisplayValues', q=True, dormant=True) visibleHUDs = [ f for f in pm.headsUpDisplay(listHeadsUpDisplays=True) if pm.headsUpDisplay(f, query=True, visible=True) ] map(lambda f: pm.headsUpDisplay(f, edit=True, visible=False), visibleHUDs) for h in pm.headsUpDisplay(listHeadsUpDisplays=True): if pm.headsUpDisplay(h, q=1, s=1) == 7: if pm.headsUpDisplay(h, q=1, b=1) == 5: try: pm.headsUpDisplay(h, rem=True) except: pass for h in pm.headsUpDisplay(listHeadsUpDisplays=True): if pm.headsUpDisplay(h, q=1, s=1) == 7: if pm.headsUpDisplay(h, q=1, b=1) == 6: try: pm.headsUpDisplay(h, rem=True) except: pass cmds.displayColor('headsUpDisplayValues', 17, dormant=True) cmds.displayColor('headsUpDisplayLabels', 16, dormant=True) def hudShot(): _nameTemp = cmds.file(q=1, ns=1).split(".")[0] return _nameTemp.rsplit("_", 1)[0] def hudName(): return getpass.getuser() pm.headsUpDisplay('HUDCurrentFrame', edit=True, visible=True, labelFontSize="large", dataFontSize="large", section=5, block=1) #cmds.headsUpDisplay('HUDA',s=7,b=6, blockAlignment='center', dataFontSize='large', command=hudShot) #cmds.headsUpDisplay('HUDB',s=7,b=5, blockAlignment='center', dataFontSize='large', label="Artist:", labelFontSize="large", command=hudName) pm.setFocus(_editor) #if pm.headsUpDisplay('HUDCurrentFrame', query=True, visible=False): # print "works 111" # pass #else: _mov_file = os.path.splitext(self._file)[0] # print _mov_file # __audios = pm.ls(type="audio") __audios = pm.ls(type="audio") if len(__audios) > 0: __audio = str(__audios[0]) else: __audio = False # frame catching min, max, current _min_frame = pm.playbackOptions(q=1, min=1) _max_frame = pm.playbackOptions(q=1, max=1) _current_frame = pm.currentTime(q=1) pm.currentTime(_min_frame) ### playblast option ### # play_args = "playblast -format avfoundation -filename \"{}\" -sound \"{}\" -sequenceTime 0 -clearCache 1 -viewer 1 -forceOverwrite -showOrnaments 1 -offScreen -fp 4 -percent 100 -compression \"H.264\" -quality 70 -widthHeight {} {};".format( self._file, __audio, self.resolution_size[0], self.resolution_size[1]) try: _temp_path, _temp_file = os.path.split(self._file) _temp_mov_path = _temp_path + "/.temp" _temp_file_01 = os.path.splitext(_temp_file) _temp_mov_file = _temp_file_01[0] + "_uncomp" + _temp_file_01[1] _full_temp_mov_file = os.path.join(_temp_mov_path, _temp_mov_file) print _full_temp_mov_file try: if not os.path.exists(_temp_mov_path): os.makedirs(_temp_mov_path) if os.path.exists(_full_temp_mov_file): os.remove(_full_temp_mov_file) except: raise ### making playblast play_args = "playblast -format qt -filename \"{}\" -sound \"{}\" -sequenceTime 0 -clearCache 1 -viewer 0 -showOrnaments 1 -compression \"H.264\" -offScreen -fp 4 -percent 100 -quality 100 -widthHeight {} {};".format( _full_temp_mov_file, __audio, self.resolution_size[0], self.resolution_size[1]) mel.eval(play_args) pm.currentTime(_current_frame) sceneName = pm.sceneName() tk = sgtk.sgtk_from_path(sceneName) # get entity information _context = tk.context_from_path(sceneName) _date = datetime.date.today() _task = _context.step["name"] _shot_name = _context.entity["name"] _png_file = os.path.normpath( _temp_mov_path + "/" + _context.user["name"].translate(None, string.whitespace) + ".png") try: if not os.path.exists(_temp_mov_path): os.makedirs(_temp_mov_path) if os.path.exists(_png_file): os.remove(_png_file) except: raise ### write information on png file ### _copylight = "Copyright (C) {} JibJab Studios - All Rights Reserved".format( _date.year) _img = Image.new('RGBA', (1920, 1080), (0, 0, 0, 0)) _slate_image = ImageDraw.Draw(_img) _type_shot_asset = ImageFont.truetype('/Library/Fonts/arial.ttf', 30) _type_copyright = ImageFont.truetype('/Library/Fonts/arial.ttf', 15) _type_task = ImageFont.truetype('/Library/Fonts/arial.ttf', 18) _slate_image.text((820, 1000), _shot_name, font=_type_shot_asset, fill=(255, 255, 255, 128)) _slate_image.text((780, 1060), _copylight, font=_type_copyright, fill=(255, 255, 255, 128)) _slate_image.text((910, 1035), "Task : {}".format(_task), font=_type_task, fill=(255, 255, 255, 128)) # _slate_image.text((1610, 1060), _review_file, font=_type_copyright, fill=(255,255,255,80)) _img.save(_png_file, 'PNG') ### convert uncomppresed file to h.264 #t = os.system("/Volumes/public/StoryBots/production/series/ask_the_storybots/03_shared_assets/01_cg/05_maya_tools/pipeline/module/ffmpeg/ffmpeg -y -i " + _full_temp_mov_file + " -vcodec libx264 -pix_fmt yuv420p -preset slower -crf 0 -vf eq=brightness=0.04 -g 1 -acodec copy " + self._file) t = os.system( "/Volumes/public/StoryBots/production/series/ask_the_storybots/03_shared_assets/01_cg/05_maya_tools/pipeline/module/ffmpeg/ffmpeg -y -i " + _full_temp_mov_file + " -i " + _png_file + " -vcodec libx264 -pix_fmt yuv420p -preset slow -crf 22 -filter_complex \"overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2\" -g 0 -acodec copy " + self._file) ###################################### #### This is RV open with mov file ### ###################################### _mov_path_RV, _mov_file_RV = os.path.split(self._file) os.chdir(_mov_path_RV) subprocess.Popen(self._RV_path + _mov_file_RV, shell=True) if os.path.exists(_full_temp_mov_file): os.remove(_full_temp_mov_file) if os.path.exists(_png_file): os.remove(_png_file) except: pm.confirmDialog( title="Playblast Error", message= "Close your RV or deselect the file.\nYour file is being used from other application", defaultButton="Yes") raise # playblast -format avfoundation -sound "ATS_301_sq020_020" -sequenceTime 0 -clearCache 1 -viewer 1 -showOrnaments 0 -offScreen -fp 4 -percent 80 -compression "H.264" -quality 70 -widthHeight 1920 1080; #pm.showWindow( _window ) pm.headsUpDisplay('HUDCurrentFrame', edit=True, visible=False, section=5, block=1) # cmds.headsUpDisplay( 'HUDA', rem=True ) # cmds.headsUpDisplay( 'HUDB', rem=True ) # delete playblast window pm.deleteUI(_window) # revive HOD modes cmds.displayColor('headsUpDisplayValues', _labelColor, dormant=True) cmds.displayColor('headsUpDisplayLabels', _labelValue, dormant=True) map(lambda f: pm.headsUpDisplay(f, edit=True, visible=True), visibleHUDs)
def createWindow(): """ try to get data from shotgun project fields need to get context's project context's shotgun instance """ app = self.parent project = app.context.project sg = app.context.tank.shotgun # set filters and search fields for entity type "Project" filters = [ ["id", "is", project['id']], ] fields = ["sg_width", "sg_height"] result = sg.find_one("Project", filters, fields) # with result, set parameters accordingly or use default otherwise if result: videoWidth = result.get("sg_width", DEFAULT_WIDTH) videoHeight = result.get("sg_height", DEFAULT_HEIGHT) # Find first camera matching pattern and set as active camera # if not use default current active camera camera_name_pattern = app.get_setting("camera_name_pattern", "persp") cameraList = [ c.name() for c in pm.ls(type="camera", r=True) if re.search(camera_name_pattern, c.name()) ] #print cameraList if not "cam" in MODEL_EDITOR_PARAMS.keys() and cameraList: MODEL_EDITOR_PARAMS["cam"] = cameraList[0] #print MODEL_EDITOR_PARAMS # Give Viewport 2.0 renderer only for Maya 2015++ # mayaVersionString = cmds.about(version=True) # mayaVersion = int(mayaVersionString[:4]) if len(mayaVersionString) >= 4 else 0 # if mayaVersion >= 2015: # params[ "rendererName" ] = "vp2Renderer" # Create window if pm.windowPref(PLAYBLAST_WINDOW, exists=True): pm.windowPref(PLAYBLAST_WINDOW, remove=True) window = pm.window(PLAYBLAST_WINDOW, titleBar=True, iconify=True, leftEdge=100, topEdge=100, width=videoWidth, height=videoHeight, sizeable=False) # Create editor area layout = pm.formLayout() editor = pm.modelEditor(**MODEL_EDITOR_PARAMS) pm.setFocus(editor) pm.formLayout(layout, edit=True, attachForm=((editor, "left", 0), (editor, "top", 0), (editor, "right", 0), (editor, "bottom", 0))) # Show window pm.setFocus(editor) pm.showWindow(window) pm.refresh() try: yield True except: traceback.print_exc() finally: pm.deleteUI(window)
def lcTextureToolsUI(dockable=False, asChildLayout=False, *args, **kwargs): ''' ''' global lct_cfg global prefix global height global defaultPath global defaultPrefix ci = 0 # color index iterator windowName = 'lcTextureTools' shelfCommand = 'import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI()'.format(windowName, prefix) commandString = 'import lct.src.{0}.{0} as {1}\nreload({1})\n{1}.{0}UI(asChildLayout=True)'.format(windowName, prefix) icon = os.path.join(basePath, 'lcTextureTools.png') winWidth = 205 winHeight = height if pm.window(windowName, ex=True): pm.deleteUI(windowName) if not asChildLayout: lcUI.UI.lcToolbox_child_popout(prefix + '_columnLayout_main', windowName, height, commandString, iconPath, lct_cfg) mainWindow = lcUI.lcWindow(prefix=prefix, windowName=windowName, width=winWidth, height=winHeight, icon=icon, shelfCommand=shelfCommand, annotation=annotation, dockable=dockable, menuBar=True) mainWindow.create() # pm.columnLayout(prefix + '_columnLayout_main') # RENAME TEXTURE NODES pm.text(l='- Rename File Texture Nodes -', font='boldLabelFont', al='center', w=200, h=20, bgc=colorWheel.darkgrey) pm.separator(style='none', h=3, w=200) pm.rowColumnLayout(nc=3, cw=([1, 40], [2, 110], [3, 50])) pm.textField(prefix + '_textField_prefix', placeholderText=defaultPrefix, changeCommand=lambda *args: lct_cfg.set('lcTextureToolsPrefix', pm.textField(prefix + '_textField_prefix', query=True, tx=True)), receiveFocusCommand=lambda *args: lcTxT_rename_focus()) pm.text(l="_'texture_file_name'") pm.button(prefix + '_button_rename', l='Rename', bgc=colorWheel.getColorRGB(ci), annotation='rename all file texture nodes', w=50, command=lambda *args: lcTxT_rename_textures(pm.textField(prefix + '_textField_prefix', q=True, tx=True))) ci += 1 pm.setParent(prefix + '_columnLayout_main') pm.separator(style='in', h=8, w=200) # REPATH TEXTURE NODES pm.text(l='- Set new path for File Textures -', font='boldLabelFont', al='center', w=200, h=25, bgc=colorWheel.darkgrey) pm.separator(style='none', h=3, w=200) lcUI.UI.lc_browse_field_button(width=200, textFieldName=prefix + '_textField_new_path', lct_cfg=lct_cfg, configAttr='lcTextureToolsRepath', placeholderText=defaultPath, annotation='Choose a new texture directory') pm.setParent(prefix + '_columnLayout_main') # pm.rowColumnLayout(nc=2, cw=([1, 100], [2, 100])) pm.iconTextButton(w=100, h=25, style='iconAndTextHorizontal', label='Repath All', flat=False, image=os.path.join(iconPath, 'repath.png'), bgc=colorWheel.getColorRGB(ci), annotation='Repath all file texture nodes to exact path given', command=lambda *args: lcTxT_repath_all()) ci += 1 pm.iconTextButton(w=100, h=25, style='iconAndTextHorizontal', label='Selected', flat=False, image=os.path.join(iconPath, 'repath.png'), bgc=colorWheel.getColorRGB(ci), annotation='Repath selected file texture nodes to exact path given', command=lambda *args: lcTxT_repath_selected()) ci += 1 pm.setParent(prefix + '_columnLayout_main') # pm.rowColumnLayout(nc=2, cw=([1, 100], [2, 100])) pm.button(w=100, h=25, label='Intelli-All', bgc=colorWheel.getColorRGB(ci), annotation='Recursive search given path to repath all file texture nodes', command=lambda *args: lcTxT_intelligent_repath_all()) ci += 1 pm.button(w=100, h=25, label='Intelli-Selected', bgc=colorWheel.getColorRGB(ci), annotation='Recursive search given path to repath selected file texture nodes', command=lambda *args: lcTxT_intelligent_repath_selected()) ci += 1 pm.setParent(prefix + '_columnLayout_main') pm.separator(style='in', h=8, w=200) # REPATH SHADERS (dx11 only) pm.text(l='- Set new path for DX11 Shaders -', font='boldLabelFont', al='center', w=200, h=25, bgc=colorWheel.darkgrey) pm.separator(style='none', h=3, w=200) lcUI.UI.lc_browse_field_button(width=200, textFieldName=prefix + '_textField_new_shader_path', lct_cfg=lct_cfg, configAttr='lcTextureToolsShaderRepath', placeholderText=defaultPath, annotation='Choose a new shader directory') pm.setParent(prefix + '_columnLayout_main') # pm.rowColumnLayout(nc=2, cw=([1, 100], [2, 100])) pm.iconTextButton(w=100, h=25, style='iconAndTextHorizontal', label='Repath All', flat=False, image=os.path.join(iconPath, 'shader_repath.png'), bgc=colorWheel.getColorRGB(ci), annotation='Repath all dx11Shader nodes to exact path given', command=lambda *args: lcTxT_shader_repath_all()) ci += 1 pm.iconTextButton(w=100, h=25, style='iconAndTextHorizontal', label='Selected', flat=False, image=os.path.join(iconPath, 'shader_repath.png'), bgc=colorWheel.getColorRGB(ci), annotation='Repath selected dx11Shader nodes to exact path given', command=lambda *args: lcTxT_shader_repath_selected()) ci += 1 pm.setParent(prefix + '_columnLayout_main') pm.separator(style='in', h=8, w=200) # OPEN TEXTURES # a=170 # b=200-a # pm.rowColumnLayout(nc=2, cw=([1,a], [2,b])) pm.text(l='- Open File Texture Nodes -', font='boldLabelFont', al='center', w=200, h=25, bgc=colorWheel.darkgrey) pm.separator(style='none', h=3, w=200) # pm.symbolButton(prefix+'_button_check_editors', visible=False, image=os.path.join(srcPath,'icons','hint.png'), annotation='Setup Image File Editors', command=lambda *args: lcTxT_update_maya_prefs(prefix+'_button_check_editors') ) pm.setParent(prefix + '_columnLayout_main') pm.rowColumnLayout(nc=2, cw=([1, 100], [2, 100])) pm.iconTextButton(w=100, h=25, style='iconAndTextHorizontal', label='Open All', flat=False, image=os.path.join(iconPath, 'open.png'), bgc=colorWheel.getColorRGB(ci), annotation='Open all file texture nodes in default associated program', command=lambda *args: lcTxT_open_textures('all')) ci += 1 pm.iconTextButton(w=100, h=25, style='iconAndTextHorizontal', label='Selected', flat=False, image=os.path.join(iconPath, 'open.png'), bgc=colorWheel.getColorRGB(ci), annotation='Open selected file texture nodes in default associated program', command=lambda *args: lcTxT_open_textures('selected')) ci += 1 pm.separator(style='none', h=8, w=200) # if not asChildLayout: mainWindow.show() pm.window(mainWindow.mainWindow, edit=True, height=winHeight, width=winWidth) else: pm.setParent('..') pm.setParent('..') # edit menus optionsMenu, helpMenu = lcUI.UI.lcToolbox_child_menu_edit(asChildLayout, windowName) # restore interface selections pm.textField(prefix + '_textField_new_path', edit=True, text=lct_cfg.get('lcTextureToolsRepath')) pm.textField(prefix + '_textField_prefix', edit=True, text=lct_cfg.get('lcTextureToolsPrefix')) pm.textField(prefix + '_textField_new_shader_path', edit=True, text=lct_cfg.get('lcTextureToolsShaderRepath')) # run extra stuff pm.setFocus(prefix + '_button_rename') # validate export directory lcPath.Path.validatePathTextField(prefix + '_textField_new_path', lct_cfg, 'lcTextureToolsRepath', defaultPath) lcPath.Path.validatePathTextField(prefix + '_textField_new_shader_path', lct_cfg, 'lcTextureToolsShaderRepath', defaultPath)
def addBtnPress(rmbtn1, rmbtn2, lay, pos=None): new = addTXF(lay, pos=pos) new.enterCommand(pm.Callback(addBtnPress, rmbtn1, rmbtn2, lay)) pm.setFocus(new) print new updateButtons(rmbtn1, rmbtn2, lay)
def setFocus(self): """Force Maya to focus on the window.""" if self.dockable(): return pm.setFocus(self.WindowID) return super(MayaWindow, self).setFocus()
def focus(self, *args): pm.select(clear = True) pm.setFocus(self._field)
def set_focus_panel(panel): pm.setFocus(panel)
def set_textFieldFocus(text_field): pm.setFocus(text_field)