ECToo / pymel

Automatically exported from code.google.com/p/pymel
0 stars 0 forks source link

ability to list ALL objects in a namespace, including child namespaces #291

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
listing objects in a namespace AND it's child namespaces is much harder than it 
should be because ls('myNamespace:*') does not recurse into child namespace

post filtering works, but can be slow and a bit verbose:
{{{
[x for x in ls(readOnly=1) if x.namespaceList()[0] == 'myNamespace']
}}}

The behavior of the ls command can actually be modified via the namespace 
command.  from the docs:

   The relativeNamespace flag can be used to change the way node names are displayed in the UI and returned by the 'ls' command... In relative name lookup mode, all names will be displayed relative to the current namespace. When not in relative name lookup mode (the default behaviour in Maya), results are printed relative to the root namespace.

here we get the desired behavior, but it is very verbose:

{{{
namespace(setNamespace='myNamespace')
namespace(relativeNames=True)
ls(recursive=True)
namespace(setNamespace=':')
namespace(relativeNames=False)
}}}

it might be nice to add the ability to pass the name of a namespace to the 
recursive flag, to trigger this behavior:

{{{
ls(resursive='myNamespace')
}}}

behind the scenes we would use the namespace command to set the namespace, 
enable relativeNames, then safely restore.

Original issue reported on code.google.com by chad...@gmail.com on 9 Jan 2013 at 11:08

GoogleCodeExporter commented 9 years ago
correction:

{{{
namespace(setNamespace='myNamespace')
namespace(relativeNames=True)
ls("*", recursive=True)
namespace(setNamespace=':')
namespace(relativeNames=False)
}}}

Original comment by chad...@gmail.com on 9 Jan 2013 at 11:10