コード例 #1
1
ファイル: commandsMod.py プロジェクト: Italic-/maya-prefs
def setThreePanelLayout():     
    shotCamera = animMod.getShotCamera()
    if not shotCamera: shotCamera = "persp"
    mel.eval("toolboxChangeQuickLayoutButton \"Persp/Graph/Hypergraph\" 2;"+\
             #"ThreeTopSplitViewArrangement;"+\
             "lookThroughModelPanel %s hyperGraphPanel2;"%shotCamera+\
             "lookThroughModelPanel persp modelPanel4;")
             #"scriptedPanel -e -rp modelPanel2 graphEditor1;")
    viewports = [view for view in cmds.getPanel(type='modelPanel') if view in cmds.getPanel(visiblePanels=True)]
    defaultCameras = [u'front', u'persp', u'side', u'top']
    
    for view in viewports:
        camera          = utilMod.getCamFromSelection([cmds.modelEditor(view, query=True, camera=True)])
        cameraTransform = camera[0]
        cameraShape     = camera[1]
    
        if cameraTransform in defaultCameras:
            utilMod.animViewportViewMode(view)
            
            if cameraTransform == "persp":
                cmds.camera(cameraTransform, edit=True, orthographic=False)
                cmds.setAttr("%s.nearClipPlane"%cameraShape, 1000)
                cmds.setAttr("%s.farClipPlane"%cameraShape, 10000000)
                cmds.setAttr("%s.focalLength"%cameraShape, 3500)
        else:
            utilMod.cameraViewMode(view)
            cmds.setAttr("%s.displayFilmGate"%cameraShape, 1)
            cmds.setAttr("%s.overscan"%cameraShape, 1)
コード例 #2
0
    def replaceWithCurrentView(self, assetName):

        thumbPath = os.path.join(self.directory, assetName, "%s_thumb.jpg" % assetName)
        SSpath = os.path.join(self.directory, assetName, "%s_s.jpg" % assetName)
        WFpath = os.path.join(self.directory, assetName, "%s_w.jpg" % assetName)

        pbPanel = cmds.getPanel(wf=True)
        if cmds.getPanel(to=pbPanel) != "modelPanel":
            cmds.warning("The focus is not on a model panel. Cancelling")
            return None, None, None
        wireMode = cmds.modelEditor(pbPanel, q=1, wireframeOnShaded=1)
        textureMode = cmds.modelEditor(pbPanel, q=1, displayTextures=1)

        cmds.setAttr("defaultRenderGlobals.imageFormat", 8)  # This is the value for jpeg

        frame = cmds.currentTime(query=True)
        # thumb
        cmds.modelEditor(pbPanel, e=1, displayTextures=1)
        cmds.modelEditor(pbPanel, e=1, wireframeOnShaded=0)
        cmds.playblast(completeFilename=thumbPath, forceOverwrite=True, format='image', width=200, height=200,
                     showOrnaments=False, frame=[frame], viewer=False)

        # screenshot
        cmds.playblast(completeFilename=SSpath, forceOverwrite=True, format='image', width=1600, height=1600,
                     showOrnaments=False, frame=[frame], viewer=False)

        # Wireframe
        cmds.modelEditor(pbPanel, e=1, displayTextures=0)
        cmds.modelEditor(pbPanel, e=1, wireframeOnShaded=1)
        cmds.playblast(completeFilename=WFpath, forceOverwrite=True, format='image', width=1600, height=1600,
                     showOrnaments=False, frame=[frame], viewer=False)

        # leave it as it was
        cmds.modelEditor(pbPanel, e=1, wireframeOnShaded=wireMode)
        cmds.modelEditor(pbPanel, e=1, displayTextures=textureMode)
コード例 #3
0
ファイル: light_set.py プロジェクト: jonike/animShader
    def __set_renderer_by_str(self, value):
        """
        This function sets the active rendere from it s string name
        @param value: str, the name of the rendere
        """
        currPanel = cmds.getPanel(withFocus=1)
        panelType = cmds.getPanel(to=currPanel)

        if value in self.RENDERERS_SHORTCUT:
            #create the mel command to eval
            cmd = 'setRendererInModelPanel \"{r}\" {cp};'.format(
                r=self.RENDERERS_SHORTCUT[value], cp=currPanel)

            #make sure we have a model panel active
            if (panelType == "modelPanel"):
                mel.eval(cmd)
            else:
                OpenMaya.MGlobal.displayError(
                    "In order to set stuff" +
                    " on the viewport we need an acive viewport")

        else:
            #print the error
            strSupp = [str(k) for k in self.RENDERERS_SHORTCUT.keys()]
            supp = "\n-" + "\n- ".join(strSupp)
            OpenMaya.MGlobal.displayError(
                "You did not provide a valid " +
                "renderer name, supported renderer names are :" +
                " \n {r}".format(r=supp) +
                " \n got {v}".format(v=type(value).__name__))
コード例 #4
0
ファイル: utils.py プロジェクト: Rotomator/PipeL
def desIsolate():
    """desisolate"""
    currPanel = mc.getPanel(withFocus=True)
    panelType = mc.getPanel(to=currPanel)
    if panelType == 'modelPanel':
        mc.isolateSelect(currPanel, state=0)
        mm.eval('enableIsolateSelect %s 0;' % currPanel)
コード例 #5
0
def getActiveModelPanel():
    '''gets the string of the active model editor panel (3D viewport returns none if none is active'''
    activePanel = cmds.getPanel(wf=True)
    if cmds.getPanel(typeOf=activePanel) == 'modelPanel':
        return activePanel
    else:
        return cmds.playblast(ae=True)
コード例 #6
0
 def isolate(self):
     """isolate node in viewport"""
     currPanel = mc.getPanel(withFocus=True)
     panelType = mc.getPanel(to=currPanel)
     if panelType == 'modelPanel':
         self()
         mc.isolateSelect(currPanel, state=1)
コード例 #7
0
def get_current_camera():
    '''
    '''
    camera = 'persp'

    if OpenMaya.MGlobal.mayaState() == OpenMaya.MGlobal.kInteractive:
        panels = mc.getPanel(vis=True)
        for pan in panels:
            if pan not in mc.getPanel(typ='modelPanel'):
                continue

            cam = mc.modelPanel(pan, q=True, cam=True)
            if mc.nodeType(cam) != 'transform':
                cam = mc.listRelatives(cam, p=True)[0]

            if cam not in ('persp', 'top', 'front', 'side'):
                camera = cam
                mc.modelEditor(pan, e=True, alo=False)
                mc.modelEditor(pan,
                               e=True,
                               pm=True,
                               av=True,
                               da='smoothShaded')
                break

    else:
        for cam in mc.listRelatives(mc.ls(cameras=True), p=True):
            if mc.getAttr('{0}.renderable'.format(cam)):
                camera = cam
                break

    return camera
コード例 #8
0
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
コード例 #9
0
ファイル: utils.py プロジェクト: mortenblaa/maya-tweener
def is_graph_editor():
    """
    Determine if keys are selected in the Graph Editor or Dope Sheet.
    
    :returns: True or False whether keys are selected in the Graph Editor or Dope Sheet
    :rtype: bool
    """

    sl_list = om.MGlobal.getActiveSelectionList()
    it = om.MItSelectionList(sl_list, om.MFn.kAnimCurve)

    visible_panels = cmds.getPanel(vis=True)
    graph_panels = cmds.getPanel(sty='graphEditor')
    dope_panels = cmds.getPanel(sty='dopeSheetPanel')

    if graph_panels is not None:
        graph_vis = any(x in graph_panels for x in visible_panels)
    else:
        graph_vis = False

    if dope_panels is not None:
        dope_vis = any(x in dope_panels for x in visible_panels)
    else:
        dope_vis = False

    return not it.isDone() and (graph_vis or dope_vis)
コード例 #10
0
ファイル: tool_belt.py プロジェクト: asisudai/maya-toolbelt
def get_panel_type():
    '''
    returns type of panel under focus
    '''
    current_panel = cmds.getPanel(withFocus=True)
    current_panel_type = cmds.getPanel(typeOf=current_panel)
    return current_panel_type
コード例 #11
0
def getPanel():
    isModelPanel = False
    panel = cmds.getPanel(withFocus=True)
    panelType = cmds.getPanel(typeOf=panel)
    if panelType == "modelPanel":   
        isModelPanel = True
    return isModelPanel, panel 
コード例 #12
0
ファイル: utils.py プロジェクト: skarone/PipeL
def desIsolate():
	"""desisolate"""
	currPanel = mc.getPanel( withFocus = True );
	panelType = mc.getPanel( to = currPanel )
	if panelType == 'modelPanel':
		mc.isolateSelect( currPanel, state = 0 )
		mm.eval( 'enableIsolateSelect %s 0;'%currPanel )
コード例 #13
0
def getActiveViewport():
    activePanel = cmds.getPanel(withFocus=True)
    panelType = cmds.getPanel(typeOf=activePanel)
    if not panelType == 'modelPanel':
        cmds.warning('No viewport active')
        return
    return activePanel
コード例 #14
0
def getAllViewports():

    return [
        view for view in cmds.getPanel(type='modelPanel')
        if view in cmds.getPanel(
            visiblePanels=True) and view != "scriptEditorPanel1"
    ]
コード例 #15
0
ファイル: mayaNode.py プロジェクト: skarone/PipeL
	def isolate(self):
		"""isolate node in viewport"""
		currPanel = mc.getPanel( withFocus = True )
		panelType = mc.getPanel( to = currPanel )
		if panelType == 'modelPanel':
			self()
			mc.isolateSelect( currPanel, state = 1 )
コード例 #16
0
def main(b_isolate=True):
	active_panel = cmds.getPanel(wf=True)
	model_panel  = cmds.getPanel(typ='modelPanel')
	src_panel    = None
	if active_panel and active_panel in model_panel:
		src_panel = active_panel
	
	if src_panel:
		iso_state = cmds.isolateSelect(src_panel, q=True, state=True)
		isExist   = True
		if b_isolate:
			if iso_state == False:
				isExist = False
				mel.eval('enableIsolateSelect "%s" 1;'%src_panel)
			selected = cmds.ls(sl=True)
			if selected:
				view_object = cmds.isolateSelect(src_panel, q=True, vo=True)
				if view_object:
					set_members = cmds.sets(view_object, q=True)
					if set_members == None:
						set_members = []
					for sel in selected:
						cmds.select(sel,r=True)
						if sel in set_members and isExist == True:
							cmds.isolateSelect(src_panel, rs=True)
						else:
							cmds.isolateSelect(src_panel, addSelected=True)
					cmds.isolateSelect(src_panel,u=True)
					cmds.select(selected, r=True)
		elif b_isolate == False and iso_state:
			cmds.isolateSelect(src_panel, state=False)
コード例 #17
0
def main(b_isolate=True):
    active_panel = cmds.getPanel(wf=True)
    model_panel = cmds.getPanel(typ='modelPanel')
    src_panel = None
    if active_panel and active_panel in model_panel:
        src_panel = active_panel

    if src_panel:
        iso_state = cmds.isolateSelect(src_panel, q=True, state=True)
        isExist = True
        if b_isolate:
            if iso_state == False:
                isExist = False
                mel.eval('enableIsolateSelect "%s" 1;' % src_panel)
            selected = cmds.ls(sl=True)
            if selected:
                view_object = cmds.isolateSelect(src_panel, q=True, vo=True)
                if view_object:
                    set_members = cmds.sets(view_object, q=True)
                    if set_members == None:
                        set_members = []
                    for sel in selected:
                        cmds.select(sel, r=True)
                        if sel in set_members and isExist == True:
                            cmds.isolateSelect(src_panel, rs=True)
                        else:
                            cmds.isolateSelect(src_panel, addSelected=True)
                    cmds.isolateSelect(src_panel, u=True)
                    cmds.select(selected, r=True)
        elif b_isolate == False and iso_state:
            cmds.isolateSelect(src_panel, state=False)
コード例 #18
0
def pre_command(with_focus=False, **flags):
    """
    :param with_focus: only affect the panel with focus
    :param flags: for mc.modelEditor
    :return: list of affected panels
    """
    global SCENE_PANEL_VALUES
    SCENE_PANEL_VALUES.clear()

    panels = mc.getPanel(type='modelPanel')
    if with_focus:
        focused_panel = mc.getPanel(withFocus=True)
        if focused_panel not in panels:
            # is this even possible?
            logger.debug('focused_panel: "{0}" not a modelPanel: [{1}]'.format(
                focused_panel, panels))
            return []
        panels = [focused_panel]
    for panel in panels:
        for flag, value in flags.iteritems():
            scene_value = mc.modelEditor(panel, q=True, **{flag: True})
            if scene_value != value:
                mc.modelEditor(panel, e=True, **{flag: value})
                SCENE_PANEL_VALUES[panel][flag] = scene_value
    return panels
コード例 #19
0
ファイル: commandsMod.py プロジェクト: jubeyjose/maya-prefs
def setThreePanelLayout():
    shotCamera = animMod.getShotCamera()
    if not shotCamera: shotCamera = "persp"
    mel.eval("toolboxChangeQuickLayoutButton \"Persp/Graph/Hypergraph\" 2;"+\
             #"ThreeTopSplitViewArrangement;"+\
             "lookThroughModelPanel %s hyperGraphPanel2;"%shotCamera+\
             "lookThroughModelPanel persp modelPanel4;")
    #"scriptedPanel -e -rp modelPanel2 graphEditor1;")
    viewports = [
        view for view in cmds.getPanel(type='modelPanel')
        if view in cmds.getPanel(visiblePanels=True)
    ]
    defaultCameras = [u'front', u'persp', u'side', u'top']

    for view in viewports:
        camera = utilMod.getCamFromSelection(
            [cmds.modelEditor(view, query=True, camera=True)])
        cameraTransform = camera[0]
        cameraShape = camera[1]

        if cameraTransform in defaultCameras:
            utilMod.animViewportViewMode(view)

            if cameraTransform == "persp":
                cmds.camera(cameraTransform, edit=True, orthographic=False)
                cmds.setAttr("%s.nearClipPlane" % cameraShape, 1000)
                cmds.setAttr("%s.farClipPlane" % cameraShape, 10000000)
                cmds.setAttr("%s.focalLength" % cameraShape, 3500)
        else:
            utilMod.cameraViewMode(view)
            cmds.setAttr("%s.displayFilmGate" % cameraShape, 1)
            cmds.setAttr("%s.overscan" % cameraShape, 1)
コード例 #20
0
    def dynSelection(self, *args, **kwargs):
        cmds.undoInfo(swf=False)  #Stop Undo/Redo queue without flushing it!
        panel = cmds.getPanel(underPointer=True)
        panelType = cmds.getPanel(typeOf=panel)
        cursorPos = self.mousePos()

        if panelType == 'modelPanel':
            shapesUnderCursor = cmds.hitTest(panel, cursorPos[0], cursorPos[1])

            if len(shapesUnderCursor) > 0:
                shape = cmds.ls(shapesUnderCursor, flatten=True)[0]

                if cmds.objectType(shape) == 'mnt_poseScope':
                    if shape != self.oldShape:
                        self.oldattrValue = cmds.getAttr(shape + '.opacity')

                        if self.oldShape:
                            cmds.setAttr(self.oldShape + '.opacity',
                                         self.oldattrValue)
                        cmds.setAttr(shape + '.opacity', 0.15)
                        self.oldShape = shape

            if len(shapesUnderCursor) == 0:
                if self.oldShape:
                    cmds.setAttr(self.oldShape + '.opacity', self.oldattrValue)
                    self.oldShape = None
        cmds.undoInfo(swf=True)
コード例 #21
0
ファイル: display_lib.py プロジェクト: boochos/work
def toggleObjectDisplay(purpose):

    # get active and find type of panel
    currentPanel = cmds.getPanel(withFocus=True)
    panelType = cmds.getPanel(to=currentPanel)

    if panelType == 'modelPanel':
        # all off
        cmds.modelEditor(currentPanel, e=True, alo=0)

        # arguments
        if purpose == 'anim':
            # specific on
            cmds.modelEditor(currentPanel, e=True, nurbsCurves=1)
            cmds.modelEditor(currentPanel, e=True, polymeshes=1)
            cmds.modelEditor(currentPanel, e=True, locators=1)
            cmds.modelEditor(currentPanel, e=True, cameras=1)
            cmds.modelEditor(currentPanel, e=True, handles=1)
            message('Panel display set for animation')
        elif purpose == 'cam':
            # specific on
            cmds.modelEditor(currentPanel, e=True, cameras=1)
            cmds.modelEditor(currentPanel, e=True, polymeshes=1)
            message('Panel display set for camera')
    else:
        message('Current panel is of the wrong type')
コード例 #22
0
ファイル: light_set.py プロジェクト: Leopardob/animShader
    def __set_renderer_by_str(self, value):
        """
        This function sets the active rendere from it s string name
        @param value: str, the name of the rendere
        """
        currPanel = cmds.getPanel(withFocus = 1)
        panelType = cmds.getPanel(to = currPanel)

        if value in self.RENDERERS_SHORTCUT:
            #create the mel command to eval
            cmd = 'setRendererInModelPanel \"{r}\" {cp};'.format(
                r = self.RENDERERS_SHORTCUT[value] , 
                cp = currPanel)
            
            #make sure we have a model panel active
            if (panelType == "modelPanel"):
                mel.eval(cmd)
            else :
                OpenMaya.MGlobal.displayError("In order to set stuff" +
                " on the viewport we need an acive viewport")

        else :
            #print the error
            strSupp = [str(k) for k in self.RENDERERS_SHORTCUT.keys()]
            supp = "\n-" +"\n- ".join(strSupp)
            OpenMaya.MGlobal.displayError("You did not provide a valid " + 
                "renderer name, supported renderer names are :" + 
                " \n {r}".format(r = supp) + 
                " \n got {v}".format(v= type(value).__name__))        
コード例 #23
0
def playblast(**kwargs):

    # Extract the camera from the active view.
    current_panel = cmds.getPanel(withFocus=True)
    panel_type = cmds.getPanel(typeOf=current_panel)
    if panel_type == 'modelPanel':
        camera = cmds.modelPanel(current_panel, query=True, camera=True)
        camera_attrs = dict((camera + '.' + k, v)
                            for k, v in settings['camera_attrs'].iteritems())
    else:
        cmds.warning(
            'Current panel is not a modelling panel; playblasts will not correctly setup the camera'
        )
        camera = None
        camera_attrs = {}

    # These should really be controlled elsewhere...
    kwargs.setdefault('widthHeight', (1280, 720))
    kwargs.setdefault('offScreen', True)
    kwargs.setdefault('forceOverwrite', True)
    kwargs.setdefault('percent', 100)

    # So much state! Can we have Python2.7 now?
    with context.attrs(settings['attrs'], camera_attrs):
        with context.command(cmds.camera,
                             camera,
                             edit=True,
                             **(settings['camera'] if camera else {})):
            with context.command(cmds.currentUnit, linear='cm', time='film'):
                return cmds.playblast(**kwargs)
コード例 #24
0
ファイル: display_lib.py プロジェクト: boochos/work
def altFrame(*args):
    # cmds.nodeType(sel), object type
    # optimize, real slow
    pnl = cmds.getPanel(withFocus=True)
    typ = cmds.getPanel(typeOf=pnl)
    if typ == 'modelPanel':
        sel = cmds.ls(sl=True, fl=True)
        gs = ac.GraphSelection()
        locs = []
        if sel:
            for item in sel:
                if cmds.objectType(item, i='transform') or cmds.objectType(item, i='joint'):
                    loc = cn.locator(obj=item, ro='zxy', X=0.35, constrain=False, shape=False)[0]
                    locs.append(loc)
                else:
                    try:
                        print cmds.listRelatives(item, parent=True)[0], '_______________'
                        loc = cn.locator(obj=cmds.listRelatives(item, parent=True)[0], ro='zxy', X=0.35, constrain=False, shape=False)
                        print loc, '_____________________'
                        loc = loc[0]
                        locs.append(loc)
                    except:
                        message('didnt frame object: ' + item)
            cmds.select(locs)
            mel.eval("fitPanel -selected;")
            cmds.delete(locs)
            gs.reselect()
        else:
            message('select an object')
    else:
        mel.eval("fitPanel -selected;")
コード例 #25
0
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
コード例 #26
0
ファイル: fx_fly_camera.py プロジェクト: jubeyjose/maya-prefs
    def getCamera(self):
        panelWithFocus = m.getPanel(withFocus=True)
        panelType = m.getPanel(typeOf=panelWithFocus)
        if panelType != 'modelPanel':
            self.showError(
                'Cannot find camera.' + (' ' * 100),
                'Select perspective viewport with camera without animation or locked channels.'
            )
            return None, None
        else:
            camera = m.modelPanel(panelWithFocus, q=True, camera=True)
            cameraShape = m.listRelatives(camera, shapes=True, fullPath=True)

            if m.getAttr(cameraShape[0] + '.orthographic'):
                self.showError(
                    'Cannot use orthographic camera.' + (' ' * 100),
                    'Select perspective viewport with camera without animation or locked channels.'
                )
                return None, None

            attrsToCheck = ('.tx', '.ty', '.tz', '.rx', '.ry', '.rz')
            for attr in attrsToCheck:
                if m.getAttr(camera + attr, lock=True) or m.listConnections(
                        camera + attr, s=True, d=False):
                    self.showError('Cannot use this camera.' + (' ' * 50),
                                   'This camera is locked or animated.')
                    return None, None

        return camera, cameraShape[0]
コード例 #27
0
    def initializeCallback(self):

        #get current model panel
        self.currentModelPanel = cmds.getPanel(wf = 1)
        if "modelPanel" not in self.currentModelPanel:
            self.currentModelPanel = cmds.getPanel(vis = 1)
            for i in self.currentModelPanel:
                if "modelPanel" in i:
                    self.currentModelPanel = i


        #try removing old callbacks from memory
        try:
            OpenMayaUI.MUiMessage.removeCallback(self.callBack)
        except:
            pass

        #create a callback that is registered after a frame is drawn with a 3D content but before 2D content
        self.callback = OpenMayaUI.MUiMessage.add3dViewPostRenderMsgCallback(self.currentModelPanel, self.update)
        self.view3D.refresh(True, True)

        #create QT maya window event filter
        main_window_ptr = OpenMayaUI.MQtUtil.mainWindow()
        self.qt_Maya_Window = wrapInstance(long(main_window_ptr), QtCore.QObject)
        self.qt_Maya_Window.installEventFilter(self.userKeyboardEvents) 

        #create viewport event filter
        active_view_ptr = self.view3D.widget()
        self.qt_Active_View = wrapInstance(long(active_view_ptr), QtCore.QObject)
        self.qt_Active_View.installEventFilter(self.userMouseEvents)

        cmds.inViewMessage( amg='<hl>Tool:</hl> Use <hl>"Esc"</hl> to cancel the tool', pos='botLeft', fade=True )

        print "Initialized..."
コード例 #28
0
def getCurrentCamera():
    '''
    Returns the camera that you're currently looking through.
    If the current highlighted panel isn't a modelPanel, 
    '''
    
    panel = mc.getPanel(withFocus=True)
    
    if mc.getPanel(typeOf=panel) != 'modelPanel':
        #just get the first visible model panel we find, hopefully the correct one.
        for p in mc.getPanel(visiblePanels=True):
            if mc.getPanel(typeOf=p) == 'modelPanel':
                panel = p
                mc.setFocus(panel)
                break
    
    if mc.getPanel(typeOf=panel) != 'modelPanel':
        OpenMaya.MGlobal.displayWarning('Please highlight a camera viewport.')
        return False
    
    camShape = mc.modelEditor(panel, query=True, camera=True)

    if not camShape:
        return False
    
    if mc.nodeType(camShape) == 'transform':
        return camShape
    elif mc.nodeType(camShape) == 'camera':
        return mc.listRelatives(camShape, parent=True)[0]
コード例 #29
0
ファイル: rcMaya.py プロジェクト: RobRuckus/rcTools
 def view(self,opt):
     panels=mc.getPanel(vis=1)
     for pane in panels:
         if mc.getPanel(to=pane) == 'modelPanel' : 
             mc.modelEditor(pane,e=1,sel=True)
             mc.modelEditor(pane,e=1,sel=False)
             mc.modelEditor(pane,e=1,sel=True)
コード例 #30
0
ファイル: modelpanel.py プロジェクト: you4jang/moonlight
def __get_panel():
    panels = cmds.getPanel(type='modelPanel')
    focus = cmds.getPanel(withFocus=True)
    if focus in panels:
        return focus
    pointer = cmds.getPanel(underPointer=True)
    if pointer in panels:
        return pointer
コード例 #31
0
ファイル: mscreen.py プロジェクト: csaez/mscreen
 def getCurrentModelPanel():
     currentModelPanel = mc.getPanel(wf=True)
     if "modelPanel" not in currentModelPanel:
         currentModelPanel = mc.getPanel(vis=True)
         for each in currentModelPanel:
             if "modelPanel" in each:
                 currentModelPanel = each
     return currentModelPanel
コード例 #32
0
def activePanel():
    fpanel = mc.getPanel( wf=1 )
    panelType = mc.getPanel( to=fpanel)
    if panelType == 'modelPanel':
        fpanel = mc.getPanel( wf=1 )
    else:
        fpanel = 'modelPanel4'
    return fpanel
コード例 #33
0
 def getCurrentModelPanel():
     currentModelPanel = mc.getPanel(wf=True)
     if "modelPanel" not in currentModelPanel:
         currentModelPanel = mc.getPanel(vis=True)
         for each in currentModelPanel:
             if "modelPanel" in each:
                 currentModelPanel = each
     return currentModelPanel
コード例 #34
0
def main():
    panel = cmds.getPanel(withFocus=True)
    if cmds.getPanel(typeOf=panel) == 'modelPanel':

        toggleState = cmds.modelEditor(panel,
                                       query=True,
                                       wireframeOnShaded=True)
        cmds.modelEditor(panel, edit=True, wireframeOnShaded=(not toggleState))
コード例 #35
0
def activePanel():
    fpanel = mc.getPanel(wf=1)
    panelType = mc.getPanel(to=fpanel)
    if panelType == "modelPanel":
        fpanel = mc.getPanel(wf=1)
    else:
        fpanel = "modelPanel4"
    return fpanel
コード例 #36
0
def batch_playblast(path, pattern):
    '''
    '''
    for filePath in glob.glob('{0}/*.m[ab]'.format(path)):

        #- open file
        if re.search('\.ma$', filePath):
            f_type = 'mayaAscii'
        elif re.search('\.mb$', filePath):
            f_type = 'mayaBinary'
        else:
            continue

        mc.file(filePath,
                typ=f_type,
                o=True,
                f=True,
                prompt=False,
                ignoreVersion=True)

        #- checking lost reference files
        unload_refs = [
            ref for ref in mc.file(q=True, r=True)
            if not mc.referenceQuery(ref, il=True)
        ]
        lost_refs = [
            ref for ref in unload_refs
            if not os.path.isfile(ref.split('{')[0])
        ]
        if lost_refs:
            continue

        #- checking cameras
        cameras = [
            cam
            for cam in mc.listRelatives(mc.ls(cameras=True), p=True) or list()
        ]
        cameras = [cam for cam in cameras if fnmatch.fnmatchcase(cam, pattern)]
        cameras.append('persp')

        #- set panels
        panels = mc.getPanel(vis=True)
        for pan in panels:
            if pan in mc.getPanel(typ='modelPanel'):
                mc.modelEditor(pan, e=True, alo=False)
                mc.modelEditor(pan,
                               e=True,
                               cam=cameras[0],
                               pm=True,
                               av=True,
                               da='smoothShaded')
                break

        #- blast
        vide_name = '{0}.mov'.format(os.path.splitext(filePath)[0])
        playblast(vide_name, view=False)

    return True
コード例 #37
0
ファイル: selectSets.py プロジェクト: Italic-/maya-prefs
 def turnOffCreateNewSetField(self):
     
     if not cmds.columnLayout(self.createNewSetLayout, query=True, visible=True): return
     
     cmds.iconTextButton (self.plusBtn, edit=True, visible=True, w=25)
     cmds.columnLayout(self.createNewSetLayout, edit=True, visible=False, w=1) 
     viewports = [view for view in cmds.getPanel(type='modelPanel') if view in cmds.getPanel(visiblePanels=True)]
     if len(viewports) > 0: cmds.setFocus(viewports[0])
     self.adjustButtonsWidth() 
コード例 #38
0
ファイル: utils.py プロジェクト: skarone/PipeL
def isolate( node ):
	"""isolate node"""
	nod = mn.Node( node )
	nod()
	currPanel = mc.getPanel( withFocus = True );
	panelType = mc.getPanel( to = currPanel )
	if panelType == 'modelPanel':
		mc.isolateSelect( currPanel, state = 1 )
		mm.eval( 'enableIsolateSelect %s 1;'%currPanel )
コード例 #39
0
ファイル: toggleCamera.py プロジェクト: natasha-c/ncTools
 def get_current_camera(self):
     current_panel = cmds.getPanel(withFocus=True)
     if current_panel != "":
         panel_type = cmds.getPanel(typeOf=current_panel)
         if panel_type == "modelPanel":
             current_camera = cmds.modelPanel(current_panel,
                                              query=True,
                                              camera=True)
     return current_camera
コード例 #40
0
ファイル: display_lib.py プロジェクト: boochos/work
def toggleGeo():
    pnl = cmds.getPanel(withFocus=True)
    if cmds.getPanel(to=pnl) == 'modelPanel':
        state = cmds.modelEditor(pnl, q=True, polymeshes=True)
        if state:
            cmds.modelEditor(pnl, e=True, polymeshes=0)
            # cmds.modelEditor(pnl, e=True, nurbsSurfaces=0)
        else:
            cmds.modelEditor(pnl, e=True, polymeshes=1)
コード例 #41
0
ファイル: utils.py プロジェクト: Rotomator/PipeL
def isolate(node):
    """isolate node"""
    nod = mn.Node(node)
    nod()
    currPanel = mc.getPanel(withFocus=True)
    panelType = mc.getPanel(to=currPanel)
    if panelType == 'modelPanel':
        mc.isolateSelect(currPanel, state=1)
        mm.eval('enableIsolateSelect %s 1;' % currPanel)
コード例 #42
0
ファイル: lighterHelperUI.py プロジェクト: skarone/PipeL
	def getCurrentCamera(self):
		pan = mc.getPanel(wf=1)
		cam = ""
		if ( "modelPanel" == mc.getPanel(to=pan) ):
			cam = mc.modelEditor(pan,q=1,camera=1);
			print mc.nodeType(cam)
		if(cam == ""):
			return None
		return mn.Node( cam );
コード例 #43
0
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   
コード例 #44
0
def getCurrentPanel():
    panel = mc.getPanel(withFocus=True)
    
    if mc.getPanel(typeOf=panel) != 'modelPanel':
        for p in mc.getPanel(visiblePanels=True):
            if mc.getPanel(typeOf=p) == 'modelPanel':
                panel = p
                break
        
    return panel if mc.getPanel(typeOf=panel) == 'modelPanel' else None
コード例 #45
0
def _openOutliner():

	outliners = cmds.getPanel(typ='outlinerPanel')
	panl = str(outliners[0])
	if _isobjectInList(cmds.getPanel(vis=1), 'outliner'):
		cmds.evalDeferred("import maya.cmds as cmds;cmds.outlinerEditor('%s', e=1, sc=1);" % panl)
	else:
		cmds.OutlinerWindow()
		cmds.evalDeferred("import maya.cmds as cmds; cmds.outlinerEditor('%s', e=1, sc=1);" % panl)
		cmds.evalDeferred("cmds.outlinerEditor('%s', e=1, sc=1);" % panl)
コード例 #46
0
def toggle_viewport_nurbs_curves():
    panel = cmds.getPanel(withFocus=True)

    if panel is not None:
        panelType = cmds.getPanel(typeOf=panel)

        # panel is model panel
        if panelType == "modelPanel" and panel:
            nc = not cmds.modelEditor(panel, q=True, nc=True)
            cmds.modelEditor(panel, e=True, nurbsCurves=nc)
コード例 #47
0
 def getScreenshot(self):
     #takes a screenshot of the current viewport
     if self.tempFile is None:
         filename = str(uuid.uuid4())
         self.tempFile = tempfile.gettempdir()+os.sep+filename+".png"
         
     cam = cmds.optionMenuGrp("frw_camera",q=True,value=True)
     
     #if not cam == "":
     #    cmds.lookThru(cam)
         
         
     panel = cmds.getPanel( withFocus=True )
     camera = ""
     if "modelPanel" == cmds.getPanel(typeOf=panel):
         camera = cmds.modelEditor(panel, q=True, camera=True)#`modelEditor -q -camera $panel`;
     else:
         return "screenshot"
         
     filmGate = cmds.camera(camera, q=True, displayFilmGate=True)
     resolutionGate = cmds.camera(camera, q=True, displayResolution=True)
     cmds.camera(camera,e=True, displayFilmGate=False)
     cmds.camera(camera,e=True, displayResolution=False)
     format = cmds.getAttr("defaultRenderGlobals.imageFormat")
     cmds.setAttr("defaultRenderGlobals.imageFormat", 32)
     
     modelWidth = cmds.layout(panel, q = True, width=True)
     modelHeight = cmds.layout(panel, q = True, height=True)
     
     renderWidth = cmds.getAttr("defaultResolution.width")
     renderHeight = cmds.getAttr("defaultResolution.height")
     
     if renderWidth < modelWidth and renderHeight<modelHeight:
         self.usingWidth = renderWidth
         self.usingHeight = renderHeight
     else:
         renderRatio = renderWidth/(renderHeight+0.0)
         widthRatio = renderWidth/(modelWidth+0.0)
         heightRatio = renderHeight/(modelHeight+0.0)
         if widthRatio<=1 and heightRatio<=1:
             usingWidth = renderWidth
             usingHeight = renderHeight
         elif widthRatio > heightRatio:
             self.usingWidth = int(modelWidth)
             self.usingHeight = int(modelWidth/renderRatio)
         else:
             self.usingWidth = int(modelHeight*renderRatio)
             self.usingHeight = int(modelHeight)
            
     time = cmds.currentTime( query=True )
     cmds.playblast(frame=time, format="image",cf=self.tempFile, v =0,orn=0,w=self.usingWidth, h=self.usingHeight, p = 100)
     cmds.setAttr("defaultRenderGlobals.imageFormat",format)
     cmds.camera(camera, e=True, displayFilmGate=filmGate)
     cmds.camera(camera, e=True, displayResolution=resolutionGate)
     return "screenshot="+self.tempFile
コード例 #48
0
ファイル: coopLib.py プロジェクト: zhuzenghui666/MNPR
def getActiveModelPanel():
    """
    Get the active model editor panel
    Returns:
        modelPanel name (str)
    """
    activePanel = cmds.getPanel(wf=True)
    if cmds.getPanel(typeOf=activePanel) == 'modelPanel':
        return activePanel
    else:
        return cmds.playblast(ae=True)
コード例 #49
0
def getCurrentCamera():
    panel = mc.getPanel(withFocus=True)

    if mc.getPanel(typeOf=panel) != 'modelPanel':
        for p in mc.getPanel(visiblePanels=True):
            if mc.getPanel(typeOf=p) == 'modelPanel':
                panel = p
                break

    return mc.modelEditor(panel, query=True, camera=True) if mc.getPanel(
        typeOf=panel) == 'modelPanel' else None
コード例 #50
0
 def setGates(self, vals):
     panel = cmds.getPanel( withFocus=True )
     camera = ""
     if "modelPanel" == cmds.getPanel(typeOf=panel):
         camera = cmds.modelEditor(panel, q=True, camera=True)#`modelEditor -q -camera $panel`;
         
     filmGate = cmds.camera(camera, q=True, displayFilmGate=True)
     resolutionGate = cmds.camera(camera, q=True, displayResolution=True)
     cmds.camera(camera,e=True, displayFilmGate=vals[0])
     cmds.camera(camera,e=True, displayResolution=vals[1])
     return [filmGate,resolutionGate]
コード例 #51
0
ファイル: Engine.py プロジェクト: DavideAlidosi/May9
 def show(cls, menu_type, menu_name, preferences, **kwargs):
     """create marking menu"""
     cls.hide(kwargs["b"])
     if not menu_name:
         return
     if menu_type == cls.MEL:
         cls._mel(menu_name, p=cmds.layout(cmds.getPanel(up=True), q=True, p=True), aob=True, mm=True, **kwargs)
     elif menu_type == cls.PYTHON:
         cls._python(menu_name, p=cmds.layout(cmds.getPanel(up=True), q=True, p=True), aob=True, mm=True, **kwargs)
     else:
         cls._preset(menu_name, preferences, p=cmds.layout(cmds.getPanel(up=True), q=True, p=True), aob=True,
                     mm=True, **kwargs)
コード例 #52
0
def get_model():
    """
    This function returns the currently active modelPanel
    @return str
    """
    currPanel = cmds.getPanel(withFocus = 1)
    panelType = cmds.getPanel(to = currPanel)
    if (panelType == "modelPanel"): 
        return currPanel
    else :
        OpenMaya.MGlobal.displayWarning("Could not find an active \
            viewport, plase select one and re-run")
コード例 #53
0
ファイル: pipeUtilities.py プロジェクト: sid2364/Maya_Python
def getActiveViewport(silent = True):
    viewport = mc.getPanel(wf = True)
    if not viewport:
        msgWin('Error', 'Couldn\'t get active viewport', silent)
        return False
    if not viewport.startswith('modelPanel'):
        try:
            viewport = [x for x in mc.getPanel(vis=True) if x.startswith('modelPanel')][0]
        except:
            msgWin('Error', 'Couldn\'t get active viewport', silent)
            return False
    return viewport
コード例 #54
0
ファイル: isolateSelected.py プロジェクト: auqeyjf/glTools
def getPanel():
	'''
	Get current model panel with focus
	'''
	# Get Panel with Focus
	panel = mc.getPanel(wf=True)
	
	# Check Model Panel
	if not mc.modelPanel(panel,q=True,ex=True):
		panel = mc.getPanel(type='modelPanel')[0]
	
	# Return Result
	return panel
コード例 #55
0
def getPanel():
    """
    Get current model panel with focus
    """
    # Get Panel with Focus
    panel = cmds.getPanel(wf=True)

    # Check Model Panel
    if not cmds.modelPanel(panel, q=True, ex=True):
        panel = cmds.getPanel(type='modelPanel')[0]

    # Return Result
    return panel
コード例 #56
0
ファイル: fx_lib.py プロジェクト: vipul-rathod/lsapipeline
def _getCam_centerOfInterest():
	## Get camera from current view
	currentPanel = cmds.getPanel(withFocus= True) or 'modelPanel4'

	## Only works with view port active, else create at default world 0, 0, 0
	panelType = cmds.getPanel(typeOf = currentPanel)
	if panelType !=  "modelPanel":
		return [0, 0, 0]
	else:
		camera = cmds.modelPanel(currentPanel, query = True, camera = True)
		cameraShape = cmds.listRelatives(camera) or camera
		position = cmds.camera(cameraShape, query = True, worldCenterOfInterest = True)

		return [ position[0], 0, position[2] ]
コード例 #57
0
def check_camera_name():
    """Get the active panel's camera.
    Return its status compared to stockCamNames."""
    activepanel = cmds.getPanel(withFocus=True)

    if cmds.getPanel(typeOf=activepanel) == 'modelPanel':
        cam = cmds.modelEditor(activepanel, query=True, camera=True)
        if cam in stockCamNames:
            return True
        else:
            return False

    else:
        return None
コード例 #58
0
ファイル: view.py プロジェクト: ewerybody/melDrop
def toggleGrid():
    panel = mc.getPanel(withFocus=True)
    ptype = mc.getPanel(typeOf=panel)
    # if in UV Editor toggle the according grid there
    if ptype == 'scriptedPanel' and panel.startswith('polyTexturePlacementPanel'):
        state = mc.textureWindow(panel, q=True, tgl=True)
        mc.textureWindow(panel, e=True, tgl=not state)
    # else use these 2 grid toggelling methods to switch it for sure
    elif ptype == 'modelPanel':
        state = True
        if mc.grid(q=True, toggle=True) or mc.modelEditor(panel, q=True, grid=True):
            state = False
        mc.grid(toggle=state)
        mc.modelEditor(panel, e=True, grid=state)