# Select motion path from curve in Maya Python

I need to obtain the motion path attached to a curve in maya using Python. This is the situation as shown in the editor:

I want to obtain motionPath1 by calling a method on curve3 since they look like they are related.

However, I have tried pleny of list methods (listAttr, listHierarchy, etc) but they only return the curveShape3.

What is the command, if it exists at all, to get the name of the motion path in Python knowing the object curve3?

You need to get motion path node name from curve shape.

import maya.cmds as cmd
shape = cmd.listRelatives( 'curve3' )
mPath = cmd.listConnections( shape, type = 'motionPath')
print mPath