當前位置: 首頁>>代碼示例>>Python>>正文


Python cmds.getPanel方法代碼示例

本文整理匯總了Python中maya.cmds.getPanel方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.getPanel方法的具體用法?Python cmds.getPanel怎麽用?Python cmds.getPanel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.getPanel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: parse_active_panel

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
def parse_active_panel():
    """Parse the active modelPanel.

    Raises
        RuntimeError: When no active modelPanel an error is raised.

    Returns:
        str: Name of modelPanel

    """

    panel = cmds.getPanel(withFocus=True)

    # This happens when last focus was on panel
    # that got deleted (e.g. `capture()` then `parse_active_view()`)
    if not panel or "modelPanel" not in panel:
        raise RuntimeError("No active model panel found")

    return panel 
開發者ID:bumpybox,項目名稱:pyblish-bumpybox,代碼行數:21,代碼來源:capture.py

示例2: getModelPanel

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
def getModelPanel():
    '''Return the active or first visible model panel.'''
    
    panel = mc.getPanel(withFocus=True)

    if mc.getPanel(typeOf=panel) != 'modelPanel':
        #just get the first visible model panel we find, hopefully the correct one.
        panels = getModelPanels()
        if panels:
            panel = panels[0]
            mc.setFocus(panel)
    
    if mc.getPanel(typeOf=panel) != 'modelPanel':
        OpenMaya.MGlobal.displayWarning('Please highlight a camera viewport.')
        return None
    return panel 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:18,代碼來源:ml_utilities.py

示例3: enter_widget

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
def enter_widget(self):
        """ set focuts to the panel under the cursor """

        panel = cmds.getPanel(underPointer=True)
        cmds.setFocus(panel)
        self.setFocus() 
開發者ID:wiremas,項目名稱:spore,代碼行數:8,代碼來源:canvas.py

示例4: initializeCallback

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
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..." 
開發者ID:volodinroman,項目名稱:mViewportDrawOpenGL,代碼行數:36,代碼來源:ViewportPainter.py

示例5: get_current_panel

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
def get_current_panel(cls):
        current = cmds.getPanel(wf=True)
        try:
            return cls.get(current)
        except RuntimeError:
            return None 
開發者ID:theodox,項目名稱:mGui,代碼行數:8,代碼來源:panels.py

示例6: get

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
def get(cls, panel_string):
        ptype = cmds.getPanel(typeOf=panel_string)
        pfclass = cls.TYPES.get(ptype, None)
        if not pfclass:
            raise RuntimeError("Unknown panel type: {}".format(ptype))
        return pfclass.wrap(panel_string, panel_string) 
開發者ID:theodox,項目名稱:mGui,代碼行數:8,代碼來源:panels.py

示例7: getWidgetUnderPointer

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
def getWidgetUnderPointer():
	panel = cmds.getPanel(underPointer=True)
	if not panel:
		return None

	ptr = mui.MQtUtil.findControl(panel)
	widget = sip.wrapinstance(long(ptr), QtCore.QObject)
	return widget 
開發者ID:justinfx,項目名稱:tutorials,代碼行數:10,代碼來源:mqtutil.py

示例8: getGraphEditorOutliner

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
def getGraphEditorOutliner():
    graphEditor = mc.getPanel(scriptType='graphEditor')
    if graphEditor:
        return mc.animCurveEditor(graphEditor[0]+'GraphEd', query=True, outliner=True)
    return None 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:7,代碼來源:ml_graphEditorMask.py

示例9: showAll

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
def showAll(*args):

    try:
        mc.delete(ATTR_FILTER_NAME)
    except:pass

    for ge in mc.getPanel(scriptType='graphEditor'):
        mm.eval('filterUIClearFilter  {};'.format(mc.animCurveEditor(ge+'GraphEd', query=True, outliner=True))) 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:10,代碼來源:ml_graphEditorMask.py

示例10: getCurrentCamera

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
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

    camNodeType = mc.nodeType(camShape)
    if mc.nodeType(camShape) == 'transform':
        return camShape
    elif mc.nodeType(camShape) in ['camera','stereoRigCamera']:
        return mc.listRelatives(camShape, parent=True, path=True)[0] 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:31,代碼來源:ml_utilities.py

示例11: getModelPanels

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
def getModelPanels():
    '''Return all the model panels visible so you can operate on them.'''
    panels = []
    for p in mc.getPanel(visiblePanels=True):
        if mc.getPanel(typeOf=p) == 'modelPanel':
            panels.append(p)
    return panels 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:9,代碼來源:ml_utilities.py

示例12: visibleInGraphEditor

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
def visibleInGraphEditor(self):
        '''
        Initializes the keySelection object with curves visibile in graph editor.
        Returns True if successful.
        '''


        if not 'graphEditor1' in mc.getPanel(visiblePanels=True):
            return False

        graphVis = mc.selectionConnection('graphEditor1FromOutliner', query=True, obj=True)

        if not graphVis:
            return False

        for each in graphVis:
            try:
                self._curves.extend(mc.keyframe(each, query=True, name=True))
            except StandardError:
                pass


        if not self._curves:
            return False

        return True 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:28,代碼來源:ml_utilities.py

示例13: generate_panels

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
def generate_panels(filename):
    with open(filename, 'wt') as filehandle:
        filehandle.write("'''\nmGui wrapper classes\n\nAuto-generated wrapper classes for use with mGui\n'''\n\n")
        filehandle.write('''
        import maya.cmds as cmds
        from mGui.core import Control
        from mGui.core.editors import EditorFactory
        from mGui.properties import WrappedCtlProperty
        def make_editor_command(cmd, editorString):
            return WrappedCtlProperty(editorString, cmd, True, EditorFactory.get)
        ''')

        for each_class in constants.PANEL_COMMANDS:
            try:
                filehandle.write(PanelInfo.from_command(each_class).template())
                filehandle.write('\n\n')

            except RuntimeError:
                filehandle.write("# command '%s' not present in this maya" % each_class)



        filehandle.write('''
        class PanelFactory(object):
            TYPES = {
                'modelPanel': ModelPanel,
                'hardwareRenderPanel': HardwareRenderPanel,
                'hyperGraph': HyperGraph,
                'hyperPanel': HyperPanel,
                'hyperShade': HyperShade,
                'nodeOutliner': NodeOutliner,
                'outlinerPanel': OutlinerPanel,
                'panelConfiguration': PanelConfiguration,
                'panelHistory': PanelHistory,
                'scriptedPanel': ScriptedPanel,
                'spreadSheetEditor': SpreadSheetEditor,
                'visor': Visor
            }

            @classmethod
            def get_current_panel(cls):
                current = cmds.getPanel(wf=True)
                try:
                    return cls.get(current)
                except RuntimeError:
                    return None

            @classmethod
            def get(cls, panel_string):
                ptype = cmds.getPanel(typeOf=panel_string)
                pfclass = cls.TYPES.get(ptype, None)
                if not pfclass:
                    raise RuntimeError("Unknown panel type: {}".format(ptype))
                return pfclass.wrap(panel_string, panel_string)\n''') 
開發者ID:theodox,項目名稱:mGui,代碼行數:56,代碼來源:preformat.py

示例14: frameGraphEditor

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
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 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:58,代碼來源:ml_frameGraphEditor.py

示例15: get_current_camera

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import getPanel [as 別名]
def get_current_camera():
    """Returns the currently active camera.

    Searched in the order of:
        1. Active Panel
        2. Selected Camera Shape
        3. Selected Camera Transform

    Returns:
        str: name of active camera transform

    """

    # Get camera from active modelPanel  (if any)
    panel = cmds.getPanel(withFocus=True)
    if cmds.getPanel(typeOf=panel) == "modelPanel":
        cam = cmds.modelEditor(panel, query=True, camera=True)
        # In some cases above returns the shape, but most often it returns the
        # transform. Still we need to make sure we return the transform.
        if cam:
            if cmds.nodeType(cam) == "transform":
                return cam
            # camera shape is a shape type
            elif cmds.objectType(cam, isAType="shape"):
                parent = cmds.listRelatives(cam, parent=True, fullPath=True)
                if parent:
                    return parent[0]

    # Check if a camShape is selected (if so use that)
    cam_shapes = cmds.ls(selection=True, type="camera")
    if cam_shapes:
        return cmds.listRelatives(cam_shapes,
                                  parent=True,
                                  fullPath=True)[0]

    # Check if a transform of a camShape is selected
    # (return cam transform if any)
    transforms = cmds.ls(selection=True, type="transform")
    if transforms:
        cam_shapes = cmds.listRelatives(transforms, shapes=True, type="camera")
        if cam_shapes:
            return cmds.listRelatives(cam_shapes,
                                      parent=True,
                                      fullPath=True)[0] 
開發者ID:Colorbleed,項目名稱:maya-capture-gui,代碼行數:46,代碼來源:lib.py


注:本文中的maya.cmds.getPanel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。