Instances, Arrays and links to source data
-
On 17/01/2016 at 13:12, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R17
Platform: Windows ;
Language(s) : C++ ;---------
Hi C4D community,With this code I can take geometry source object of geometry instance:
if (obj->GetType() == Oinstance) { printf("\n %4d %d %5d %6d %7d %7d", obj->GetType(), obj->GetBit(BIT_CONTROLOBJECT), 0, 0, dg, dm); printf(" %s", obj->GetName().GetCStringCopy()); BaseContainer *cnt = obj->GetDataInstance(); if (cnt) { BaseObject * source_object = cnt->GetObjectLink(INSTANCEOBJECT_LINK, doc); }
How to get the source object for Array? I create Array and put some object inside Array and tune the number of several object repetitions. I don't want to create the copies of geometry for the same object several times, but would like to link the source geometry with a few instances and matrices.
Thanks!
-
On 17/01/2016 at 13:35, xxxxxxxx wrote:
Ok, my first obvious guess is to take the source object for Array using the links to it's children:
for (BaseObject * tp = obj->GetDown(); tp; tp = tp->GetNext())
And then traverse the children recursively using GetCache() example. Use children as the source for all that generated things by Array produced by recursion of GetDeformCache() / GetCache().
What issues are possible in this approach?
-
On 18/01/2016 at 10:13, xxxxxxxx wrote:
Hi,
an Instance object and an Array object are two completely different things.
And seemingly you are also looking for two different things.
For the instance you look at the "input object", the one that will be instanced by the Instance object.
But for the Array, you seem to be interested in the generated objects. At least that's what your cache traversal will correctly deliver, the clones generated by the Array object.
If you are interested in the input objects (those that will be cloned) of the Array object, you can simply walk the children of the Array object and check BIT_CONTROLOBJECT, via GetBit().What issues? Well, none, assuming, that's the result you want to get and you implemented it correctly.