It looks like the appropriate C++ function is MGlobal::selectCommand, but 
that isn't available in Python.

On Monday, 9 April 2018 14:32:12 UTC+10, Michael Boon wrote:
> Hi,
> If I change the selection using the API, for example:
> import maya.api.OpenMaya as om
> # meshFn is a MFnMesh attached to an object in the scene
> # faceIds is a MIntArray
> compFn = om.MFnSingleIndexedComponent()
> compObj = compFn.create(om.MFn.kMeshPolygonComponent)
> compFn.addElements(faceIds)
> sList = om.MSelectionList()
> sList.add((meshFn.getPath(), compObj))
> om.MGlobal.setActiveSelectionList(sList)
> How do I make that play nicely with undo? Currently it doesn't affect the 
> undo stack at all, so undoing undoes whatever happened before it, and 
> redoing doesn't redo it, so the selection ends up wrong.
> MDGModifier doesn't seem to be relevant to selection.
> Thanks,
> Boon

You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To view this discussion on the web visit
For more options, visit

Reply via email to