API Documentation

Viewport

class mvp.Viewport(m3dview)

A convenient api for manipulating Maya 3D Viewports. While you can manually construct a Viewport from an OpenMayaUI.M3dView instance, it is much easier to use the convenience methods Viewport.iter, Viewport.active and Viewport.get:

# Get the active view
v = Viewport.active()
assert v.focus == True

# Assuming we have a second modelPanel available
# Get an inactive view and make it the active view
v2 = Viewport.get(1)
v2.focus = True

assert v.focus == False
assert v2.focus == True

Viewport provides standard attribute lookup to all modelEditor properties:

# Hide nurbsCurves and show polymeshes in the viewport
v.nurbsCurves = False
v.polymeshes = True
Parameters:m3dview – OpenMayaUI.M3dView instance.
classmethod active()

Get the active Viewport.

background

Get the background color of the Viewport

camera

Get the short name of the active camera.

classmethod clear_identifiers()

Remove all the QLabels drawn by show_identifiers.

close()

Close this viewport

copy()

Tear off a copy of the viewport.

Returns:A new torn off copy of Viewport
static count()

The number of 3D Viewports.

depthOfField

Get active camera depthOfField attribute

draw_identifier(text)

Draws an identifier in a Viewport.

float()

Tear off the panel.

focus

Check if current Viewport is the active Viewport.

classmethod get(index)

Get the Viewport at index.

get_state()

Get a state dictionary of all modelEditor properties.

classmethod identify(delay=2000)

Shows identifiers in all Viewports:

Viewport.identify()
Parameters:delay – Length of time in ms to leave up identifier
index

Returns the index of the viewport

classmethod iter()

Yield all Viewport objects.

usage:

for view in Viewport.iter():
    print v.panel
panel

Returns a panel name for the Viewport.

playblast(filename, **kwargs)

Playblasting with reasonable default arguments. Automatically sets this viewport to the active view, ensuring that we playblast the correct view.

Parameters:
  • filename – Absolute path to output file
  • kwargs – Same kwargs as maya.cmds.playblast()
properties

A list including all editor property names.

set_state(state)

Sets a dictionary of properties all at once.

Parameters:state – Dictionary including property, value pairs
classmethod show_identifiers()

Draws QLabels indexing each Viewport. These indices can be used to with :method:`get` to return a corresponding Viewport object.

widget

Returns a QWidget object for the viewport.

window

Returns a QWidget object for the viewports parent window

RenderGlobals

mvp.RenderGlobals

alias of <Mock name='mock.cmds.getAttr()' id='140399063905488'>