So far, my best idea is to use PyMel:

import pymel.core as pm
pmMesh = pm.PyNode(meshFn.fullPathName())
pmFaces = pm.MeshFace(pmMesh, faceIds)
pm.select(pmFaces)

On Monday, 9 April 2018 15:12:03 UTC+10, Michael Boon wrote:
>
> 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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/bddf8e6f-6dc2-4e99-9432-9f8ed47bc44c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to