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 info from one Object to other Object

    Cinema 4D SDK
    python s22
    4
    5
    1.3k
    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.
    • chuanzhenC
      chuanzhen
      last edited by Manuel

      Hi,
      i want to Copy all info of one Object to other Object.Use source.CopyTo(aim), But object aim is dead after CopyTo().
      My purpose is to copy all the information of an object except the basic information to another object, so after CopyTo(), I want to use the backup information to restore the basic information of aim, but the object is dead and an exception will be thrown

      this is code:

      import c4d
      from c4d import gui
      
      def main():
          source,aim = doc.GetActiveObjects(2)
          doc.StartUndo()
          #backup basic properties
          info_list = []
          description = aim.GetDescription(c4d.DESCFLAGS_DESC_NONE)
          did_list = [c4d.DescID(c4d.DescLevel(110050, 1, 110050)),
                      c4d.DescID(c4d.DescLevel(1041666, 1, 110050))]
          for bc, paramid, groupid in description:
              if groupid in did_list:
                  if aim[paramid]:
                      info_list.append((paramid, aim[paramid]))
          doc.AddUndo(c4d.UNDOTYPE_CHANGE,aim)
          source.CopyTo(aim, c4d.COPYFLAGS_NO_BRANCHES|c4d.COPYFLAGS_NO_MATERIALPREVIEW|c4d.COPYFLAGS_NO_BITS)
          #restore  basic properties
          for info in info_list:
              aim[info[0]] = info[1]
          
          doc.EndUndo()
          c4d.EventAdd()
      # Execute main()
      if __name__=='__main__':
          main()
      

      Thanks for any help!

      相信我,可以的!

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        Hi,

        This is a python bug; it works as expected when using c++. Try to use the following flag c4d.COPYFLAGS_PRIVATE_IDENTMARKER for now to fix the issue. I will open a bug report and we will try to fix the issue as soon as possible.

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        chuanzhenC mikeudinM John_DoJ 3 Replies Last reply Reply Quote 1
        • chuanzhenC
          chuanzhen @Manuel
          last edited by

          @manuel Thanks for your help!

          相信我,可以的!

          1 Reply Last reply Reply Quote 0
          • mikeudinM
            mikeudin @Manuel
            last edited by

            @Manuel said in Copy info from one Object to other Object:

            This is a python bug; it works as expected when using c++.
            I will open a bug report and we will try to fix the issue as soon as possible.

            Still having this bug on 2024.4 🤔

            Checkout my python tutorials, plugins, scripts, xpresso presets and more
            https://mikeudin.net

            1 Reply Last reply Reply Quote 0
            • John_DoJ
              John_Do @Manuel
              last edited by

              @Manuel Thanks ! Still here in 2024.5.1

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