Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Copy link object

    Cinema 4D SDK
    r20 c++
    2
    4
    893
    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.
    • A
      anoano
      last edited by

      Hi.

      I copied the object of link field in the virtual object with GetClone ().

      However, if the type of the linked object is a generator type such as instance, it can not be displayed properly below the linked object on the object manager.

      I checked past posts and found that they have priority issues.
      But I do not know how to solve it.

      https://developers.maxon.net/forum/topic/6250/6615_clone-of-a-linked-object

      Please let me know if anyone knows who you are.

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by m_adam

        Hi @anoano.

        I will need more information.
        I'm not sure in which context you are, when you say virtual object I think you refer to be inside of a Generator and the GetVirtualObjects method isn't?

        Moreover, when you say a link, you refer to a LinkBox parameter, so the linked object can be anywhere and not necessary a Child of the current Generator, isn't?

        Last stuff, please make sure to mark your topic as a question. I've done it for this time (don't worry you are new, no issue at all), see Q&A New Functionality.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • A
          anoano
          last edited by

          Re: Copy link object

          This is the code I wrote.

          BaseObject *HyperINS::GetVirtualObjects(BaseObject *op, HierarchyHelp *hh)
          {
                  BaseContainer* bc = op->GetDataInstance();
          	BaseObject* main = BaseObject::Alloc(Onull);
          	if (!main) return nullptr;
          	
          	BaseObject    *link= (BaseObject*)bc->GetLink(ID_LINK, hh->GetDocument());
          	if (!link) return main;
          		
          	AutoAlloc<AliasTrans> aliastrans;
                  if (!aliastrans || !aliastrans->Init(hh->GetDocument())) return main;
                  
                  BaseObject* ref = static_cast<BaseObject*>(link->GetClone(COPYFLAGS::NONE, nullptr));
          
                  aliastrans->Translate(true);
          
                  ref->InsertUnder(main);
          		
          	return main;
          }
          

          It will not work at the manager's position.

          alt text
          alt text

          1 Reply Last reply Reply Quote 0
          • M
            m_adam
            last edited by

            Hi, the topic is now marked as solved, did you solve your issue?

            The only workaround I was able to find is to make use of AddToExecution and define it to GENERATOR+1, here you retrieve and clone the cache of the linked object in a member variable of your instance, then in the next GVO you make use of this cache, but this has the application that you work always on a mesh that has been generated in a previous SceneExecution call, which may be an issue in case of animation.

            Cheers,
            Maxime.

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

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