MergeDocument under a selected Null
-
Hey,
i use
c4d.documents.MergeDocument(doc , f, c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS | c4d.SCENEFILTER_MERGESCENE)
now i would like to group this new scene under a NULL. if i do the whole thing via obj.InsertUnder(null) i miss the materials.
which is totally logical but unfortunately not what i have in mind.So one idea would be to insert the materials separately into the scene by checking the tags. The problem is that I can't be 100% sure that all the materials that are needed will be migrated.
Another approach would be to check which objects are already in the scene and then simply move the newly loaded ones under the zero.
So what is the best way to extend the functionality of MergeDocument to be able to specify a null object as root?
-
Hey @pyr,
Thank you for reaching out to us. The sentence 'if i do the whole thing via obj.InsertUnder(null) i miss the material' is a bit ambiguous, how do you mean that? I assume you mean that when you load two documents A and B and then start copying objects over by either cloning them or removing them from A and inserting them into B, that you then miss material references. Because the call you show us will load both objects and materials found at
f
intodoc
.A straightforward way to do what you want to do, parent everything that has been imported to a null, is to track the state of the top-level objects before and after the import. The difference between the states then tells you what to move where. In practice, there are some technical hoops to jump through, primarily the problem that you might run into dead references when you try to store objects references over the import process.
Cheers,
FerdinandResult: