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)] linear = tuple(v / 12.92 if v < 0.04045 else ((v + 0.055) / 1.055) ** 2.4 for v in rgb) mat.diffuse_color = linear + (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), 'ece3d0', 0) box('wall_back', (0, 2.7, 1.7), (5.6, 0.15, 3), '859eae', 0) box('wall_side', (-2.7, 0, 1.7), (0.15, 5.6, 3), '859eae', 0) box('trim_back', (0, 2.595, 0.29), (5.2, 0.05, 0.18), 'ece3d0', 0) box('trim_side', (-2.595, 0, 0.29), (0.05, 5.2, 0.18), 'ece3d0', 0) box('refrigerator_body', (-1.95, 1.85, 1.25), (0.92, 0.95, 2.1), '9b7359', -1.5708) box('refrigerator_door_0', (-1.46, 2.03, 1.25), (0.425, 0.035, 2.01), 'ece3d0', -1.5708) box('refrigerator_handle_0', (-1.425, 1.88, 1.345), (0.04, 0.04, 0.18), '504945', -1.5708) box('refrigerator_door_1', (-1.46, 1.67, 1.25), (0.425, 0.035, 2.01), 'ece3d0', -1.5708) box('refrigerator_handle_1', (-1.425, 1.82, 1.345), (0.04, 0.04, 0.18), '504945', -1.5708) box('counter_body', (-2.08, -0.35, 0.62), (2.35, 0.75, 0.84), '9b7359', -1.5708) box('counter_door_0', (-1.685, 0.2075, 0.62), (1.14, 0.035, 0.75), 'ece3d0', -1.5708) box('counter_handle_0', (-1.645, -0.2425, 0.662), (0.04, 0.04, 0.18), '504945', -1.5708) box('counter_door_1', (-1.685, -0.9075, 0.62), (1.14, 0.035, 0.75), 'ece3d0', -1.5708) box('counter_handle_1', (-1.645, -0.3575, 0.662), (0.04, 0.04, 0.18), '504945', -1.5708) box('counter_worktop', (-2.08, -0.35, 1.1), (2.43, 0.8, 0.12), 'ece3d0', -1.5708) box('stove_top', (-2.07, 0.3, 1.177), (0.76, 0.63, 0.035), '4a4a51', -1.5708) cylinder('stove_burner_0', (-1.93, 0.52, 1.201), 0.105, 0.02, '85838b') cylinder('stove_burner_1', (-2.21, 0.52, 1.201), 0.105, 0.02, '85838b') cylinder('stove_burner_2', (-1.93, 0.08, 1.201), 0.105, 0.02, '85838b') cylinder('stove_burner_3', (-2.21, 0.08, 1.201), 0.105, 0.02, '85838b') box('sink_basin', (-2.07, -0.85, 1.173), (0.57, 0.5, 0.026), '646b72', -1.5708) box('sink_rim_0', (-2.07, -0.53, 1.19), (0.06, 0.61, 0.04), 'b9c6c9', -1.5708) box('sink_rim_1', (-2.07, -1.17, 1.19), (0.06, 0.61, 0.04), 'b9c6c9', -1.5708) box('sink_edge_0', (-1.75, -0.85, 1.19), (0.66, 0.06, 0.04), 'b9c6c9', -1.5708) box('sink_edge_1', (-2.39, -0.85, 1.19), (0.66, 0.06, 0.04), 'b9c6c9', -1.5708) box('sink_tap_stem', (-2.38, -0.85, 1.35), (0.055, 0.055, 0.32), 'b9c6c9', -1.5708) box('sink_tap_spout', (-2.29, -0.85, 1.49), (0.055, 0.22, 0.055), 'b9c6c9', -1.5708) box('table_top', (0.35, -0.55, 1.05), (1.35, 0.9, 0.12), '9b7359', -1.5708) box('table_leg_0', (0.68, 0.005, 0.595), (0.1, 0.1, 0.79), '9b7359', -1.5708) box('table_leg_1', (0.02, 0.005, 0.595), (0.1, 0.1, 0.79), '9b7359', -1.5708) box('table_leg_2', (0.68, -1.095, 0.595), (0.1, 0.1, 0.79), '9b7359', -1.5708) box('table_leg_3', (0.02, -1.095, 0.595), (0.1, 0.1, 0.79), '9b7359', -1.5708) box('chair_1_leg_0', (1.26, -0.82, 0.4), (0.08, 0.08, 0.4), '9b7359', -4.7124) box('chair_1_leg_1', (1.64, -0.82, 0.4), (0.08, 0.08, 0.4), '9b7359', -4.7124) box('chair_1_leg_2', (1.26, -0.44, 0.4), (0.08, 0.08, 0.4), '9b7359', -4.7124) box('chair_1_leg_3', (1.64, -0.44, 0.4), (0.08, 0.08, 0.4), '9b7359', -4.7124) box('chair_1_seat', (1.45, -0.63, 0.65), (0.64, 0.62, 0.14), 'cb8d74', -4.7124) box('chair_1_back', (1.68, -0.63, 0.97), (0.64, 0.12, 0.66), 'cb8d74', -4.7124) box('chair_2_leg_0', (0.26, -1.68, 0.4), (0.08, 0.08, 0.4), '9b7359', 0.0) box('chair_2_leg_1', (0.26, -2.06, 0.4), (0.08, 0.08, 0.4), '9b7359', 0.0) box('chair_2_leg_2', (0.64, -1.68, 0.4), (0.08, 0.08, 0.4), '9b7359', 0.0) box('chair_2_leg_3', (0.64, -2.06, 0.4), (0.08, 0.08, 0.4), '9b7359', 0.0) box('chair_2_seat', (0.45, -1.87, 0.65), (0.64, 0.62, 0.14), 'cb8d74', 0.0) box('chair_2_back', (0.45, -2.1, 0.97), (0.64, 0.12, 0.66), 'cb8d74', 0.0) cylinder('bowl', (0.35, -0.55, 1.15), 0.19, 0.08, 'cb8d74') cylinder('plant_pot', (1.35, 1.85, 0.35), 0.19, 0.3, 'cb8d74') cylinder('plant_stem', (1.35, 1.85, 0.6), 0.035, 0.35, '6d8051') box('plant_leaf_0', (1.35, 1.96, 0.75), (0.25, 0.17, 0.3), '739662', -1.5708) box('plant_leaf_1', (1.33, 1.74, 0.75), (0.25, 0.17, 0.3), '739662', -2.3708) box('plant_leaf_2', (1.25, 1.85, 0.75), (0.25, 0.17, 0.3), '739662', -3.1708) box('artwork_frame', (-2.59, -0.55, 2.2), (0.95, 0.065, 0.7), '9b7359', -1.5708) box('artwork_canvas', (-2.547, -0.55, 2.2), (0.83, 0.025, 0.58), 'ece3d0', -1.5708) box('artwork_shape', (-2.527, -0.62, 2.2), (0.37, 0.02, 0.33), 'cb8d74', -1.5708) bpy.context.view_layer.update()