I made a script that clears the scene if there was anything superfluous), and adds two types of trees. With each click of the script, the trees are positioned differently, as well as their height.
Script and screen
import bpy
import random
green_plane.diffuse_color = [0, 0.45, 0, 1]
green_tree.diffuse_color = [0, 0.7, 0, 1]
brown_tree.diffuse_color = [0.2, 0.1, 0, 1]
green_black.diffuse_color = [0, 0.2, 0, 1]
def clean_scene():
bpy.ops.object.delete()
def add_plane():
bpy.ops.mesh.primitive_plane_add()
plane = bpy.context.active_object
plane.scale.x = 20
plane.scale.y = 20
def add_tree():
for i in range(10):
x = random.randint(-19, 19)
y = random.randint(-19, 19)
height = random.randint(4, 6)
bpy.ops.mesh.primitive_cylinder_add(radius = 0.5, location = (x,y, height / 2), depth = height)
cyl = bpy.context.active_object
bpy.ops.mesh.primitive_uv_sphere_add(location = (x,y, height), radius = 3)
uv = bpy.context.active_object
uv.data.materials.append(green_tree) for i in range(10):
x = random.randint(-19, 19)
y = random.randint(-19, 19)
height = random.randint(4, 6)
bpy.ops.mesh.primitive_cylinder_add(radius = 0.5, location = (x,y, height / 2), depth = height)
cyl = bpy.context.active_object
bpy.ops.mesh.primitive_cone_add(location = (x,y, height), depth = height,radius1= 2)
cone = bpy.context.active_object
clean_scene()
add_plane()
add_tree()