Extend polygons selection to shell
This file contains 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 om | |
import maya.cmds as cmds | |
def expandSelection(): | |
sel = om.MSelectionList() | |
om.MGlobal.getActiveSelectionList(sel) | |
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(): | |
currfaces.append(itr.index()) | |
itr.next() | |
# 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) | |
expandSelection() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment