MSelectionList selList; MGlobal::getActiveSelectionList(selList); MDagPath dagPath; selList.getDagPath(0, dagPath);
MDagPath parentPath = ...; unsigned int numChildren = parentPath.childCount(); for (unsigned int i = 0; i < numChildren; i++) { MDagPath childPath = parentPath.child(i); // Do something with childPath }This example uses the `childCount` function to get the number of children attached to a given `MDagPath`, and then iterates through each child using the `child` function to retrieve the `MDagPath` for each child. These examples use the Maya API, which is part of the Autodesk Maya software package. The C++ code for using the Maya API is typically compiled as a plugin for Maya, and uses the libraries provided by Maya to interact with the scene.