Read the modelยค
compas.json_load gives back the whole thing: elements, features, materials,
the tree, and the graph with the contacts on it.

237 elements, 733 contacts. The scene tree on the right is the model's own tree, mirrored, so every group can be switched off on its own.
import pathlib
import compas
from compas.colors import Color
from compas_model.elements import Group
from compas_viewer import Viewer
from compas_tf.model import TFModel
from compas_tf.viewer import zoom_to
MODEL_FILE = pathlib.Path(__file__).parent.parent / "data" / "cantilevers_baked_model.json"
# Baked before it was written, so nothing is recomputed on load.
model: TFModel = compas.json_load(MODEL_FILE)
elements = list(model.geometry_elements())
contacts = list(model.contacts())
print(f"{len(elements)} elements, {len(contacts)} contacts")
viewer = Viewer()
# Mirrored, not flattened, so the groups stay browsable in the scene.
def add_tree(node, parent=None):
for child in node.children:
element = child.element
if isinstance(element, Group):
add_tree(child, viewer.scene.add_group(element.name, parent=parent))
elif element.modelgeometry is not None:
viewer.scene.add(element, name=element.name, parent=parent)
add_tree(model.tree.root)
group = viewer.scene.add_group("contacts")
for contact in contacts:
viewer.scene.add(contact.polygon, parent=group, facecolor=Color(1, 0, 0), linecolor=Color(1, 0, 0), show_points=False)
# The camera's far plane is 1000 mm, so without this the building starts clipped.
zoom_to(viewer, [element.aabb for element in elements])
viewer.show()
The geometry is baked - every boolean already evaluated and stored - so this runs none and needs no boolean backend: 0.60 s for 3.9 MB.
What the 237 are:
floor_model 185 quarters_model 136 = 4 x 34
oculus_model 9
connectors 40
columns_model 8 4 x (column + support)
connectors 8
connector_cylinders 32
outer_rib_connectors 4
A quarter is 34: 18 beds, 6 t-sections, 2 outer ribs, 2 inner ribs, 3 inner
beams, 3 wedges. 145 of the 237 are PlateElement; the rest are the columns,
their supports, and the fasteners.
model.elements() yields the groups too, geometry_elements() only the leaves.
model.contacts() reads what the search stored rather than searching again.