Selecting Nodes By Name
Selecting objects within the Maya API is a relatively simple thing to achieve. MGlobal contains a number of static functions that allow us to query and set the currently selected items.
The enum MGlobal::ListAdjustment defines how the selection will work. The following are the valid enum values which can be provided to most selection functions.
MGlobal::kReplaceList
MGlobal::kXORWithList
MGlobal::kAddToList
MGlobal::kRemoveFromList
Probably the simplest method of selecting objects in by is to use the MGlobal::selectByName() function.
Maya uses the MSelectionList class to manipulate the current (Active in maya speak) selection list. As a basic example, to retrieve the currently selected objects, we simply need to query the Active selection list via MGlobal.