Hello Marcus!
Well, that only renames the node. So child nodes will still have the
namespace intact.

So right now I have this which moves the namespace eventually into the root


oSel = cmds.ls(sl=True)[0].split(":")
if len(oSel) >1:
    for i in range(len(oSel)-1):
        cmds.namespace(mv=(oSel[i], ":"), f=True)

Still trying to find a clever way of removing a selected object/shader (and
their child nodes) into the root.

regards
stefan



On Wed, Sep 3, 2014 at 6:12 PM, Marcus Ottosson <[email protected]>
wrote:

> Hi Stefan,
>
> The namespace is in the name, so renaming a node to a name without
> namespace will effectively remove its namespace.
>
> cmds.rename('namespace:my_node', 'my_node')
>
> So if you’ve got many shaders you’d like to remove namespaces from, simply
> rename them all.
>
> for shader in cmds.ls(type='shadingDependNode'):
>     try:
>         # Note rsplit instead of split
>         namespace, name = shader.rsplit(":", 1)
>     except:
>         namespace, name = None, shader
>
>     if namespace:
>         try:
>             cmds.rename(shader, name)
>         except RuntimeError:
>             # Can't rename some shaders, like lambert1
>             pass
>
> Best,
> Marcus
> ​
>
>
> On 3 September 2014 17:53, Stefan Andersson <[email protected]> wrote:
>
>> Hi All,
>>
>> I'm having a brain lock down... I'm trying to removed namespaces (both
>> nested and not nested) from shaders. But can't for the world in me figure
>> out how to check the namespace of the selected object, or query a node to
>> return the namespaces....
>>
>> I need to get a string back of all the namespaces that a object or a
>> shader has.
>>
>> any help would be appreciated. or a RTFM to a specific page :)
>>
>> regards
>> stefan
>>
>>
>>
>> --
>> -- -- - [ *not morse code* ] -- - - -- -- - -- - -- -- - - - --- - -- -
>> - - --- -
>> *stefan andersson | vfx superviso*r
>> Important Looking Pirates  | http://www.ilpvfx.com
>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/CAKW24e1X8N1As7CCePs_ijzMHj641rP7gCM_C3yNZ96QMqsdKA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/python_inside_maya/CAKW24e1X8N1As7CCePs_ijzMHj641rP7gCM_C3yNZ96QMqsdKA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> *Marcus Ottosson*
> [email protected]
>
> --
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCYhOyigQ4Evvb4S%3D4EPOA3os-%3D06myX6d-zcKsfMRxFQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOCYhOyigQ4Evvb4S%3D4EPOA3os-%3D06myX6d-zcKsfMRxFQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-- -- - [ *not morse code* ] -- - - -- -- - -- - -- -- - - - --- - -- - - -
--- -
*stefan andersson | vfx superviso*r
Important Looking Pirates  | http://www.ilpvfx.com

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAKW24e0G6igN1y3BJ2m3DxL8tkYUYavysvTpmD9-Fm4zbN2xAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to