本文整理汇总了Python中maya.cmds.getPanel函数的典型用法代码示例。如果您正苦于以下问题:Python getPanel函数的具体用法?Python getPanel怎么用?Python getPanel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getPanel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
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)
示例2: toggleObjectDisplay
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')
示例3: setThreePanelLayout
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)
示例4: getPanel
def getPanel():
isModelPanel = False
panel = cmds.getPanel(withFocus=True)
panelType = cmds.getPanel(typeOf=panel)
if panelType == "modelPanel":
isModelPanel = True
return isModelPanel, panel
示例5: view
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)
示例6: isolate
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: desIsolate
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 )
示例8: get_panel_type
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
示例9: altFrame
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;")
示例10: __set_renderer_by_str
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__))
示例11: initializeCallback
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..."
示例12: getCurrentCamera
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]
示例13: getCurrentModelPanel
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
示例14: activePanel
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
示例15: activePanel
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