API Guide > Selecting with the API >

# setObject() method

The setObject() method on MFnDagNode is inherited by all function sets from MFnBase. It sets the object on which the function set operates. This is usually done through the function set’s constructor, but if the function set already exists and you want to change the object, use setObject(). This is more efficient than creating and destroying function sets each time you need one.

## Example

Try selecting a few CVs then calling this plug-in. Instead of the name of the CV output, you get the name of the parent object (the curve, surface, or mesh). You may also notice the number of selected objects is not the same as the number of printed names.

The Maya selection architecture simplifies the selection of object components such as CVs. Instead of putting each component object (for instance, each CV) onto the selection list, the parent object is put on the list and the components are grouped together.

So, if several CVs of nurbSphereShape1 are selected, the list.getDagPath()call in the Simple plug-in example returns an MDagPath to nurbSphereShape1, and an MObject groups all selected CVs. The MDagPath and the MObject can then be passed to an MItSurfaceCV iterator to examine the selected CVs.

As long as you continue to select components of only one object, the object appears on the selection list only once. If you pick components of one object, components of another object, then more components of the first object, the first object appears on the selection list twice. This is so you can determine the order in which objects were selected.