Duplicate with children

I want to build python code to populate a scene with duplicates of architectural building objects according to an input file.

Up until now I could make it work for single objects that get duplicated and then linked to a “super” parent where I collect all duplicate objects of the same type.

But now I need to duplicate Object groups where there is a “main” object that has child objects.

The following code worked fine for single objects but now I am stuck with the children.

        ob_act = Blender.Object.Get('10205')
        scn.objects.selected = []
        ob_act.sel = 1

        # select children
        for ob in bpy.data.objects: 
            if ob.parent == ob_act:
                ob.sel = 1
        Blender.Object.Duplicate() #Duplicate linked
        ob_act = scn.objects.active
        ob_act.LocX = float(ar[7].replace(",","."))
        ob_act.LocY = -float(ar[6].replace(",","."))

I am guessing that the line

ob_act = scn.objects.active

no longer is the right thing to do as all the children in the duplicate are selected as well.

The result of the program right now is, that the main object gets duplicated and put into the super.parent group but the child objects get duplicted in the original “main” parent object.


I start with

+ column.top (child)

after running the script i have

+column duplicates ...


+ column.top duplicates ...

but what i want to have is

+column.top (child)


+ column.001 duplicate
++ column.top.001 duplicate
+ column.002 duplicate
++ column.top.002 duplicate

any ideas?

found a solution where I scan the duplicated and just manipulate the parent object.

    Blender.Object.Duplicate() #Duplicate linked
    ob_act = Object.GetSelected()

    for t in ob_act:
        if t.getParent() is None:
            t.LocX = 10

Why not just use groups?