Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hello PluginCafe
I tried to insert a cache of selected object into the doc via Console but I got this error/crash.
doc.InsertObject(op.GetCache())
is it possible to bypass this behavior?
Hello,
this is no bug of the Python API. The code is just unsafe.
A given BaseObject (generator) owns the content of its cache. This cache may be a BaseObject (and subsequent child objects) or nothing - None.
BaseObject
None
So if you operate with a cache you should always check if that cache is actually set. GetCache() can always return None.
GetCache()
cache = op.GetCache() if cache is None: return
But the real problem is that the given BaseObject owns the content of the cache. In your code, you take the cache and inset it into the BaseDocument. Both the generator and theBaseObject now think they do have sole ownership of the cache content. This can't work and is a perfect recipe for any kind of undefined behaviour - including a crash.
BaseDocument
So you cannot insert the cache into the BaseDocument. You must create a copy of the cache (GetClone()) and insert that copy into the BaseDocument.
GetClone()
best wishes, Sebastian
Thanks, Sebastian for detailed explanation But this still can be considered as a bug since it CRASHES c4d instead of raising an error message.
Hi @merkvilson, this feedback has been communicated to our development team.
Cheers, Maxime.