Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Extend polygons selection to shell
import maya.OpenMaya as om
import maya.cmds as cmds
def expandSelection():
sel = om.MSelectionList()
dag = om.MDagPath()
obj = om.MObject()
# get the active object (dag) and its selected components (obj)
sel.getDagPath(0, dag, obj)
# Here we create an iterator over the selected components
itr = om.MItMeshPolygon(dag, obj)
# Now we add all faces of the selection to the array
currfaces = om.MIntArray()
while not itr.isDone():
# finally we reconvert the MIntArray to a simple list
currfaces = list(currfaces)
# and use maya.cmds to extend the polygon-selection to their shells
cmds.polySelect(dag.fullPathName(), extendToShell = currfaces, add=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment