Pymel ls command does not return full path names

As i’m working on an inhouse exporter script, i stumbled over a peculiar problem with PyMel. The pymel version of the ls-command seems to ignore the long parameter, while the maya.cmds version works correctly:

import maya.cmds as cmds
for x in cmds.ls(sl=True, l=True):
    print x

Result:
|scene_main|mesh_helix1

PyMel:

from pymel.core import *
for x in ls(sl=True, l=True):
    print x

Result:
mesh_helix1

Am i doing something wrong here or is this actually a bug? Has anyone encountered that problem?

In PyMEL, pm.ls returns you PyNode objects, not strings - which is what cmds.ls does

From the docs:

Modifications:
- Returns PyNode objects, not “names” - all flags which do nothing but modify
the string name of returned objects are ignored (ie, ‘long’); note that
the ‘allPaths’ flag DOES have an effect, as PyNode objects are aware of
their dag paths (ie, two different instances of the same object will result
in two unique PyNodes)

Key bit here is: “PyNode objects are aware of their dag paths” :slight_smile:

1 Like

Right on, my mistake, now i feel stupid :smiley:

A little research in the docu also showed me how i get the full name:

print ls(sl=True)[0].longName()

|scene_main|mesh_helix1
3 Likes