当前位置: 首页>>代码示例>>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;未经允许,请勿转载。