|
1 |
| -from compas.colors import Color |
2 | 1 | from compas.geometry import Box
|
3 |
| -from compas.geometry import Translation |
4 | 2 | from compas_viewer import Viewer
|
5 | 3 | from compas_viewer.scene import Tag
|
6 | 4 |
|
7 | 5 | box1 = Box.from_width_height_depth(5, 1, 1)
|
8 | 6 | box2 = Box.from_width_height_depth(1, 5, 1)
|
9 |
| -t = Tag("EN", (0, 0, 0), height=50) |
10 |
| -viewer = Viewer() |
11 |
| - |
12 |
| -# Simple list of objects |
13 |
| -group1 = viewer.scene.add([box1, box2, t]) |
| 7 | +t = Tag("EN", (5, 0, 0), height=50) |
14 | 8 |
|
15 | 9 |
|
16 |
| -# with kwargs for each object |
17 |
| -box1 = box1.transformed(Translation.from_vector([0, 5, 0])) |
18 |
| -box2 = box2.transformed(Translation.from_vector([0, 5, 0])) |
19 |
| -group2 = viewer.scene.add([(box1, {"name": "box1", "facecolor": Color.red()}), (box2, {"name": "box2", "facecolor": Color.green()})], linecolor=Color.blue()) |
| 10 | +viewer = Viewer() |
20 | 11 |
|
21 |
| -# with nested groups |
22 |
| -box1 = box1.transformed(Translation.from_vector([0, 5, 0])) |
23 |
| -box2 = box2.transformed(Translation.from_vector([0, 5, 0])) |
24 |
| -group3 = viewer.scene.add([[box1], box2]) |
25 |
| -group3.transformation = Translation.from_vector([0, 0, 5]) |
| 12 | +# Just fix API for groups |
| 13 | +group1 = viewer.scene.add_group(name="group1") |
| 14 | +group1.add(box1, name="box1") |
| 15 | +group1.add(box2, name="box2") |
| 16 | +group1.add(t, name="tag") |
26 | 17 | viewer.show()
|
0 commit comments