Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Clearing scene namespaces

Clearing scene namespaces

Anonymous
Not applicable
2,758 Views
7 Replies
Message 1 of 8

Clearing scene namespaces

Anonymous
Not applicable
Hi everyone!

OK my problem sounds very simple... but I can't find ANY documentation, so I'd be really grateful for any help.

It seems that, when you create a namespace for an object, it is stored permanently somewhere in MotionBuilder's system. Even if you delete the object or replace the namespace, the original namespace is still listed in the "namespaces currently in scene". This is quite frustrating.

I've been trying to write some python to clear all of the namespaces in a MotionBuilder (2011, 64 bit) scene, with no success. Any ideas?

Thanks 🙂
0 Likes
Accepted solutions (1)
2,759 Views
7 Replies
Replies (7)
Message 2 of 8

brissef2
Autodesk
Autodesk

Hi PDWhiting,

 

Actually, Namespaces are supposed to be listed only if an object uses it. If any object uses it, the namespace should be removed automatically.

Please report any issue you might found if this is not behaving properly.

 

Best regards,

Francis

0 Likes
Message 3 of 8

Anonymous
Not applicable

This is definitely not the case. I just tested it out. I used Edit>Select By Namespace and I selected all the objects with that namespace. I deleted those objects. I went to add/remove namespaces, and it is still there. I try to select by namespace again and it selects nothing...
(& wow, it took 7 years for that question to get a response...)

0 Likes
Message 4 of 8

brissef2
Autodesk
Autodesk

Hi @Anonymous , @Anonymous ,

 

Indeed, I can reproduce your behavior.

 

It looks the best way to clear the namespace and its content then is to use the SDK:

FBSystem().Scene.NamespaceDelete("NamespaceName")

 

Best regards,
Francis

PS: @Anonymous , better late then never. 🙂

0 Likes
Message 5 of 8

danlane3d
Contributor
Contributor

How do I clear a namespace but retain the objects? 

0 Likes
Message 6 of 8

brissef2
Autodesk
Autodesk
Accepted solution

Hi @danlane3d ,

 

I am not sure there is an API for this yet.

You would likely need to pass through all the content of the Namespace, using FBSystem().Scene.NamespaceGetContentList(...)

And then you could change the LongName property of each object to rename the namespace.

 

I think it would work, I don't know if it would work for all scenarios though.

 

Best regards,

Francis

Message 7 of 8

damian.pajda
Advocate
Advocate

I tested what @brissef2  suggested and it works nice.

replacing LongName is nice idea, because it removes only specific namespace, not all components namespaces like this function:

comp.ProcessObjectNamespace(FBNamespaceAction.kFBRemoveAllNamespace, "")

script below works for me

Namespace_name = "namespace"
comp_list = FBComponentList()
FBSystem().Scene.NamespaceGetContentList(comp_list , Namespace_name )
        
for comp in comp_list :
    comp.LongName = comp.LongName.replace(Namespace_name +':', '')
                
if FBSystem().Scene.NamespaceEmpty(Namespace_name ):
    FBSystem().Scene.NamespaceDelete(Namespace_name )

 

Message 8 of 8

danlane3d
Contributor
Contributor

Thanks for the replies, it works great. cheers

0 Likes