Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Instances, Arrays and links to source data

    SDK Help
    0
    3
    292
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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?

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          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. 😉

          1 Reply Last reply Reply Quote 0
          • First post
            Last post