Deleting nested namespace

40 views
Skip to first unread message

yann19

unread,
May 4, 2015, 5:33:56 AM5/4/15
to python_in...@googlegroups.com

Hi all, I am trying to do some namespace removal in the python way but I am meeting with some problems, especially those nested namespaces.

This is my code:

nsLs = cmds.namespaceInfo( lon=True )
defaultNs
= ["UI", "shared", "camera01"]    # I need camera01

diff
= [item for item in sel if item not in defaultNs]

for ns in diff:
   
if cmds.namespace( exists=str(ns)):
        cmds
.namespace(rm=str(ns))

I am having issues with deleting "new_run01" that resides within "v02" and "v03", as soon as I run the code, I am getting this error:
# Error: line 1: The namespace 'v02' is not empty.
# Traceback (most recent call last):
#   File "<maya console>", line 8, in <module>
# RuntimeError: The namespace 'v02' is not empty. #

I have checked and verified that there is no contents listed within those 2 new_run01 but unless I opened up the Namespace Editor and delete them manually, it seems to defeat the purpose of scripting it in the first place.

Was wondering if anyone happen to do something similar before? Many thanks in advance!




yann19

unread,
May 4, 2015, 6:21:14 AM5/4/15
to python_in...@googlegroups.com
There was a typo in code.. It should be:

nsLs = cmds.namespaceInfo( lon=True )
defaultNs
= ["UI", "shared", "camera01"]    # I need camera01


diff
= [item for item in nsLs if item not in defaultNs]

Gerard Gmail

unread,
May 4, 2015, 7:58:03 AM5/4/15
to python_in...@googlegroups.com

Hi. I'm not at my computer to check your script but I think I recall insuring that namespaces were empty by using the:

cmds.namespace(mv=(namespace_to_empty, ':') # puts contents into default / scene namespace. 

before deleting. May be unrelated to your issue. If so, just ignore.. :)

Gerard. 

On 4 May 2015, at 7:33 pm, yann19 <yang...@gmail.com> wrote:

Hi all, I am trying to do some namespace removal in the python way but I am meeting with some problems, especially those nested namespaces.

This is my code:

nsLs = cmds.namespaceInfo( lon=True )

defaultNs = ["UI", "shared", "camera01"]    # I need camera01

diff = [item for item in sel if item not in defaultNs]


for ns in diff:
    if cmds.namespace( exists=str(ns)):
        cmds.namespace(rm=str(ns))
I am having issues with deleting "new_run01" that resides within "v02" and "v03", as soon as I run the code, I am getting this error:
# Error: line 1: The namespace 'v02' is not empty.
# Traceback (most recent call last):
#   File "<maya console>", line 8, in <module>
# RuntimeError: The namespace 'v02' is not empty. # 

I have checked and verified that there is no contents listed within those 2 new_run01 but unless I opened up the Namespace Editor and delete them manually, it seems to defeat the purpose of scripting it in the first place.

Was wondering if anyone happen to do something similar before? Many thanks in advance!




-- 
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/00412c30-471d-4ba5-bb35-13cf7657c5e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Gerard. 
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/80fd0be8-c9b8-4500-b4db-76540d8774b2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages