Examples
Making a box
Make a box, move it, and show it in COMPAS Viewer
This example builds a box, rotates and moves it, turns it into a mesh and opens it in COMPAS Viewer.
Install the viewer
uv add compas_viewer
mamba install -c conda-forge compas_viewer
conda install -c conda-forge compas_viewer
pip install compas_viewer
The script
box.py
import math
from compas.geometry import Box, Frame, Rotation, Translation
from compas_viewer import Viewer
box = Box(1, 2, 3, frame=Frame.worldXY())
T = Translation.from_vector([5, 0, 0])
R = Rotation.from_axis_and_angle([0, 0, 1], math.radians(45))
box.transform(T * R)
mesh = box.to_mesh()
viewer = Viewer()
viewer.scene.add(mesh)
viewer.show()
Run it with python box.py, or uv run box.py. A window opens with the box; drag to orbit and scroll to zoom.
Transformations are 4x4 matrices. Combine them with *; the right-hand one applies first, so the box rotates about the world origin and then moves.