Dag paths have knowledge of their MObject but not the other way around. For example, a skin cluster MObject has no dag path so it doesn't make sense that you should be able to get a MDagPath back from the MObject. To get the path, you'll need to use MFnDagNode.getPath()
Chad On Fri, Dec 17, 2010 at 11:30 AM, John Patrick <[email protected]> wrote: > Hey guys, > > I'm getting some errors trying to go back and forth between MObject and > MDagPath objects - I feel like there's something I'm not understanding about > the way the Python API works. > > I've pulled this out of context, but here's the idea: > > import maya.cmds as MC > import maya.OpenMaya as OM > MC.sphere(name='mySphere') > > sl = OM.MSelectionList() > sl.add('mySphere') > dagPath = OM.MDagPath() > sl.getDagPath(0, dagPath) > > > sl = OM.MSelectionList() > node = dagPath.node() > node.hasFn(OM.MFn.kDagNode) > print "Is the node null? %s" % node.isNull() > print "The type is %s" % node.apiTypeStr() > sl.add(node) > newDagPath = OM.MDagPath() > sl.getDagPath(0, newDagPath) > > From this I get: > # Error: (kFailure): NULL object returned > > I'm confused :( Any ideas? Thanks!! > > -- > John Patrick > 404-242-2675 > [email protected] > http://www.canyourigit.com > > -- > http://groups.google.com/group/python_inside_maya > -- http://groups.google.com/group/python_inside_maya
