Duplicate Hierarchy



  • 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.



  • 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



  • 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.


Log in to reply