Clone of a linked Object
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/02/2012 at 02:10, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R12
Platform: Windows ;
Language(s) : C++ ;---------
Hi!I have a generator-object with a link-field. Now I need to get a clone of the linked object. But this doesn't work if the linked-object is the input-object of another generator (and in the object-manager above my plugin-object - in other word its cache isn't build when my GetVirtualObjects function gets called).
Here is an example where the instance-object does exactly what I want (there are a lot of fake download-buttons, plz use the one with the arrow on the left side!).
In this simple case my plugin would return an empty Null-object with:linkedObj->GetClone(COPYFLAGS_NO_ANIMATION, NULL);
Thanks for any help!
Greetings,
Satara -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/02/2012 at 07:39, xxxxxxxx wrote:
You can use CheckCache() and GetCache() but there is no guarantee that you will get the build cache. GetAndCheckHierarchyClone() may be a better idea since it will either generate a clone from the hierarchy or return the current cache as clone if no rebuild is needed.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 27/02/2012 at 08:54, xxxxxxxx wrote:
hey thanks for the reply! But unfortunately this won't work in my case, because I don't want to clone the output of the generator but the original (unmodified) object which is used as Input for the generator..
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/03/2012 at 11:31, xxxxxxxx wrote:
A hint how it is solved in the Instance-Object would be great!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/03/2012 at 06:08, xxxxxxxx wrote:
If your link is to the generator object then you will need to get a clone of the child (input for the generator). If your link is to the object itself, it should return the object unmodified by the generator to be cloned. Definitely need to see more code to understand what your exact problem is.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/03/2012 at 10:12, xxxxxxxx wrote:
Yes the link is to the input of the generator object. So I just called GetClone directly on the linked object, but GetClone returns NULL when my Object comes after the parent of the linked object in the hierarchy.
Here is some code, there is not much happening. Just getting the link and trying to return the clone of it.BaseObject* GetVirtualObjects(..) { GeData data; op->GetParameter(DescID(CROSSSECTION_INPUT), data, DESCFLAGS_GET_0); BaseLink *link = data.GetBaseLink(); if (!link) return NULL; BaseList2D *bl = link->GetLink(doc); if (!bl) return NULL; BaseObject *clone = static_cast<BaseObject*>(bl)->GetClone(COPYFLAGS_0, NULL/*tried almost all flags here*/); return clone; }
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 02/03/2012 at 11:32, xxxxxxxx wrote:
My emitter plugin has exactly the same requirement and works fine if I clone the object from a link field where the object is the child of another generator. However, my code uses the base container, not GetParameter(). The code looks like this:
BaseObject* XParticle::GetVirtualObjects(BaseObject *op, HierarchyHelp *hh) { BaseObject *lnk = NULL, *newop = NULL; BaseContainer *bc = op->GetDataInstance(); // get the linked object lnk = (BaseObject* )bc->GetLink(PARTICLES_EMITTER_SHAPE_OBJECT_LINK, hh->doc); if(lnk) { // clone the object newop = static_cast<BaseObject*>(lnk->GetClone(COPYFLAGS_0, NULL)); } // and so on... }
This gets a clone of the linked object without problems.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/03/2012 at 01:13, xxxxxxxx wrote:
Hmm sounded promising but didn't work either
I do exactly the same as you now:BaseContainer *bc =op->GetDataInstance(); BaseObject *link = static_cast<BaseObject*>((BaseObject* )bc->GetLink(CROSSSECTION_INPUT, hh->GetDocument())); if (!link) return NULL; BaseObject *bo = static_cast<BaseObject*>(link->GetClone(COPYFLAGS_0, NULL)); return bo;
It's the same problem as before, when the plugin is located before the generator it works. Just realized that it's the same when I link to the HyperNurbs..
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/03/2012 at 03:28, xxxxxxxx wrote:
It sounds very much like a priorities problem. Those can be an almighty PITA to resolve, IME. If no priority is set, C4D works through each object in turn in the OM, starting from the top. This would explain why your plug only works if it's above the other generator.
I can't tell you how to resolve this because I never found a satisfactory way of doing so. But a look at priorities in the SDK might be helpful. You would want to make sure that your plug is executed before other generators.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/03/2012 at 04:15, xxxxxxxx wrote:
Thanks a lot to both of u. I made a quick test and cloning by using priorities works in my case! Have to revise the caching behavior now and check for drawbacks but I think this is the way to go!