On 17/01/2014 at 07:55, xxxxxxxx wrote:
Hi - I'm having a bit of trouble with a script I am working on. I have a file with 100 models in it and I want a script that will copy each individual model and place it in its own new document. I've grabbed a list of the models and then tried to use a loop to pull each model out and insert it into a new document. I keep getting an "AssertionError: Found next objects. Please add them separately." If I don't try to pull models from the list and instead create a new cube object in the same loop it works.
For testing purposes I created a new document and put 3 cube objects in it with unique names (1, 2, 3) so I can tell them apart as the script runs.
The script is a work in progress but this is where I'm stuck at the moment.
Any help would be appreciated.
from c4d import gui
from c4d import documents
def main() : models = doc.GetObjects()#get list of models in document for i in (models) : #obj = c4d.BaseObject(c4d.Ocube) obj = i newDoc = c4d.documents.BaseDocument() #Initialize a new base document newDoc.SetDocumentName("MyNewDoc") #set the name of the new document c4d.documents.InsertBaseDocument(newDoc) #makes the document visible in the editor newDoc.InsertObject(obj) c4d.EventAdd() if __name__=='__main__': main()