Skip to content
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

ShowElementsByType GH Component #335

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added attribute `is_group_element` to `TimberElement`.
* Added `JointRule.joints_from_beams_and_rules()` static method
* Added `Element.reset()` method.

* Added new `fasteners.py` module with new `Fastener` element type.
* Added new `compas_timber._fabrication.Lap`.
* Added `ShowElementsByType` GH Component.
* Added `fasteners` property to `TimberModel`.

### Changed

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# flake8: noqa
from ghpythonlib.componentbase import executingcomponent as component
from compas.scene import Scene


class ShowElementsByType(component):
def RunScript(self, model):
beam_scene = Scene()
plate_scene = Scene()
fastener_scene = Scene()

for beam in model.beams:
beam_scene.add(beam._geometry or beam.blank)
obucklin marked this conversation as resolved.
Show resolved Hide resolved
for plate in model.plates:
plate_scene.add(plate._geometry or plate.blank)
for fastener in model.fasteners:
fastener_scene.add(fastener.geometry)

return beam_scene.draw(), plate_scene.draw(), fastener_scene.draw()
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "ShowElementsByType",
"nickname": "ElementTypes",
"category": "COMPAS Timber",
"subcategory": "Show",
"description": "allows user to filter element geometries by type.",
"exposure": 2,
"ghpython": {
"isAdvancedMode": true,
"iconDisplay": 0,
"inputParameters": [
{
"name": "Model",
"description": "Model object.",
"typeHintID": "none",
"scriptParamAccess": 0
}
],
"outputParameters": [
{
"name": "Beams",
"description": "beam element geometries."
},
{
"name": "Plates",
"description": "plate element geometries."
},
{
"name": "Fasteners",
"description": "fastener element geometries."
}
]
}
}
7 changes: 7 additions & 0 deletions src/compas_timber/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ def joints(self):
if isinstance(interaction, Joint):
yield interaction # TODO: consider if there are other interaction types...

@property
def fasteners(self):
obucklin marked this conversation as resolved.
Show resolved Hide resolved
# type: () -> Generator[Fastener, None, None]
for element in self.elements():
if getattr(element, "is_fastener", False):
yield element

@property
def walls(self):
# type: () -> Generator[Wall, None, None]
Expand Down