-
Notifications
You must be signed in to change notification settings - Fork 3
Adding Group and viewer objects #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| 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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
|
@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. |
| 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() |
There was a problem hiding this comment.
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...
Can we take a look at this and discuss on tomorrow's dev meeting?