Hi again all,
I’m trying to figure out how the flag kSurfaceSelectMethod is supposed to work in combination with om.MGlobal.selectFromScreen() function, and was hoping someone knew or could test this (code below)
What I want is to select only faces that are visible to the camera, which I already do with the code below. However by default the screen selection function uses the flag kWireframeSelectMethod, which means that objects in front of your target will not occlude the selection of faces, since in wireframe mode you can see through those objects. I want to use kSurfaceSelectMethod instead, but adding that as an argument does not change the behavior, so this is either a bug in Maya 2018.5 or I’m missing something…
import pymel.core as pmc import maya.OpenMaya as om import maya.api.OpenMayaUI as mui # get selection modes pmc.selectMode(component=True) pmc.selectType(polymeshFace=True) pmc.selectPref(useDepth=True) # only select faces visible to the camera pmc.refresh() active_view = mui.M3dView.active3dView() om.MGlobal.selectFromScreen(0, 0, active_view.portWidth(), active_view.portHeight(), om.MGlobal.kReplaceList, om.MGlobal.kSurfaceSelectMethod) # you may want to uncomment this to get your selection working normally #pmc.selectPref(ud=False) # Reset mask back to default behavior
Here’s a visual of what I hoped would happen
Can anyone confirm this or tell me what I’m doing wrong?