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

Drill hole #172

Merged
merged 4 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Added `btlx_processes` folder and processes `JackCut` and `FrenchRidgeHalfLap`
* Added `BTLx` Grasshopper component
* Added `FrenchRidgeHalfLap` joint
* Added `DrillHole` Feature.
* Added `DrillHoleFeature` Grasshopper component.

### Changed
* Changed `Beam` definition to include `blank_frame` and `blank_length` attributes
Expand Down
4 changes: 3 additions & 1 deletion src/compas_timber/consumers/geometry.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from compas.geometry import Brep
from compas.geometry import Cylinder
from compas.geometry import Frame
from compas.geometry import Plane

from compas_timber.parts import CutFeature
from compas_timber.parts import DrillFeature
from compas_timber.parts import MillVolume


def apply_drill_feature(beam_geometry, feature):
frame = Frame.from_plane(feature.plane)
frame = Frame.from_plane(Plane(point=feature.line.start, normal=feature.line.vector))
frame.point += frame.zaxis * 0.5 * feature.length
drill_volume = Cylinder(frame=frame, radius=feature.diameter / 2.0, height=feature.length)
return beam_geometry - Brep.from_cylinder(drill_volume)

Expand Down
32 changes: 32 additions & 0 deletions src/compas_timber/ghpython/components/CT_DrillHole/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from ghpythonlib.componentbase import executingcomponent as component
from Grasshopper.Kernel.GH_RuntimeMessageLevel import Warning

from compas_rhino.conversions import line_to_compas

from compas_timber.ghpython import FeatureDefinition
from compas_timber.parts import DrillFeature


class DrillHoleFeature(component):
def RunScript(self, Beam, Line, Diameter, Length):
Copy link
Member

Choose a reason for hiding this comment

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

is it required that the param names are uppercased? I think it does a positional match, so, these could be lowercased

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right. That's awesome, had no idea. will make a separate PR to change all the components, will be much cozier :)

if not Beam:
self.AddRuntimeMessage(Warning, "Input parameter Beams failed to collect data")
if not Line:
self.AddRuntimeMessage(Warning, "Input parameter Line failed to collect data")
if not Diameter:
self.AddRuntimeMessage(Warning, "Input parameter Diameter failed to collect data")
if not Length:
self.AddRuntimeMessage(Warning, "Input parameter Length failed to collect data")

if not (Beam and Line and Diameter and Length):
return

if not isinstance(Beam, list):
Beam = [Beam]

Feature = []
for beam in Beam:
feature = DrillFeature(line_to_compas(Line), Diameter, Length)
Feature.append(FeatureDefinition(feature, beam))

return Feature
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions src/compas_timber/ghpython/components/CT_DrillHole/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "Drill Hole Feature",
"nickname": "Drill Hole",
"category": "COMPAS Timber",
"subcategory": "Features",
"description": "Creates a Feature representing a drill hole in Beam. Specify multiple Beams to drill through all Beams with the same hole.",
"exposure": 4,
"ghpython": {
"isAdvancedMode": true,
"iconDisplay": 0,
"inputParameters": [
{
"name": "Beam",
"description": "Beam(s) to subtract Geometry from.",
"typeHintID": "none",
"scriptParamAccess": 1
},
{
"name": "Line",
"description": "Line representing the axis of the drill hole.",
"typeHintID": "line",
"scriptParamAccess": 0
},
{
"name": "Diameter",
"description": "The diameter of the drill hole",
"typeHintID": "float",
"scriptParamAccess": 0
},
{
"name": "Length",
"description": "The depth of the drill hole from the starting point of the line",
"typeHintID": "float",
"scriptParamAccess": 0
}
],
"outputParameters": [
{
"name": "Feature",
"description": "Defined Feature(s)."
}
]
}
}
6 changes: 3 additions & 3 deletions src/compas_timber/parts/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ class DrillFeature(Feature):

"""

def __init__(self, plane, diameter, length, **kwargs):
def __init__(self, line, diameter, length, **kwargs):
super(DrillFeature, self).__init__(**kwargs)
self.plane = plane
self.line = line
self.diameter = diameter
self.length = length

@property
def data(self):
data_dict = {"plane": self.plane, "diameter": self.diameter, "length": self.length}
data_dict = {"line": self.line, "diameter": self.diameter, "length": self.length}
data_dict.update(super(DrillFeature, self).data)
return data_dict

Expand Down
Loading