Skip to content

Conversation

@Licini
Copy link
Collaborator

@Licini Licini commented Mar 5, 2025

Can we take a look at this and discuss on tomorrow's dev meeting?

@Licini Licini changed the title Viewer objects Adding Group and viewer objects Apr 1, 2025
@Licini Licini requested review from petrasvestartas and tomvanmele and removed request for tomvanmele April 1, 2025 11:01
Comment on lines +1 to +40
from compas.geometry import Polygon
from compas.geometry import Translation
from compas_model.elements import BeamElement
from compas_model.elements import PlateElement
from compas_model.models import Model
from compas_viewer import Viewer

beam1 = BeamElement(0.2, 0.3, 3)
beam2 = BeamElement(0.2, 0.3, 3)
beam3 = BeamElement(0.2, 0.3, 3)
beam4 = BeamElement(0.2, 0.3, 3)

beam1.transformation = Translation.from_vector([3, 3, 0])
beam2.transformation = Translation.from_vector([-3, 3, 0])
beam3.transformation = Translation.from_vector([-3, -3, 0])
beam4.transformation = Translation.from_vector([3, -3, 0])


points: list[list[float]] = [
[-3, -3, 0],
[-3, 3, 0],
[3, 3, 0],
[3, -3, 0],
]
polygon: Polygon = Polygon(points)
plate = PlateElement(polygon=polygon, thickness=0.2)
plate.transformation = Translation.from_vector([0, 0, 3])

model = Model()
group = model.add_group(name="Beams")
model.add_element(beam1, parent=group)
model.add_element(beam2, parent=group)
model.add_element(beam3, parent=group)
model.add_element(beam4, parent=group)
model.add_element(plate)

# Vizualize.
viewer = Viewer()
viewer.scene.add(model)
viewer.show()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the intended API usage. Basically aligns to BlockResearchGroup/compas-Masonry#11

And at the end, we directly add the entire model to the viewer.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrt adding the entire model, i think this is good for now, but we will have to make it simple to visualise interfaces etc as well. maybe we can add a specific scene object for doing this kind of detailed things...

@Licini Licini marked this pull request as ready for review April 1, 2025 11:17
@Licini Licini marked this pull request as draft April 3, 2025 08:20
@Licini Licini marked this pull request as ready for review April 9, 2025 08:40
@Licini
Copy link
Collaborator Author

Licini commented Apr 9, 2025

@tomvanmele @petrasvestartas This is ready for review. All decisions from our last week meeting are now implemented. There is the doc build error for missing Group class from compas.datastructures which will go away once we cut a new release.

Comment on lines +1 to +40
from compas.geometry import Polygon
from compas.geometry import Translation
from compas_model.elements import BeamElement
from compas_model.elements import PlateElement
from compas_model.models import Model
from compas_viewer import Viewer

beam1 = BeamElement(0.2, 0.3, 3)
beam2 = BeamElement(0.2, 0.3, 3)
beam3 = BeamElement(0.2, 0.3, 3)
beam4 = BeamElement(0.2, 0.3, 3)

beam1.transformation = Translation.from_vector([3, 3, 0])
beam2.transformation = Translation.from_vector([-3, 3, 0])
beam3.transformation = Translation.from_vector([-3, -3, 0])
beam4.transformation = Translation.from_vector([3, -3, 0])


points: list[list[float]] = [
[-3, -3, 0],
[-3, 3, 0],
[3, 3, 0],
[3, -3, 0],
]
polygon: Polygon = Polygon(points)
plate = PlateElement(polygon=polygon, thickness=0.2)
plate.transformation = Translation.from_vector([0, 0, 3])

model = Model()
group = model.add_group(name="Beams")
model.add_element(beam1, parent=group)
model.add_element(beam2, parent=group)
model.add_element(beam3, parent=group)
model.add_element(beam4, parent=group)
model.add_element(plate)

# Vizualize.
viewer = Viewer()
viewer.scene.add(model)
viewer.show()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrt adding the entire model, i think this is good for now, but we will have to make it simple to visualise interfaces etc as well. maybe we can add a specific scene object for doing this kind of detailed things...

@Licini Licini merged commit 438f2e3 into main Apr 23, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants