Hi,
your code does look a bit confusing to me.
-
If you invoke
self.SetOptimizeCache(True)
inObjectData.Init()
then you do not have to handle your cache manually inObjectData.GetVirtualObjects()
(GVO). -
Only letting your
GVO
logic execute if theBaseObject
node attached to yourObjectData
has no children and then grabing the first object of the scene as an input is really weird. -
If you do some file I/O, you should not do it in
GVO
if possible. Also the following snippet is a crash waiting to happen (when your first object in the scene is aMyObject
object).
preset = doc.GetFirstObject()
obj = preset.GetClone()
-
You do modify the scene graph and invoke events in
GVO
. You are not allowed to do that. -
You also use
GVO
against its purpose since you never do return any objects constructed in yourGVO
. You only return the cache when your object node isn't flagged dirty. But that does not mean anything since you never return any objects to populate that cache. In most cases yourGVO
will returnNone
, which will be read by c4d as that you have indicated an memory error. If you want to return nothing you have to return a null object. So there is nothing to convert in yourObjectData
. -
Think of your
ObjectData
as a null object. InGVO
you have to return the object tree that c4d is supposed to put under that null. These children objects will be hidden from the user. When the user then invokes "current state to object" c4d will remove that null and return the hidden object tree.
Cheers
zipit