After calling MergeDocument()
merge_status = c4d.documents.MergeDocument(doc, path,
c4d.SCENEFILTER_MERGESCENE | c4d.SCENEFILTER_OBJECTS)
I check merge_status to be true and wish to find some handle/name to the object associated with the call to MergeDocument(), how do I do that ?
I tried the following on an empty scene
doc = c4d.documents.GetActiveDocument()
ao = doc.GetActiveObject()
that works if I am calling MergeDocument for a single path but if I am calling MergeDocument (in a loop) for a collection of paths, GetActiveObject() points to the same object, not the next one corresponding to the next path I am merging into the scene
there's no direct way of doing it. You must store the different object. Either you can store the original object's list and select/inverse the selection to retrieve all the objects that were not in the original document. Or you can store the object in a list each time you import a document.
from c4d import gui
while not op.GetNext() and op.GetUp():
op = op.GetUp()
originalObjects = list()
child = doc.GetFirstObject()
if child is None:
child = GetNextObject(child)
# Store the original object in a list
originalObjects = GetOriginalObjectList()
mergedObject = list()
for root, dirs, files in os.walk(path):
for name in files:
filePath = os.path.join(path,name)
merge_status = c4d.documents.MergeDocument(doc, filePath, c4d.SCENEFILTER_MERGESCENE | c4d.SCENEFILTER_OBJECTS)
c4d.CallCommand(100004767) # Deselect All object
# select all object that were on the orignal document
for obj in originalObjects:
c4d.CallCommand(100004794) # Invert Selection
#Print all the object list we gather during the import.
for objList in mergedObject:
# Execute main()
without any further questions or postings, we will consider this topic as solved by Wednesday and flag it accordingly.