import bpy import math def material(color): mat = bpy.data.materials.get(color) if mat is None: mat = bpy.data.materials.new(color) rgb = [int(color[i:i+2], 16) / 255 for i in (0, 2, 4)] mat.diffuse_color = rgb + (1,) return mat def box(name, loc, size, color, angle=0): bpy.ops.mesh.primitive_cube_add(size=1, location=loc) obj = bpy.context.object obj.name = name obj.dimensions = size bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) obj.rotation_euler.z = angle obj.data.materials.append(material(color)) bevel = obj.modifiers.new('edge', 'BEVEL') bevel.width = min(0.025, min(size) / 5) bevel.segments = 1 return obj def cylinder(name, loc, radius, depth, color): bpy.ops.mesh.primitive_cylinder_add(vertices=10, radius=radius, depth=depth, location=loc) obj = bpy.context.object obj.name = name obj.data.materials.append(material(color)) return obj box('floor', (0, 0, 0.1), (5.6, 5.6, 0.2), 'e8dfcd', 0) box('wall_back', (0, 2.7, 1.7), (5.6, 0.15, 3), '91aa8a', 0) box('wall_side', (-2.7, 0, 1.7), (0.15, 5.6, 3), '91aa8a', 0) box('trim_back', (0, 2.595, 0.29), (5.2, 0.05, 0.18), 'e8dfcd', 0) box('trim_side', (-2.595, 0, 0.29), (0.05, 5.2, 0.18), 'e8dfcd', 0) box('desk_top', (-0.25, 1.85, 1.05), (1.9, 0.8, 0.12), '9b704d', 0) box('desk_leg_0', (-0.97, 1.58, 0.595), (0.1, 0.1, 0.79), '9b704d', 0) box('desk_leg_1', (-0.97, 2.12, 0.595), (0.1, 0.1, 0.79), '9b704d', 0) box('desk_leg_2', (0.47, 1.58, 0.595), (0.1, 0.1, 0.79), '9b704d', 0) box('desk_leg_3', (0.47, 2.12, 0.595), (0.1, 0.1, 0.79), '9b704d', 0) box('chair_leg_0', (0.02, 0.72, 0.4), (0.08, 0.08, 0.4), '9b704d', 3.1416) box('chair_leg_1', (0.02, 0.28, 0.4), (0.08, 0.08, 0.4), '9b704d', 3.1416) box('chair_leg_2', (-0.42, 0.72, 0.4), (0.08, 0.08, 0.4), '9b704d', 3.1416) box('chair_leg_3', (-0.42, 0.28, 0.4), (0.08, 0.08, 0.4), '9b704d', 3.1416) box('chair_seat', (-0.2, 0.5, 0.65), (0.64, 0.62, 0.14), 'e2b96b', 3.1416) box('chair_back', (-0.2, 0.35, 0.97), (0.64, 0.12, 0.66), 'e2b96b', 3.1416) box('monitor_foot', (-0.25, 1.85, 1.145), (0.38, 0.25, 0.08), '4c515a', 0) box('monitor_stand', (-0.25, 1.97, 1.33), (0.09, 0.07, 0.32), '4c515a', 0) box('monitor_frame', (-0.25, 1.97, 1.59), (0.85, 0.09, 0.5), '4c515a', 0) box('monitor_screen', (-0.25, 1.93, 1.59), (0.77, 0.02, 0.42), 'a5c6ce', 0) box('keyboard', (-0.25, 1.53, 1.13), (0.5, 0.18, 0.04), 'e8dfcd', 0) box('storage_body', (1.95, 0.45, 0.6), (0.72, 0.8, 0.8), '9b704d', 0) box('storage_door_0', (1.77, 0.035, 0.6), (0.325, 0.035, 0.71), 'e8dfcd', 0) box('storage_handle_0', (1.87, -0.0, 0.64), (0.04, 0.04, 0.18), '504945', 0) box('storage_door_1', (2.13, 0.035, 0.6), (0.325, 0.035, 0.71), 'e8dfcd', 0) box('storage_handle_1', (2.03, -0.0, 0.64), (0.04, 0.04, 0.18), '504945', 0) cylinder('plant_pot', (1.95, 0.45, 1.0975), 0.125, 0.195, 'e2b96b') cylinder('plant_stem', (1.95, 0.45, 1.27), 0.025, 0.19, '6d8051') box('plant_leaf_0', (1.89, 0.45, 1.39), (0.15, 0.17, 0.28), '739662', 0.0) box('plant_leaf_1', (2.01, 0.46, 1.39), (0.15, 0.17, 0.28), '739662', 0.8) box('plant_leaf_2', (1.95, 0.5, 1.39), (0.15, 0.17, 0.28), '739662', 1.6) box('shelf_side_0', (-2.35, 1.6, 1.095), (0.08, 0.48, 2.19), '9b704d', 0) box('shelf_side_1', (-1.55, 1.6, 1.095), (0.08, 0.48, 2.19), '9b704d', 0) box('shelf_level_0', (-1.95, 1.6, 0.24), (0.88, 0.48, 0.08), '9b704d', 0) box('books_0_0', (-2.21, 1.6, 0.39), (0.08, 0.22, 0.22), '91aa8a', 0) box('books_0_1', (-2.105, 1.6, 0.4075), (0.08, 0.22, 0.255), 'e8dfcd', 0) box('books_0_2', (-2.0, 1.6, 0.425), (0.08, 0.22, 0.29), 'e2b96b', 0) box('books_0_3', (-1.895, 1.6, 0.39), (0.08, 0.22, 0.22), '91aa8a', 0) box('shelf_level_1', (-1.95, 1.6, 0.88), (0.88, 0.48, 0.08), '9b704d', 0) box('books_1_0', (-2.21, 1.6, 1.03), (0.08, 0.22, 0.22), '91aa8a', 0) box('books_1_1', (-2.105, 1.6, 1.0475), (0.08, 0.22, 0.255), 'e8dfcd', 0) box('books_1_2', (-2.0, 1.6, 1.065), (0.08, 0.22, 0.29), 'e2b96b', 0) box('books_1_3', (-1.895, 1.6, 1.03), (0.08, 0.22, 0.22), '91aa8a', 0) box('shelf_level_2', (-1.95, 1.6, 1.52), (0.88, 0.48, 0.08), '9b704d', 0) box('books_2_0', (-2.21, 1.6, 1.67), (0.08, 0.22, 0.22), '91aa8a', 0) box('books_2_1', (-2.105, 1.6, 1.6875), (0.08, 0.22, 0.255), 'e8dfcd', 0) box('books_2_2', (-2.0, 1.6, 1.705), (0.08, 0.22, 0.29), 'e2b96b', 0) box('books_2_3', (-1.895, 1.6, 1.67), (0.08, 0.22, 0.22), '91aa8a', 0) box('shelf_level_3', (-1.95, 1.6, 2.16), (0.88, 0.48, 0.08), '9b704d', 0) box('books_3_0', (-2.21, 1.6, 2.31), (0.08, 0.22, 0.22), '91aa8a', 0) box('books_3_1', (-2.105, 1.6, 2.3275), (0.08, 0.22, 0.255), 'e8dfcd', 0) box('books_3_2', (-2.0, 1.6, 2.345), (0.08, 0.22, 0.29), 'e2b96b', 0) box('books_3_3', (-1.895, 1.6, 2.31), (0.08, 0.22, 0.22), '91aa8a', 0) box('rug', (0.3, -0.7, 0.22), (2.0, 1.3, 0.04), 'e2b96b', 0) cylinder('lamp_base', (-1.9, -1.2, 0.235), 0.23, 0.07, '514b47') cylinder('lamp_stem', (-1.9, -1.2, 0.925), 0.035, 1.45, '514b47') cylinder('lamp_shade', (-1.9, -1.2, 1.65), 0.26, 0.35, 'e8dfcd') box('artwork_frame', (0.55, 2.59, 2.2), (0.95, 0.065, 0.7), '9b704d', 0) box('artwork_canvas', (0.55, 2.547, 2.2), (0.83, 0.025, 0.58), 'e8dfcd', 0) box('artwork_shape', (0.62, 2.527, 2.2), (0.37, 0.02, 0.33), 'e2b96b', 0) bpy.context.view_layer.update()