def _createNode(self): try: cam = pm.ls(sl=True, type="camera")[0] except: raise AttributeError("Please select a camera shape!") node = pm.nodetypes.ImagePlane() # adapted from cameraImagePlaneUpdate.mel node.message.connect(cam.imagePlane, nextAvailable=True) cam.horizontalFilmAperture.connect(node.sizeX) cam.verticalFilmAperture.connect(node.sizeY) cam.orthographicWidth.connect(node.width) cam.orthographicWidth.connect(node.height) node.attr("center").set(cam.getWorldCenterOfInterest()) for item in pm.listRelatives(cam, parent=True): pm.showHidden(item, below=True) for modelPanel in pm.getPanel(type="modelPanel"): modelCamera = pm.modelPanel(modelPanel, query=True) if modelCamera != "": for shape in pm.listRelatives(modelCamera, shapes=True): if shape == cam: editor = pm.modelPanel(modelPanel, query=True, modelEditor=True) pm.modelEditor(editor, edit=True, updateColorMode=True) break return node
def set_camera_background(self, camera_node=None, panel_node=None): if panel_node is None: panel_node = self.get_selected_panel() pmc.modelPanel(panel_node, edit=True, camera=camera_node) if camera_node is None: camera_node = self.get_selected_camera() self.draw_background(camera_node) pmc.camera(camera_node, edit=True, displayFilmGate=False, displayResolution=True, overscan=1.3)
def getCamFromModelPanel(panel=None): cam = None if not panel: panel = pm.getPanel(withFocus=True) if pm.modelPanel(panel, exists=True): # whether panel is modelPanel(viewport) or not cam = pm.modelPanel(panel, q=True, camera=True) else: om2.MGlobal.displayWarning('Active panel is not modelPanel(viewport)!') mypopup("ビューポートが非アクティブです.") return 0 return cam
def gui(): ''' Triggers the interface for zoomerate. ''' # Warning this is causeing issues with 2012 panel = pm.getPanel(wf=True) try: whichCam = pm.modelPanel(panel, q=1, camera=True) except RuntimeError: whichCam = pm.modelPanel('modelPanel4', q=1, camera=True) print 'Using: %s' % whichCam whichCamShape = pm.ls(whichCam, dag=True, shapes=True, ap=True) # Figure out what cameras to use when building the menu cameras = pm.ls(ca=True) diffCams = [] diffCams.extend(whichCamShape) diffCams.extend(cameras) print diffCams, len(diffCams) win_name = 'zoomer_win2' if pm.window(win_name, ex=True): pm.deleteUI(win_name) win = pm.window(win_name, s=0, ip=True, iconName='zoomer', w=400, h=180, t='Camera zoomeratro v1.0') main = pm.columnLayout() pm.frameLayout(borderVisible=True, labelVisible=True, labelAlign='cener', label='Zoom Options', marginWidth=5, marginHeight=5) pm.columnLayout() global which_cam_menu which_cam_menu = pm.optionMenuGrp(label='Camera to Zoom', cc=connect) pm.menuItem(label=whichCamShape[0]) for i in xrange(len(diffCams)-1): pm.menuItem(label=cameras[i]) horizontal_attr = '%s.horizontalFilmOffset' % whichCamShape[0] vertical_attr = '%s.verticalFilmOffset' % whichCamShape[0] overscan_attr = '%s.overscan' % whichCamShape[0] global horizontal_slider, vertical_slider, overscan_slider horizontal_slider = pm.floatSliderGrp(field=True, label='Horizontal', min=-3, max=3, pre=3, step=0.001) vertical_slider = pm.floatSliderGrp(field=True, label='Vertical', min=-3, max=3, pre=3, step=0.001) overscan_slider = pm.floatSliderGrp(field=True, label='Overscan', min=-3, max=3, pre=3, step=0.001) pm.connectControl(horizontal_slider, horizontal_attr) pm.connectControl(vertical_slider, vertical_attr) pm.connectControl(overscan_slider, overscan_slider) pm.button(label='Reset', c=reset) win.show()
def lightActivatedEvent(self, obj, lightItem, *args, **kwargs): super(LightControl, self).lightActivatedEvent(args, kwargs) name = lightItem.data(QtCore.Qt.UserRole) light = pmc.PyNode(name) self.activeLight = light pmc.modelPanel('lcModelPanel', e=True, p=self.paneLayoutName) if self.selectLightCheckbox.isChecked(): pmc.select(light) if self.lookThroughLightCheckbox.isChecked(): self._updateCamera(light.name()) self._updateControls(light, enable=light.visibility.get()) self.statusBar().showMessage('Controlling {}'.format(light.name()))
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 __init__(self, metadata_path='', filename='', camera='', frame_range='', format='', compression='', width='', height=''): self.metadata_path = metadata_path self.camera = camera self.frame_range = FrameRange.parse(frame_range) self.format = format self.compression = compression self.widthHeight = (int(width), int(height)) self.filename = filename self.input_pb_args = { 'filename': self.filename, 'frame': self.frame_range.get_frames(), 'format': self.format, 'compression': self.compression, 'widthHeight': self.widthHeight } self.gpu_meshes = [] self.namespaces = [] self.colors = [] self.meshes_with_color = [] self.old_render_layer = None self.playblast_panel = pm.modelPanel(replacePanel='modelPanel4') self.old_bkg_color = pm.displayRGBColor("background", query=True) self.old_bkg_top_color = pm.displayRGBColor("backgroundTop", query=True) self.old_bkg_bottom_color = pm.displayRGBColor("backgroundBottom", query=True)
def __init__(self, metadata_path='', filename= '', camera='', frame_range='', format='', compression='', width='', height=''): self.metadata_path = metadata_path self.camera = camera self.frame_range = FrameRange.parse(frame_range) self.format = format self.compression = compression self.widthHeight = (int(width), int(height)) self.filename = filename self.input_pb_args = {'filename' : self.filename, 'frame' : self.frame_range.get_frames(), 'format' : self.format, 'compression' : self.compression, 'widthHeight' : self.widthHeight} self.gpu_meshes = [] self.namespaces = [] self.colors = [] self.meshes_with_color = [] self.old_render_layer = None self.playblast_panel = pm.modelPanel(replacePanel='modelPanel4') self.old_bkg_color = pm.displayRGBColor("background", query=True) self.old_bkg_top_color = pm.displayRGBColor("backgroundTop", query=True) self.old_bkg_bottom_color = pm.displayRGBColor( "backgroundBottom", query=True )
def setCamPlaybackRange(): modelPanel = pm.playblast(activeEditor=True).split('|')[-1] activeCam = pm.PyNode( pm.modelPanel( modelPanel, q=True, camera=True ) ) startFrame = activeCam.startFrame.get() endFrame = activeCam.endFrame.get() pm.playbackOptions(min=endFrame, max=startFrame)
def lockCam(): view = pm.PyNode(pm.modelPanel(pm.getPanel(wf=True), q=True, cam=True)) cam = pm.ls(view)[0] if (cam.tx.get(l=1) == 1): cam.translate.set(l=0) cam.rotate.set(l=0) else: cam.translate.set(l=1) cam.rotate.set(l=1)
def lockCam(): view = pm.PyNode(pm.modelPanel(pm.getPanel(wf=True), q=True, cam=True)) cam = pm.ls(view)[0] if (cam.tx.get(l=1) == 1): cam.translate.set(l = 0) cam.rotate.set(l = 0) else: cam.translate.set(l = 1) cam.rotate.set(l = 1)
def _addMayaUI(self): ptr = long(shiboken2.getCppPointer(self.cameraBoxLayout)[0]) # Then get the full path to the UI in maya as a string mayaFullDagPath = openMayaUI.MQtUtil.fullName(ptr) if pmc.modelPanel('lcModelPanel', ex=True): pmc.deleteUI('lcModelPanel', panel=True) # Find a pointer to the paneLayout that we just created self.paneLayoutName = pmc.paneLayout('lcPaneLayout', cn='horizontal2', parent=mayaFullDagPath) ptr = openMayaUI.MQtUtil.findControl(self.paneLayoutName) # Wrap the pointer into a python QObject panelObj = wrapinstance(long(ptr)) self.lcModelPanel = pmc.modelPanel('lcModelPanel', label='Light Control', p=self.paneLayoutName) self.lcModelPanel.setMenuBarVisible(False) self.lcModelPanel.unParent() # add our QObject reference to the paneLayout to our layout self.cameraBoxLayout.addWidget(panelObj)
def addImgBookMark(): global bmCam bmCam = pm.modelPanel(pm.getPanel(wf=True),q=True,cam=True) #remove current bookmark cmvList = pm.ls(type='cameraView') if len(cmvList)!=0: for cmv in cmvList: if cmv == 'imageView_bookmark': pm.cameraView(cmv,c=bmCam,e=True,rb=True) pm.delete(cmv) #add bookmark addBM = pm.cameraView(c=bmCam,ab=True,n='imageView_bookmark')
def getCurrentCamera(): """Returns the current cammera with focus""" panelUnderPointer = pymel.getPanel( underPointer=True ) camera = None if panelUnderPointer: if 'modelPanel' in panelUnderPointer: currentPanel = pymel.getPanel(withFocus=True) currentPanel = currentPanel.split('|')[-1] camera = pymel.modelPanel(currentPanel, query=True, camera=True) return pymel.ls(camera)[0] return pymel.ls('persp')[0]
def createFallowCam( ): ''' 캐릭터를 따라다니는 카메라 생성 ''' # 선택한 물체에서 네임 스페이스 얻어옴. ns = '' sel = pm.selected() if sel: ns = sel[0].namespace() # 컨스트레인 걸 대상 리스트 확보 jnts = ['Hips','Spine*','*Leg','*Foot'] #jnts = ['Spine*','*Foot'] targets = [] for j in jnts: targets.extend( pm.ls( ns + j, exactType='joint' ) ) # 확보 안됨 끝. if not targets: print u'캐릭터의 일부를 선택하세요.' return # 카메라와 그룹 생성 cam = pm.camera(n='followCam')[0] grp = pm.group( cam, n='followCam_grp' ) # 컨스트레인 const = pm.pointConstraint( targets, grp ); pm.delete(const) # 우선 위치에 배치하고 #pm.pointConstraint( targets, grp, skip='y' ) # 컨스트레인 pm.pointConstraint( targets, grp ) # 컨스트레인 # 카메라 조정 cam.tz.set(1200) cam.focalLength.set(100) cam.centerOfInterest.set(1200) cam.filmFit.set(2) # vertical # 패널 조정 activePanel = pm.playblast( activeEditor=True ).split('|')[-1] pm.modelPanel( activePanel, edit=True, camera=cam )
def get_camera(with_panel=None): all_cams = [cam for cam in mc.listCameras(p=1) if not mc.referenceQuery(cam, isNodeReferenced=True)] extra_cams = ['persp', 'left', 'right', 'top', 'side', 'bottom'] if with_panel: try: current_cam = pm.PyNode(pm.modelPanel(pm.getPanel(wf=True), q=True, cam=True)) return current_cam except RuntimeError: pass all_cam_transform = [str(cam) for cam in all_cams if str(cam) not in extra_cams] # print all_cam_transform if all_cam_transform: return all_cam_transform else: return ["persp"]
def get_active_camera(): """ Return the active camera. Thanks to Nohra Seif for the snippet! """ # seems that $gMainPane contain the name of the main window pane layout holding the panels. main_pane = mel.eval('string $test = $gMainPane;') if main_pane != "": # get the layout's immediate children main_pane_ctrls = pymel.paneLayout(main_pane, q=True, childArray=True) for i in range(len(main_pane_ctrls)): # panel containing the specified control panel_name = pymel.getPanel(containing=main_pane_ctrls[i]) if "" != panel_name: # Return the type of the specified panel. if ("modelPanel" == pymel.getPanel(typeOf=panel_name)): # Return whether the control can actually be seen by the user, isObscured for invisible if not (pymel.control(main_pane_ctrls[i], q=True, isObscured=True)): model_editor = pymel.modelPanel(panel_name, q=True, modelEditor=True) if model_editor: # If this view is already active, let's continue to use it. if pymel.modelEditor(model_editor, q=True, activeView=True): # get the camera in the current modelPanel return pymel.PyNode(pymel.modelPanel(model_editor, q=True, camera=True))
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 createCamSolidBG( camera=None ): ''' 카메라 백으로 사용할 솔리드한 Plane을 세움, 카메라 이름을 명시하거나, 모델패털을 포커스한 상태에서 실행. Version : 2015-02-24 >>> camSolidBG() (nt.Transform(u'persp_camSolidBG_grp'), nt.Transform(u'persp_camSolidBG_mesh'), nt.SurfaceShader(u'persp_camSolidBG_surfaceShader'), nt.ShadingEngine(u'persp_camSolidBG_SG')) >>> camSolidBG( camera='side' ) (nt.Transform(u'side_camSolidBG_grp'), nt.Transform(u'side_camSolidBG_mesh'), nt.SurfaceShader(u'side_camSolidBG_surfaceShader'), nt.ShadingEngine(u'side_camSolidBG_SG')) ''' if not camera: camera = pm.modelPanel( pm.playblast(activeEditor=True).split('|')[-1], q=True, camera=True ) mesh = pm.polyPlane(sh=1, sw=1, ch=False)[0] grp = pm.group() pm.parentConstraint(camera, grp) mesh.t.set(0,0,-500) mesh.r.set(90,0,0) mesh.s.set(150,150,150) shader, SG = pm.createSurfaceShader('surfaceShader') shader.outColor.set(0.5,0.5,0.5) pm.select(mesh) pm.hyperShade(assign=shader) mesh.castsShadows.set(False) mesh.receiveShadows.set(False) mesh.motionBlur.set(False) mesh.smoothShading.set(False) mesh.visibleInReflections.set(False) mesh.visibleInRefractions.set(False) grp. rename('%s_camSolidBG_grp' % camera) mesh. rename('%s_camSolidBG_mesh' % camera) shader.rename('%s_camSolidBG_surfaceShader' % camera) SG. rename('%s_camSolidBG_SG' % camera) return grp, mesh, shader, SG
def getEditor(): """ The modelEditor is the node in maya that contains all the information about a modelPanel. A panel is an object in maya that acts as the root of a ui element. The model editor for instance holds information about what cameras have been added to a panel. """ if pm.modelEditor("mypanel", exists=True): print("the panel exists...deleting and creating a new one") pm.deleteUI("mypanel") cam = pm.ls(selection=True)[0] #SETTING CAMERA VIEWPORT SETTINGS pm.camera(cam, edit=True, displayResolution=False, displayFilmGate=False) window = pm.window(width=1280, height=720, backgroundColor=(1.0, 0.0, 0.0)) lay = pm.paneLayout() pan = pm.modelPanel() pm.modelEditor("mypanel", camera=cam, activeView=True, displayAppearance="smoothShaded") pm.showWindow(window, window=True)
def buildBody(self): self._iconSize = self.gui.iconSize self.minSize = 128 self.maxSize = 512 self.tempFileName = 'mayaIcon{0}.png' self.gui.window.setToolbox(True) self.camera = self.newCamera() with pm.formLayout() as form: with pm.columnLayout(): kw = dict(w=128, h=128) with pm.frameLayout(lv=False, bv=False, **kw) as self.editorFrame: self.panel = pm.modelPanel(cam=self.camera, mbv=False, l='Icon Capture View') self.setupModelEditor(self.panel.getModelEditor()) bar = self.panel.getBarLayout() pm.layout(bar, e=True, m=False) with pm.formLayout() as form2: self.buildFooter() utils.layoutForm(form2, 1) utils.layoutForm(form, (0, 1), vertical=True) self.updateEditorFrame() pm.refresh()
def buildMenuItems(self): # find camera try: camUnderPointer = pm.PyNode( pm.modelPanel(self.panel, q=True, cam=True)) if isinstance(camUnderPointer, pm.nt.Camera): camera = camUnderPointer else: camera = camUnderPointer.getShape() except: LOG.warning('could not find camera for panel: {0}'.format( self.panel)) return menuItemCol = pm.radioMenuItemCollection() isOrtho = camera.isOrtho() # list same type camera in radial positions similar = sorted( [c for c in pm.ls(typ='camera') if c.isOrtho() == isOrtho]) rps = quickmenus.getRadialMenuPositions(len(similar)) for cam, rp in zip(similar, rps): kw = {} if rp is not None: kw['rp'] = rp if cam == camera: kw['rb'] = True kw['cl'] = menuItemCol pm.menuItem(l=cam.getParent(), c=pm.Callback(pm.mel.lookThroughModelPanel, str(cam), str(self.panel)), **kw) if len(rps) > 8: pm.menuItem(d=True) # list other cameras dissimilar = sorted( [c for c in pm.ls(typ='camera') if c.isOrtho() != isOrtho]) for cam in dissimilar: pm.menuItem(l=cam.getParent(), c=pm.Callback(pm.mel.lookThroughModelPanel, str(cam), str(self.panel)))
def createImgPln(): global imgOp global imgDep global curCam global ImgPln global fileNm global pLoc #comfirmDialog for checking if ImgPln in the scene allTransNd = pm.ls(type='transform',fl=True) isImgPln = [] for trans in allTransNd: if trans == 'ImagePlane_Parent_Loc': isImgPln.append(trans) if len(isImgPln) >= 1: cfmAnswer = pm.confirmDialog( title='Confirm', message='Delete Image Plane?', button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No' ) if cfmAnswer == 'Yes': cleanupImgPln() createImgPln() elif len(isImgPln) == 0: #image plane opacty and offset from camera imgOp = 1 imgDep = 10 #get current camera curCam = pm.modelPanel(pm.getPanel(wf=True),q=True,cam=True) #select image and creat imagePlane and setup fileNm = pm.fileDialog2(ds=0,fm=1,cap='open',okc='Select Image') ImgPln = pm.imagePlane(fn=fileNm[0],lookThrough=curCam,maintainRatio=1) pm.setAttr(ImgPln[1]+'.displayOnlyIfCurrent',True) pm.setAttr(ImgPln[0]+'.translateZ',-pm.getAttr(curCam+'.translateZ')/3+-imgDep) pm.setAttr(ImgPln[1]+'.alphaGain',imgOp) pm.setAttr(ImgPln[1]+'.textureFilter',1) #aligh to the camera #create locator to be the parent and then create parent constraint pLoc = pm.spaceLocator(name='ImagePlane_Parent_Loc') pm.parent(ImgPln[0],pLoc) LocCons = pm.parentConstraint(curCam,pLoc) pm.setAttr(pLoc+'Shape.template',1) pm.setAttr(LocCons+'.template',1)
def get_current_camera(): current_cam = pm.PyNode( pm.modelPanel(pm.getPanel(wf=True), q=True, cam=True)) return current_cam
def onWindowClosed(self): if pm.modelPanel(self.panel, q=True, ex=True): pm.deleteUI(self.panel, pnl=True) if self.camera.exists(): pm.delete(self.camera)
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 toggleTextureMode(val): for panel in pc.getPanel(type='modelPanel'): me = pc.modelPanel(panel, q=True, me=True) pc.modelEditor(me, e=True, displayAppearance='smoothShaded') pc.modelEditor(me, e=True, dtx=val)
def get_panel_camera(self): camera_panel = pmc.modelPanel(self.get_selected_panel(), query=True, camera=True) return pmc.PyNode(camera_panel)
def reset_view(self): pan = cmds.getPanel(withFocus=True) sel_camera = pm.modelPanel(pan, q=True, camera=True) cmds.panZoom(sel_camera, abs=True, z=1, d=0, l=0, r=0, u=0)
def getActiveCamera(): panel = getActivePanel() return pm.PyNode(pm.modelPanel(panel, q=1, cam=1))
def getActiveCamera(self): panel = self.getActivePanel() if panel: return pm.PyNode(pm.modelPanel(panel, q=1, cam=1))
def export(self, **kwargs): # the category is just a folder below the library path assetCategory = kwargs.setdefault('assetCategory', 'default') # if no name is specified it uses the scene name assetName = kwargs.setdefault('assetName', pm.sceneName().basename()[:-3]) # an asset can have a .txt file associated with it. This should # help to clarify the contents of an asset assetDescription = kwargs.setdefault('assetDescription') # by default the exportAll command is called exportType = kwargs.setdefault('type', 'all') # if true automatically sets the camera to frame the exported objs autoFrame = kwargs.setdefault('autoFrame', True) breakRef = kwargs.setdefault('breakRef', False) # if the scene was not saved it has no name if assetName == '': raise Exception('Asset Name not specified') if exportType == 'selected' and not pm.selected(): # if nothing is selected, stop the execution here raise Exception('Nothing Selected') # create the folders if they don't exist self.checkPath(os.path.join(self.libraryPath, assetCategory)) assetPath = os.path.join(self.libraryPath, assetCategory, assetName) self.checkPath(assetPath) # save the selection now because enableIsolateSelect clears it selection = pm.selected() mpanel = pm.paneLayout('viewPanes', q=True, pane1=True) # disable selection highlighting and wireframe on shaded wireframeOnShadedState = pm.windows.modelEditor(mpanel, q=True, wireframeOnShaded=True) pm.windows.modelEditor(mpanel, e=True, sel=False, wireframeOnShaded=False) # set background color originalBackgroundColor = pm.general.displayRGBColor('background', q=True) pm.general.displayRGBColor('background', 0.3, 0.3, 0.3) # set the camera cam = pm.ls(pm.modelPanel(mpanel, q=True, cam=True), type='transform')[0] if autoFrame: wTrans = cam.getTranslation(ws=True) wRot = cam.getRotation(ws=True) try: cam.rx.set(-10) cam.ry.set(30) pm.viewFit() except: pass pm.general.refresh() if exportType == 'selected': # hide everything that is not selected for the playblast pm.mel.eval('enableIsolateSelect %s %d' % (mpanel, 1)) # RENDER ICON # this is a simple playblast of the current frame # image is saved as .jpg with an _icon suffix pm.animation.playblast(cf=assetPath + '/' + assetName + '_icon.jpg', format='image', compression='jpg', widthHeight=[128, 128], frame=[pm.animation.currentTime()], orn=False, os=True, v=False, percent=100) if autoFrame: try: # reset camera cam.setTranslation(wTrans, ws=True) cam.setRotation(wRot, ws=True) except: pass if exportType == 'selected': # show the scene again. the user shouldn't notice pm.mel.eval('enableIsolateSelect %s %d' % (mpanel, 0)) # reenable selection highlighting and reset wireframe on shaded to what it was before pm.windows.modelEditor(mpanel, e=True, sel=True, wireframeOnShaded=wireframeOnShadedState) #reset the background color to what it was before pm.general.displayRGBColor('background', originalBackgroundColor[0], originalBackgroundColor[1], originalBackgroundColor[2]) # EXPORT FILE # reselect the selection, isolate select clears it. pm.select(selection) if exportType == 'all': self.fixNamespaces( self.removeStudentLic( pm.system.exportAll(assetPath + '/' + assetName + '.ma', preserveReferences=not breakRef, force=True))) if exportType == 'selected': self.fixNamespaces( self.removeStudentLic( pm.system.exportSelected(assetPath + '/' + assetName + '.ma', preserveReferences=not breakRef, force=True))) # SAVE DESCRIPTION # newlines are saved if assetDescription: text_file = open(assetPath + '/' + assetName + '.txt', 'wt') text_file.write(assetDescription.encode('utf8')) text_file.close()
def gui(): ''' Triggers the interface for zoomerate. ''' # Warning this is causeing issues with 2012 panel = pm.getPanel(wf=True) try: whichCam = pm.modelPanel(panel, q=1, camera=True) except RuntimeError: whichCam = pm.modelPanel('modelPanel4', q=1, camera=True) print 'Using: %s' % whichCam whichCamShape = pm.ls(whichCam, dag=True, shapes=True, ap=True) # Figure out what cameras to use when building the menu cameras = pm.ls(ca=True) diffCams = [] diffCams.extend(whichCamShape) diffCams.extend(cameras) print diffCams, len(diffCams) win_name = 'zoomer_win2' if pm.window(win_name, ex=True): pm.deleteUI(win_name) win = pm.window(win_name, s=0, ip=True, iconName='zoomer', w=400, h=180, t='Camera zoomeratro v1.0') main = pm.columnLayout() pm.frameLayout(borderVisible=True, labelVisible=True, labelAlign='cener', label='Zoom Options', marginWidth=5, marginHeight=5) pm.columnLayout() global which_cam_menu which_cam_menu = pm.optionMenuGrp(label='Camera to Zoom', cc=connect) pm.menuItem(label=whichCamShape[0]) for i in xrange(len(diffCams) - 1): pm.menuItem(label=cameras[i]) horizontal_attr = '%s.horizontalFilmOffset' % whichCamShape[0] vertical_attr = '%s.verticalFilmOffset' % whichCamShape[0] overscan_attr = '%s.overscan' % whichCamShape[0] global horizontal_slider, vertical_slider, overscan_slider horizontal_slider = pm.floatSliderGrp(field=True, label='Horizontal', min=-3, max=3, pre=3, step=0.001) vertical_slider = pm.floatSliderGrp(field=True, label='Vertical', min=-3, max=3, pre=3, step=0.001) overscan_slider = pm.floatSliderGrp(field=True, label='Overscan', min=-3, max=3, pre=3, step=0.001) pm.connectControl(horizontal_slider, horizontal_attr) pm.connectControl(vertical_slider, vertical_attr) pm.connectControl(overscan_slider, overscan_slider) pm.button(label='Reset', c=reset) win.show()