Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm confused about the usage of OpenMaya.MGlobal.isSelected(). I want to use this method to detect if an mObject is selected in the viewport, but this method always returns False.
I'm using the python code below in Maya's Script Editor to test the method:
import maya.api.OpenMaya as OpenMaya
selectionList = OpenMaya.MGlobal.getActiveSelectionList() # Use this to get a selection
# list containing all selected
# objects
mObject1 = selectionList.getDependNode(0) # Get the first OpenMaya.MObject instance in
# the selection list, mObject1 is of type
# OpenMaya.MObject
print(OpenMaya.MGlobal.isSelected(mObject1)) # I think it will return True,
# because mObject1 is from the
# selectionList, but it returns False
You can view the test scene in the attachment.
OpenMaya.MGlobal.isSelected() is documented on the page below:
Solved! Go to Solution.