import bpy # Your input data data = { "bathroom1": [8.52112676056338, 8.52112676056338, 6.408450704225352, 8.52112676056338, 6.408450704225352, 6.408450704225352, 8.52112676056338, 6.408450704225352], "bedroom1": [9.507042253521128, 5.422535211267606, 6.408450704225352, 5.422535211267606, 6.408450704225352, 3.3098591549295775, 9.507042253521128, 3.3098591549295775], "living_room": [14.71830985915493, 10.563380281690142, 10.563380281690142, 10.563380281690142, 10.563380281690142, 7.464788732394367, 14.71830985915493, 7.464788732394367], "kitchen": [9.507042253521128, 12.605633802816902, 4.366197183098592, 12.605633802816902, 4.366197183098592, 10.563380281690142, 9.507042253521128, 10.563380281690142], "bedroom2": [13.661971830985916, 7.464788732394367, 10.563380281690142, 7.464788732394367, 10.563380281690142, 6.408450704225352, 9.507042253521128, 6.408450704225352, 9.507042253521128, 4.366197183098592, 13.661971830985916, 4.366197183098592], "bedroom3": [12.605633802816902, 14.71830985915493, 9.507042253521128, 14.71830985915493, 9.507042253521128, 11.619718309859156, 10.563380281690142, 11.619718309859156, 10.563380281690142, 10.563380281690142, 12.605633802816902, 10.563380281690142], "bathroom2": [9.507042253521128, 10.563380281690142, 6.408450704225352, 10.563380281690142, 6.408450704225352, 8.52112676056338, 9.507042253521128, 8.52112676056338], "bedroom4": [5.422535211267606, 9.507042253521128, 3.3098591549295775, 9.507042253521128, 3.3098591549295775, 5.422535211267606, 5.422535211267606, 5.422535211267606], "corridor": [9.507042253521128, 11.619718309859156, 9.507042253521128, 8.52112676056338, 8.52112676056338, 8.52112676056338, 8.52112676056338, 6.408450704225352, 6.408450704225352, 6.408450704225352, 6.408450704225352, 9.507042253521128, 5.422535211267606, 9.507042253521128, 5.422535211267606, 5.422535211267606, 9.507042253521128, 5.422535211267606, 9.507042253521128, 6.408450704225352, 10.563380281690142, 6.408450704225352, 10.563380281690142, 11.619718309859156]} def create_room(name, coords): # Create vertices for the room verts = [(coords[i], coords[i+1], 0) for i in range(0, len(coords), 2)] edges = [(i, (i+1)%len(verts)) for i in range(len(verts))] # Create a new mesh with a given name mesh = bpy.data.meshes.new(name) # Load the room data into the mesh mesh.from_pydata(verts, edges, []) # Create a new object with the mesh obj = bpy.data.objects.new(name, mesh) # Link the object to the scene bpy.context.scene.collection.objects.link(obj) # Set the object as the active object bpy.context.view_layer.objects.active = obj obj.select_set(True) # Switch to edit mode bpy.ops.object.mode_set(mode='EDIT') # Select all mesh elements bpy.ops.mesh.select_all(action='SELECT') # Switch back to object mode bpy.ops.object.mode_set(mode='OBJECT') # Create rooms from the data for room_name, room_coords in data.items(): create_room(room_name, room_coords)