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

    Replace object and links

    SDK Help
    0
    7
    535
    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 13/08/2013 at 03:47, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:    
      Platform:      
      Language(s) :

      ---------
      I want to replace an object in a hierarchy and adjust all BaseLinks pointing to it. Is this possible? I
      couldn't find a way to do it.

      Thanks!
      -niklas

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

        On 13/08/2013 at 04:24, xxxxxxxx wrote:

        hi niklas,

        i am not sure if do understand you correctly, but i did something similar recently in python (replace 
        object type a with object type b in a document, while maintainaing all qualities of object A). first of 
        all there is the built in replace with function in c4d, which might do what you want without any
        further struggle. if you do need more control here are my python results :

        1. replacing the track, containder/userdata data works pretty straight forward.
        2. for replacing the links i did:
        > - collect all  nodes to be replaced
        >
        > - generate a  replacement node list in the same order
        >
        > - temp insert the  replacement list into the document
        >
        > - overwrite the BaseLinks
        >
        > - remove the old nodes
        >
        > - move the  replacement nodes to their final destination.
        3. which does work ok. however for BaseLinks stored in the userdata container my method does
        not work, i am not 100% sure why.

        if you are looking for an automated way to get hold of all BaseLinks pointing to a BaseList2D i am 
        afraid there is no such method. You will have to iterate through your documents nodes and their 
        data containers yourself.

        here is some code. the relevant method would be replaceContainerReference().
        http://codepad.org/ne4v1nBN

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

          On 13/08/2013 at 06:30, xxxxxxxx wrote:

          Thank you very much for your answer Ferdinand, appreciate it.

          What is this automated "replace with" function you mentioned? I can't find something
          like this neither in the C++ SDK nor in the Python SDK. Maybe I am searching with the
          wrong keywords. 🙂

          I'll try to replicate your Python code in C++.

          Thanks!
          -Niklas

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

            On 13/08/2013 at 07:05, xxxxxxxx wrote:

            Howdy,

            I think the function you're trying to find is BaseList2D::TransferGoal().

            Adios,
            Cactus Dan

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

              On 13/08/2013 at 07:20, xxxxxxxx wrote:

              That's exactly what I searched for, Dan! Thank you very much!

              Best,
              -Niklas

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

                On 13/08/2013 at 07:27, xxxxxxxx wrote:

                Howdy,

                You're welcome. 😉

                Adios,
                Cactus Dan

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

                  On 13/08/2013 at 14:19, xxxxxxxx wrote:

                  Originally posted by xxxxxxxx

                  Thank you very much for your answer Ferdinand, appreciate it.

                  What is this automated "replace with" function you mentioned? I can't find something
                  like this neither in the C++ SDK nor in the Python SDK. Maybe I am searching with the
                  wrong keywords. 🙂

                  I'll try to replicate your Python code in C++.

                  Thanks!
                  -Niklas

                  i meant the CA command which is buried somewhere in the CA tools menu. but it is good to
                  know about BaseList2D.TransferGoal(). Something learned again today 😉

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