"""Test of the unit assembler in an empty file: a flush spine car with a side door into a sunken room. blender -b --factory-startup --python build/test_units.py -- """ import os import sys import bpy sys.dont_write_bytecode = True sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) import bl_kit # noqa: E402 from bl_kit import Kit, get_collection # noqa: E402 from cars import BAY, CAR_HALF, DOOR_GAP, Engineer # noqa: E402 from units import frame, place # noqa: E402 out = sys.argv[sys.argv.index("--") + 1] bpy.ops.wm.read_factory_settings(use_empty=True) kit = Kit() eng = Engineer() root = get_collection("TEST") c_mesh = get_collection("TEST | meshes", root) c_light = get_collection("TEST | lights", root) c_decal = get_collection("TEST | decals", root) stats = {} N = 5 spine = eng.car("blue", N, side_doors=[(2, +1)], props="tidy") place(kit, spine.items, c_mesh, frame(0, 0, 0), zone="SPINE", lights=c_light, decals=c_decal, stats=stats) room = eng.car("white", 3, door_a=False, door_b=False, side_doors=[(1, -1)], props="tidy") place(kit, room.items, c_mesh, frame(BAY, 2 * CAR_HALF, 0), zone="ROOM", lights=c_light, decals=c_decal, stats=stats) # the doors: both ends of the spine and the side door between spine bay 2 and room bay 1 for f in (frame(0, 0, 0), frame(eng.length(N), 0, 0), frame(DOOR_GAP + 2.5 * BAY, CAR_HALF, 0, 90.0)): place(kit, eng.conn.items, c_mesh, f, zone="DOOR", lights=c_light, decals=c_decal, stats=stats) # a cube beyond the far end, closed on three sides cube = eng.cube("W", props="tidy") place(kit, cube.items, c_mesh, frame(eng.length(N), 0, 0), zone="CUBE", lights=c_light, decals=c_decal, stats=stats) print("TEST placed", stats, "conn items", len(eng.conn.items), "cube wall", eng.cube_wall is not None) os.makedirs(os.path.dirname(out), exist_ok=True) bpy.ops.wm.save_as_mainfile(filepath=out, compress=True) print("saved", out)