本文整理匯總了Python中maya.cmds.modelEditor方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.modelEditor方法的具體用法?Python cmds.modelEditor怎麽用?Python cmds.modelEditor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類maya.cmds
的用法示例。
在下文中一共展示了cmds.modelEditor方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _applied_viewport_options
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import modelEditor [as 別名]
def _applied_viewport_options(options, panel):
"""Context manager for applying `options` to `panel`"""
options = dict(ViewportOptions, **(options or {}))
# separate the plugin display filter options since they need to
# be set differently (see #55)
plugins = cmds.pluginDisplayFilter(query=True, listFilters=True)
plugin_options = dict()
for plugin in plugins:
if plugin in options:
plugin_options[plugin] = options.pop(plugin)
# default options
cmds.modelEditor(panel, edit=True, **options)
# plugin display filter options
for plugin, state in plugin_options.items():
cmds.modelEditor(panel, edit=True, pluginObjects=(plugin, state))
yield
示例2: test_apply_parsed_view_exact
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import modelEditor [as 別名]
def test_apply_parsed_view_exact():
"""Apply parsed view sanity check works"""
import maya.cmds as cmds
panel = "modelPanel1"
cmds.modelEditor(panel, edit=True, displayAppearance="wireframe")
parsed = capture.parse_view(panel)
display = parsed["viewport_options"]["displayAppearance"]
assert display == "wireframe"
# important to test both, just in case wireframe was already
# set when making the first query, and to make sure this
# actually does something.
cmds.modelEditor(panel, edit=True, displayAppearance="smoothShaded")
parsed = capture.parse_view(panel)
display = parsed["viewport_options"]["displayAppearance"]
assert display == "smoothShaded"
capture.apply_view(panel,
viewport_options={"displayAppearance": "wireframe"})
assert cmds.modelEditor(panel,
query=True,
displayAppearance=True) == "wireframe"
示例3: _applied_viewport_options
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import modelEditor [as 別名]
def _applied_viewport_options(options, panel):
"""Context manager for applying `options` to `panel`"""
options = dict(ViewportOptions, **(options or {}))
# separate the plugin display filter options since they need to
# be set differently (see #55)
plugins = cmds.pluginDisplayFilter(query=True, listFilters=True)
plugin_options = dict()
for plugin in plugins:
if plugin in options:
plugin_options[plugin] = options.pop(plugin)
# default options
cmds.modelEditor(panel, edit=True, **options)
# plugin display filter options
for plugin, state in plugin_options.items():
cmds.modelEditor(panel, edit=True, pluginObjects=(plugin, state))
yield
示例4: get_outputs
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import modelEditor [as 別名]
def get_outputs(self):
"""
Retrieve all settings of each available sub widgets
:return:
"""
inputs = self.get_inputs(as_preset=False)
outputs = dict()
outputs['off_screen'] = inputs['off_screen']
import capture_gui.lib
# Get isolate view members of the active panel
if inputs['isolate_view']:
panel = capture_gui.lib.get_active_editor()
filter_set = mc.modelEditor(panel, query=True, viewObjects=True)
isolate = mc.sets(filter_set, query=True) if filter_set else None
outputs['isolate'] = isolate
return outputs
示例5: apply_view
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import modelEditor [as 別名]
def apply_view(panel, **options):
"""Apply options to panel"""
camera = cmds.modelPanel(panel, camera=True, query=True)
# Display options
display_options = options.get("display_options", {})
for key, value in display_options.iteritems():
if key in _DisplayOptionsRGB:
cmds.displayRGBColor(key, *value)
else:
cmds.displayPref(**{key: value})
# Camera options
camera_options = options.get("camera_options", {})
for key, value in camera_options.iteritems():
cmds.setAttr("{0}.{1}".format(camera, key), value)
# Viewport options
viewport_options = options.get("viewport_options", {})
for key, value in viewport_options.iteritems():
cmds.modelEditor(panel, edit=True, **{key: value})
viewport2_options = options.get("viewport2_options", {})
for key, value in viewport2_options.iteritems():
attr = "hardwareRenderingGlobals.{0}".format(key)
cmds.setAttr(attr, value)
示例6: getCurrentCamera
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import modelEditor [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]
示例7: get_renderers
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import modelEditor [as 別名]
def get_renderers(self):
"""Collect all available renderers for playblast"""
active_editor = lib.get_active_editor()
renderers_ui = cmds.modelEditor(active_editor,
query=True,
rendererListUI=True)
renderers_id = cmds.modelEditor(active_editor,
query=True,
rendererList=True)
renderers = dict(zip(renderers_ui, renderers_id))
renderers.pop("Stub Renderer")
return renderers
示例8: parse_view
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import modelEditor [as 別名]
def parse_view(panel):
"""Parse the scene, panel and camera for their current settings
Example:
>>> parse_view("modelPanel1")
Arguments:
panel (str): Name of modelPanel
"""
camera = cmds.modelPanel(panel, query=True, camera=True)
# Display options
display_options = {}
for key in DisplayOptions:
if key in _DisplayOptionsRGB:
display_options[key] = cmds.displayRGBColor(key, query=True)
else:
display_options[key] = cmds.displayPref(query=True, **{key: True})
# Camera options
camera_options = {}
for key in CameraOptions:
camera_options[key] = cmds.getAttr("{0}.{1}".format(camera, key))
# Viewport options
viewport_options = {}
# capture plugin display filters first to ensure we never override
# built-in arguments if ever possible a plugin has similarly named
# plugin display filters (which it shouldn't!)
plugins = cmds.pluginDisplayFilter(query=True, listFilters=True)
for plugin in plugins:
plugin = str(plugin) # unicode->str for simplicity of the dict
state = cmds.modelEditor(panel, query=True, queryPluginObjects=plugin)
viewport_options[plugin] = state
for key in ViewportOptions:
viewport_options[key] = cmds.modelEditor(
panel, query=True, **{key: True})
viewport2_options = {}
for key in Viewport2Options.keys():
attr = "hardwareRenderingGlobals.{0}".format(key)
try:
viewport2_options[key] = cmds.getAttr(attr)
except ValueError:
continue
return {
"camera": camera,
"display_options": display_options,
"camera_options": camera_options,
"viewport_options": viewport_options,
"viewport2_options": viewport2_options
}
示例9: _independent_panel
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import modelEditor [as 別名]
def _independent_panel(width, height, off_screen=False):
"""Create capture-window context without decorations
Arguments:
width (int): Width of panel
height (int): Height of panel
Example:
>>> with _independent_panel(800, 600):
... cmds.capture()
"""
# center panel on screen
screen_width, screen_height = _get_screen_size()
topLeft = [int((screen_height-height)/2.0),
int((screen_width-width)/2.0)]
window = cmds.window(width=width,
height=height,
topLeftCorner=topLeft,
menuBarVisible=False,
titleBar=False,
visible=not off_screen)
cmds.paneLayout()
panel = cmds.modelPanel(menuBarVisible=False,
label='CapturePanel')
# Hide icons under panel menus
bar_layout = cmds.modelPanel(panel, q=True, barLayout=True)
cmds.frameLayout(bar_layout, edit=True, collapse=True)
if not off_screen:
cmds.showWindow(window)
# Set the modelEditor of the modelPanel as the active view so it takes
# the playback focus. Does seem redundant with the `refresh` added in.
editor = cmds.modelPanel(panel, query=True, modelEditor=True)
cmds.modelEditor(editor, edit=True, activeView=True)
# Force a draw refresh of Maya so it keeps focus on the new panel
# This focus is required to force preview playback in the independent panel
cmds.refresh(force=True)
try:
yield panel
finally:
# Delete the panel to fix memory leak (about 5 mb per capture)
cmds.deleteUI(panel, panel=True)
cmds.deleteUI(window)
示例10: parse_view
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import modelEditor [as 別名]
def parse_view(panel):
"""Parse the scene, panel and camera for their current settings
Example:
>>> parse_view("modelPanel1")
Arguments:
panel (str): Name of modelPanel
"""
camera = cmds.modelPanel(panel, query=True, camera=True)
# Display options
display_options = {}
for key in DisplayOptions:
if key in _DisplayOptionsRGB:
display_options[key] = cmds.displayRGBColor(key, query=True)
else:
display_options[key] = cmds.displayPref(query=True, **{key: True})
# Camera options
camera_options = {}
for key in CameraOptions:
camera_options[key] = cmds.getAttr("{0}.{1}".format(camera, key))
# Viewport options
viewport_options = {}
# capture plugin display filters first to ensure we never override
# built-in arguments if ever possible a plugin has similarly named
# plugin display filters (which it shouldn't!)
plugins = cmds.pluginDisplayFilter(query=True, listFilters=True)
for plugin in plugins:
plugin = str(plugin) # unicode->str for simplicity of the dict
state = cmds.modelEditor(panel, query=True, queryPluginObjects=plugin)
viewport_options[plugin] = state
for key in ViewportOptions:
viewport_options[key] = cmds.modelEditor(
panel, query=True, **{key: True})
viewport2_options = {}
for key in Viewport2Options.keys():
attr = "hardwareRenderingGlobals.{0}".format(key)
try:
viewport2_options[key] = cmds.getAttr(attr)
except ValueError:
continue
return {
"camera": camera,
"display_options": display_options,
"camera_options": camera_options,
"viewport_options": viewport_options,
"viewport2_options": viewport2_options
}
示例11: get_current_camera
# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import modelEditor [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]