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

    Get clone of group and keep links

    Cinema 4D SDK
    python
    2
    3
    881
    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.
    • R
      rownn
      last edited by s_bach

      Hello,

      for example I have a null object with 2 children, one child is a rectangleSpline and the other is a sphere. The sphere has an align-to-spline-tag with the rectangle as spline-path source. If I clone the null with null.GetClone() the new spline-path links to the old rectangle, but I want it to link to the new rectangle. So, how can I get the behavior alike copy paste groups in OM?

      Thx for any hints
      rownn

      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        Hello and welcome to the PluginCafe,

        Please post your questions regarding the Cinema 4D API in the "Cinema 4D Development" forum.

        Also, please use tags and the Q&A system to mark questions. Please read "Read Before Posting".

        To handle links when coping objects one can use a AliasTrans object. This object allows to fix links after objects are copied.

        trans = c4d.AliasTrans()
        if trans is None or trans.Init(doc) is False:
            return False
        
        objects = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_0)
         
        for obj in objects:
             
            clone = obj.GetClone(c4d.COPYFLAGS_0, trans)
                
            if clone is not None:
                clone.SetName(obj.GetName() + " clone")
                doc.InsertObject(clone, None, None)
                 
        c4d.EventAdd()
        

        You find more information in the C4DAtom Manual or the AliasTrans Python documentation.

        Best wishes,
        Sebastian

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        R 1 Reply Last reply Reply Quote 3
        • R
          rownn @s_bach
          last edited by rownn

          Very cool, thx alot Sebastian
          rownn

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