3/4

import bpy
from random import randint

number_buildings=4
number_elements=3
move_x=0
move_y=0

for j in range(0, number_buildings):

move_x=move_x+10
move_y=0

for i in range(0, number_elements):
x=randint(i,5)+move_x
y=randint(i,5)
z=randint(1,5)
bpy.ops.mesh.primitive_cube_add(location=(x,y,0))
bpy.context.scene.cursor.location=(x,y,-1)
bpy.ops.object.origin_set(type=’ORIGIN_CURSOR‘)
xs=randint(1,2)
ys=randint(1,2)
zs=randint(i,6)
bpy.ops.transform.resize(value=(xs, ys, zs))

for k in range(0, number_buildings):

move_y=move_y+10

for l in range(0, number_elements):
x=randint(l,5)+move_x
y=randint(l,5)+move_y
z=randint(1,5)
bpy.ops.mesh.primitive_cube_add(location=(x,y,0))
bpy.context.scene.cursor.location=(x,y,-1)
bpy.ops.object.origin_set(type=’ORIGIN_CURSOR‘)
xs=randint(1,2)
ys=randint(1,2)
zs=randint(l,6)
bpy.ops.transform.resize(value=(xs, ys, zs))