This is great. I was stuck with either references not wanting to delete or wrong referencing options meaning the namespace is added as an actual prefix part of the name and not a namespace.
I animate on referenced rigs for game characters, then when I need to export the animation for the engine, I need to remove the namespace so that the animation's skeleton matches with the character rig's skeleton in the engine.
If you're having trouble removing the namespace using the method (namespace editor in Windows > General editors > Namespace Editor) then try this method:
- First go to your reference editor in (File > Reference Editor)
- then in that new window click (File) in the top left drop down and select Import (Objects from Reference).
This will make the referenced objects and all animations real, rather than referenced, meaning you can edit them. - Now that your object are real, select all the objects in your skeleton, open the script editor from (Windows > General Editors > Script Editor) and in the new window select the (Python) tab that's above the bottom text box.
- In the Python tab type this code (make sure you indent the last line by pressing [tab]):
import pymel.core as pm
for item in pm.selected():
item.rename(item.name().replace('The Prefix You Want to Remove', 'What you want to replace the prefix with'))
What this will do is replace a prefix with something else. In my case I wrote:
import pymel.core as pm
for item in pm.selected():
item.rename(item.name().replace('NewRig_Cloths_', ''))
This will remove the prefix 'NewRig_Cloths_' and replace it with nothing ''.
And that's it! Now my animation that I couldn't remove the namespace for will will match the character rig in engine. I won't save the file, because I want to keep the original animation file, but I will export the animation.
Hope this helped. I've seen this issue in many places and I've been struggling with it too. Hopefully this is a useful answer for everyone. Appreciate it if OP sets this as the new answer 👍
