Skip to content

Commit

Permalink
Merge pull request #227 from gramaziokohler/drill_length
Browse files Browse the repository at this point in the history
Drill length
  • Loading branch information
chenkasirer authored Feb 15, 2024
2 parents 9a44540 + b96e2c0 commit e4efdb9
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Fixed T-Butt doesn't get extended to cross beam's plane.
* `SimpleSequenceGenerator` updated to work with `compas.datastructures.assembly` and generates building plan acording to type.
* Changed GH Categories for joint rules
* `BrepGeometryConsumer` continues to apply features even after the first error.
* `DrillHole` component calculates length from input line.
* `DrillHole` has default diameter proportional to beam cross-section.

### Removed

* Removed input `Length` from `DrillHole` component.

## [0.6.1] 2024-02-02

Expand Down
Binary file modified examples/Grasshopper/CT_NEW_UI_Example.3dm
Binary file not shown.
Binary file modified examples/Grasshopper/CT_NEW_UI_Example.gh
Binary file not shown.
18 changes: 9 additions & 9 deletions src/compas_timber/consumers/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,20 +220,20 @@ def result(self):
for beam in self.assembly.beams:
geometry = Brep.from_box(beam.blank)
debug_info = None
try:
resulting_geometry = self._apply_features(geometry, beam.features)
except FeatureApplicationError as error:
resulting_geometry = geometry
debug_info = error
resulting_geometry, debug_info = self._apply_features(geometry, beam.features)
yield BeamGeometry(beam, resulting_geometry, debug_info)

def _apply_features(self, geometry, features):
debug_info = []
for feature in features:
cls = self.FEATURE_MAP.get(type(feature), None)
if not cls:
raise ValueError("No applicator found for feature type: {}".format(type(feature)))
feature_applicator = cls(geometry, feature)
if not feature_applicator:
continue
geometry = feature_applicator.apply()
return geometry

try:
geometry = feature_applicator.apply()
except FeatureApplicationError as error:
debug_info.append(error)

return geometry, debug_info
13 changes: 6 additions & 7 deletions src/compas_timber/ghpython/components/CT_DrillHole/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@


class DrillHoleFeature(component):
def RunScript(self, beam, line, diameter, length):
def RunScript(self, beam, line, diameter):
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):
if not (beam and line):
return

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

f = DrillFeature(line_to_compas(line), diameter, length)
diameter = diameter or beam[0].width * beam[0].height * 0.5

line = line_to_compas(line)
f = DrillFeature(line, diameter, line.length)
return FeatureDefinition(f, beam)
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@
"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": [
Expand Down
5 changes: 4 additions & 1 deletion src/compas_timber/ghpython/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,10 @@ def has_errors(self):
return self.feature_errors or self.joint_errors

def add_feature_error(self, error):
self.feature_errors.append(error)
if isinstance(error, list):
self.feature_errors.extend(error)
else:
self.feature_errors.append(error)

def add_joint_error(self, error):
self.joint_errors.append(error)

0 comments on commit e4efdb9

Please sign in to comment.