If you look at the C++ Maya API doc, you'll see that the `
MSelectionList::getDagPath` method is defining a parameter `
MDagPath & dagPath`. In C++, the `
&` character denotes what is called a
reference. What it means here is that `
dagPath` is an input/output parameter to the `
MSelectionList::getDagPath` method—the method can read but also modify the content of the `
dagPath` argument.
In your code, you initialize your `
mDagPath` variable with `
OpenMaya.MDagPath()`. At this point in time, `
mDagPath` is like an empty “shell”, with uninitialized data that is not pointing to any valid DAG node in your scene, so calling some methods, such as `
MDagPath::fullPathName`, might result in an undefined behaviour (in other words: don't do it). When you pass `
mDagPath` to `
MSelectionList::getDagPath`, the method will fill it with a new “substance”, that is the data required to point to a valid DAG node. Now you can safely access or modify the DAG node like you've already done with the `
MDagPath::fullPathName` method and others.
Arguably, this whole reference thing is popular in C++ but not so much in Python. If the Python version of the Maya API v1 would have received a bit more love, you'd probably only would have had to type `
mDagPath = mSel.getDagPath(0)` instead.
Now, `
mDagPath.fullPathName('pCube1')` doesn't make so much sense in itself as one would expect the method `
MDagPath::fullPathName` to return the full path of the DAG node, nothing else. But it surely would make sense to have another method allowing to easily retrieve a `
MDagPath` object from its name. Alas there's none available and that's why many develop their own utilities by wrapping the `
MGlobal::getSelectionListByName` function.