Skip to main content

Generating a furnished room

This tutorial explains how to generate a furnished room with tables and a loudspeaker through the following steps:


Key steps:

  1. Project setup
  2. Create a model and add geometry
  3. Add geometry components
  4. Add a box and loudspeaker
  5. Prepare for simulation

Project setup

Import the required libraries, initialize an instance of TSDK, and create a new project:

from treble_tsdk import tsdk_namespace as treble
from treble_tsdk.utility_classes import (
Transform3d,
Vector3d,
Rotation,
Point3d,
BoundingBox,
)
from treble_tsdk import display_data as dd

tsdk = treble.TSDK()
p = tsdk.get_or_create_project("my_geometry_test_project")

Create a model and add geometry

Generate a T-shaped room and visualize its structure:

geo_def = treble.GeometryDefinitionGenerator.create_T_shaped_room(
a_side=6,
b_side=2,
c_side=2,
d_side=2,
height_z=2.5,
)
geo_def.plot()
T-shaped room.

Add geometry components

Query the component library for tables and select the first component from the results:

gc = tsdk.geometry_component_library.query(group='table')[0]
gc.plot()
Example table.

Place multiple tables in the room at specific positions and orientations:

geo_def.add_geometry_component(
"my_table", gc, Transform3d(Vector3d(1, 1, 0), Rotation(0, 0, 0))
)
geo_def.add_geometry_component(
"my_table2", gc, Transform3d(Vector3d(5, 1, 0), Rotation(0, 0, 0))
)
geo_def.add_geometry_component(
"my_table3", gc, Transform3d(Vector3d(3, 1, 0), Rotation(0, 0, 0))
)
geo_def.plot()
Room with table.

Add a box and loudspeaker

Create a box and place it inside the room:

box = treble.GeometryComponentGenerator.create_box(
BoundingBox(Point3d(-0.5, 0.5, -0.5), Point3d(0.5, -0.5, 0.5))
)
geo_def.add_geometry_component(
"name", box, Transform3d(Vector3d(3, 3, 0.5), Rotation(45, 0, 0))
)
geo_def.plot()
Room with box.

Next, position a loudspeaker on top:

speaker = treble.GeometryComponentGenerator.create_loudspeaker(
width=0.2, height=0.3, depth=0.5, membrane_diameter=0.1, membrane_center_height=0.1
)
geo_def.add_geometry_component(
"my_speaker", speaker, Transform3d(Vector3d(3, 3, 1.1), Rotation(-90, 0, 0))
)
geo_def.plot()
Room with box and loudspeaker.

Prepare for simulation

Once the geometry is finalized, add the model to a project:

model = p.add_model("my_model", geo_def)
model.as_live_model_status()

my_model
├── Id: 5b027c50-9bff-4ee7-81c8-4f5ebe705dbe
├── Status: Valid
├── Status message: OK
├── Is watertight: True
├── Filename: joined_model.zip
├── Filesize: 16.58KB
└── Layers: ['box', 'tshape_walls', 'tshape_ceiling', 'tshape_floor', 'enclosure', 'membrane', 'Furniture/Dining ta
Done