On 09/07/2018 at 21:09, xxxxxxxx wrote:
I'm trying to merge a directory full of .obj files into my scene, but after each merged .obj I need to perform some operations on the newly added objects before merging the remaining files.
Here's the function I'm using to merge the .obj for now:
def mergeObj(path) :
obj_loader = plugins.FindPlugin(c4d.FORMAT_OBJ2IMPORT, c4d.PLUGINTYPE_SCENELOADER)
if obj_loader:
data = {}
obj_loader.Message(c4d.MSG_RETRIEVEPRIVATEDATA, data)
bc = data['imexporter'].GetDataInstance()
bc.SetInt32(c4d.OBJIMPORTOPTIONS_SPLITBY, 3)
return documents.MergeDocument(doc, path, loadflags = c4d.SCENEFILTER_NOUNDO | c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS | c4d.SCENEFILTER_MERGESCENE)
return False
This function currently returns True or False but I'd rather that it return the highest level object inserted by the MergeDocument() call. What's the best way to do that?
I foolishly thought that I might be able to return doc.GetActiveObject() to get the top level BaseObject because that works after using the 'Merge...' menu item, but calling MergeDocument() doesn't seem to change the active object.
Thanks for any help!