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

    Duplicate Hierarchy

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 388 Views
    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 Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 21/07/2011 at 11:02, xxxxxxxx wrote:

      Wondering if someone has some code to duplicate a hierarchy, but with an arbitrary object. For instance, if your hierarchy is made of cubes and you want to duplicate that hierarchy but change all the cubes to spheres. The character->convert to nulls function is pretty much what I am looking for.

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

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 21/07/2011 at 11:28, xxxxxxxx wrote:

        having the code search through the hierarchy and change cubes to spheres is entirely possible, but also very specific, so i don't have any pre-made code, but mabye something like this:

        import c4d
        from c4d import documents as docs
        from c4d import BaseObject as bo

        doc = docs.GetActiveDocument()
        op = doc.GetActiveObject()
        objs = op.GetChildren()
        mainNull = bo(c4d.Onull)
        for obj in objs:
          if obj.CheckType(c4d.Ocube) or isinstance(obj,c4d.BaseObject) :
              newObj = bo(c4d.Osphere)
              newObj.SetRelPos(obj.GetRelPos())
              newObj.InsertUnder(mainNull)
        return mainNull

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

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 21/07/2011 at 13:18, xxxxxxxx wrote:

          Thanks! I'll have to try this out and see if it works.

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