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(",","."))
p10205.makeParent([scn.objects.active])
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.
Example:
I start with
column
+ column.top (child)
after running the script i have
column
+column.top
+column duplicates ...
and
column.grp.parent
+ column.top duplicates ...
but what i want to have is
column
+column.top (child)
and
column.grp.parent
+ column.001 duplicate
++ column.top.001 duplicate
+ column.002 duplicate
++ column.top.002 duplicate
...
etc.
any ideas?