I have a question about clean all baseobjects within document.There were many Baseobjects using Baseobject::Alloc() to achieve and put into Basedocument. If I use Basedocument::Free() to clean all info,Is it necessarily that all objects were destoryed using baseobject::Free() within doc one by one?
if you want to completely empty an document, simply call Flush(), it empties and destroys everything in it. BaseDocument.Flush()
This also deletes everything, not only BaseObjects.
However, you stated that you only want to Free all BaseObjects, you then have to iterate over the entire document and remove them manually.
Could look like this then:
inline void g_DeleteAllObjects(BaseDocument* doc)
auto obj = doc->GetFirstObject();
const auto tempObj = obj->GetNext();
obj = tempObj;
what @mp5gosu is showing in his code snippet is actually a quite common concept in Cinema 4D. More on this topic can also be found in the GeListNode manual in our C++ documentation.
One request from my side: Please do not use all capital letters in the subject of a topic. Our forum tries to emphasize threads which are unread by a user by temporarily formatting a subject in all capital letters. So if you do as you did here ("FREE ALL BASEOBJECT") the thread always looks like it is still unread. I changed it here in this thread.
And as a small reminder, please make use of our tagging system in this forum to provide a bit of additional information for a thread and to help us keep this forum nice and tidy and easily searchable. See Read Before Posting..
Lastly I turned your thread into a question (see How to Post Questions). Another feature we'd like to see people making use of in order to increase the usefulness of this forum.