Created
August 29, 2015 11:31
-
-
Save SEVEZ/353829b70243092c336a to your computer and use it in GitHub Desktop.
Select all visible objects in viewport
From http://www9.atwiki.jp/hajimen/pages/124.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.OpenMaya as OpenMaya | |
import maya.OpenMayaUI as OpenMayaUI | |
def selectAllVisibleObjectsFromScreen(): | |
activePane=OpenMayaUI.M3dView.active3dView() | |
w=activePane.portWidth() | |
h=activePane.portHeight() | |
myX=OpenMaya.MScriptUtil() | |
myX.createFromInt(0) | |
myY=OpenMaya.MScriptUtil() | |
myY.createFromInt(0) | |
myEndX=OpenMaya.MScriptUtil() | |
myEndX.createFromInt(w) | |
myEndY=OpenMaya.MScriptUtil() | |
myEndY.createFromInt(h) | |
OpenMaya.MGlobal.selectFromScreen( | |
myX.asShortPtr(), | |
myY.asShortPtr(), | |
myEndX.asShortPtr(), | |
myEndY.asShortPtr(), | |
OpenMaya.MGlobal.kReplaceList | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the simplest method :)
import maya.OpenMaya as om
import maya.OpenMayaUI as omUI
view = omUI.M3dView.active3dView()
om.MGlobal.selectFromScreen( 0, 0, view.portWidth(), view.portHeight(), om.MGlobal.kReplaceList)