MoBu: Moving components to another namespace question

I’m trying to move all components from one namespace into another (one that already exists or not, depending on the situation). I’ve looped over all relevant components and either changed their LongName or used ProcessObjectNamespace on them, but both these operations take “forever”, with the number of objects I’m dealing with.

So I’m looking for a faster way to map everything in one namespace to another - E.G.:

temp:salmon -> salmon (where salmon is an existing namespace)
temp.salmon -> salmon_01 (where salmon_01 is not an existing namespace)

FBSystem().Scene.RenameNamespace() sadly only works when moving from an existing namespaces to one that doesn’t.

Cheers

P.S. I’ve asked this on the Area also, but things are usually very quiet over there so…

Hey Sune, this is an older example that ships with Mobu but it is fast



 from pyfbsdk import FBSystem, FBNamespaceAction
 

 #Change the name of the following value to match your namespaces
 lOldNamespace = "CHR_G_Generic_Ctrl1"
 lNewNamespace = "tempNamespace"
 

 for lComp in FBSystem().Scene.Components:
         # This function is a recursive function that will go through the whole hierarchy to add or replace the prefix
         lComp.ProcessNamespaceHierarchy (FBNamespaceAction.kFBReplaceNamespace, lOldNamespace, lNewNamespace, False)  
 

 # Clean-up
 del(FBSystem, FBNamespaceAction, lComp)         


http://docs.autodesk.com/MB/2014/ENU/MotionBuilder-SDK-Documentation/py_ref/_basic_operations_2_replace_namespace_8py-example.html

Hey Brad,

ProcessObjectNamespace is what’s I’m already doing. In one case this takes about 15 seconds, where something like FBSystem().Scene.RenameNamespace() just takes a few.

I’m doing this namespaces mapping in connection with merging files, but it’s pushing my “merge times” by a factor three (e.g. 30 sec -> 90 sec), which is not really acceptable.

doh, sorry, didn’t read slowly enough.

Is there a a reason you are not setting the name space at import with the file options settings and you are doing it after merge?

http://docs.autodesk.com/MB/2014/ENU/MotionBuilder-SDK-Documentation/index.html?url=files/GUID-9CA39221-DEDB-4355-ADFA-C86D3D3DDE83.htm,topicNumber=d30e8745

Yeah, the incoming file already has a bunch of namespaces, that may of may not conflict with what’s in the scene. I’m not happy with the way that MotionBuilder handles the renaming for me, so I apply a temporary unique namespace on merge and then check what was merged against what is already in the scene and do any remapping needed.

ohhhhhhhhhhhhhhhhhhh, still it seems like your complicating things :slight_smile: But if something is funky with how it is merging a nice note and wine/cheese basket to Autodesk might be in order.

whine and cheese!

I very well might be, seeing as we are embarking on a new project with all animation in MotionBuilder, I think we need to have a talk! I’d love to get your input :slight_smile: