Skip to content

Commit

Permalink
Merge pull request #272 from gramaziokohler/Surface_model_show_beam_type
Browse files Browse the repository at this point in the history
Surface_model_show_beam_type
  • Loading branch information
obucklin authored Sep 10, 2024
2 parents 7fff411 + 7ba9d5d commit dbd3d9a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added `SurfaceModelJointOverride` GH Component.
* Added `Plate` element.
* Added attribute `plates` to `TimberModel`.
* Added `SurfaceModelJointOverride` GH Component
* Added `ShowSurfaceModelBeamType` GH Component

### Changed

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from compas.scene import Scene
from ghpythonlib.componentbase import executingcomponent as component
from Grasshopper.Kernel.GH_RuntimeMessageLevel import Warning
from System.Windows.Forms import ToolStripSeparator

from compas_timber.ghpython.ghcomponent_helpers import rename_gh_output


class SurfaceModelJointRule(component):
def __init__(self):
super(SurfaceModelJointRule, self).__init__()
self.beam_type = None
if ghenv.Component.Params.Output[0].NickName == "type":
self.joint_type = None
else:
self.beam_type = ghenv.Component.Params.Output[0].NickName

def RunScript(self, model):
self.names = set(element.attributes.get("category") for element in model.elements())
self.names.remove(None)
if not self.beam_type:
ghenv.Component.Message = "Select beam type from context menu (right click)"
self.AddRuntimeMessage(Warning, "Select beam type from context menu (right click)")
return None
else:
ghenv.Component.Message = self.beam_type
scene = Scene()
for beam in model.beams:
if beam.attributes["category"] == self.beam_type:
scene.add(beam.geometry)
return scene.draw()

def AppendAdditionalMenuItems(self, menu):
if not self.RuntimeMessages(Warning):
menu.Items.Add(ToolStripSeparator())
for name in self.names:
item = menu.Items.Add(name, None, self.on_item_click)
if self.beam_type and name == self.beam_type:
item.Checked = True

def on_item_click(self, sender, event_info):
self.beam_type = str(sender)
rename_gh_output(self.beam_type, 0, ghenv)
ghenv.Component.ExpireSolution(True)
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,26 @@
{
"name": "ShowSurfaceModelBeamTypes",
"nickname": "ShowBeamType",
"category": "COMPAS Timber",
"subcategory": "Show",
"description": "allows user to visualize beam types in surface model.",
"exposure": 2,
"ghpython": {
"isAdvancedMode": true,
"iconDisplay": 0,
"inputParameters": [
{
"name": "Model",
"description": "Model object.",
"typeHintID": "none",
"scriptParamAccess": 0
}
],
"outputParameters": [
{
"name": "type",
"description": "beam type to visualize."
}
]
}
}

0 comments on commit dbd3d9a

Please sign in to comment.