本文整理匯總了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
示例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
示例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()
示例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..."
示例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
示例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)
示例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
示例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
示例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)))
示例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]
示例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
示例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
示例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''')
示例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
示例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]