From 48e4160f55a2a2c45b5f4f0367c6aa8677fa1328 Mon Sep 17 00:00:00 2001 From: obucklin Date: Mon, 16 Sep 2024 10:36:39 +0200 Subject: [PATCH 1/3] init --- src/compas_timber/design/wall_from_surface.py | 11 +--- .../components/CT_Model_From_Surface/code.py | 65 +++++++++++++------ 2 files changed, 48 insertions(+), 28 deletions(-) diff --git a/src/compas_timber/design/wall_from_surface.py b/src/compas_timber/design/wall_from_surface.py index fb42877c1..3f10e77cb 100644 --- a/src/compas_timber/design/wall_from_surface.py +++ b/src/compas_timber/design/wall_from_surface.py @@ -274,10 +274,10 @@ def create_model(self): model.add_element(element) topologies = [] solver = ConnectionSolver() - found_pairs = solver.find_intersecting_pairs(model.beams, rtree=True, max_distance=self.dist_tolerance) + found_pairs = solver.find_intersecting_pairs(model.beams, rtree=True, max_distance=self.dist_tolerance*100) for pair in found_pairs: beam_a, beam_b = pair - detected_topo, beam_a, beam_b = solver.find_topology(beam_a, beam_b, max_distance=self.dist_tolerance) + detected_topo, beam_a, beam_b = solver.find_topology(beam_a, beam_b, max_distance=self.dist_tolerance*100) if not detected_topo == JointTopology.TOPO_UNKNOWN: topologies.append({"detected_topo": detected_topo, "beam_a": beam_a, "beam_b": beam_b}) for rule in self.rules: @@ -323,7 +323,6 @@ def parse_loops(self): def generate_perimeter_beams(self): interior_indices = self.get_interior_segment_indices(self.outer_polyline) - print(interior_indices) for i, segment in enumerate(self.outer_polyline.lines): beam_def = self.BeamDefinition(segment, parent=self) if i in interior_indices: @@ -355,7 +354,6 @@ def generate_perimeter_beams(self): self._beam_definitions.append(self.BeamDefinition(king_line, type="king_stud", parent=self)) def get_interior_segment_indices(self, polyline): - print(polyline.points) points = polyline.points[0:-1] out = [] for index in range(len(points)): @@ -367,13 +365,10 @@ def get_interior_segment_indices(self, polyline): angle = angle_vectors_signed( points[index - 1] - points[index], points[index + 1] - points[index], self.normal, deg=True ) - print(index, angle) if angle > 0: - print(index) - out.append(index - 1) out.append(index) if len(out) > 0: - out.insert(1, out[0] - 1) + out.insert(0, out[0] - 1) return set(out) def offset_elements(self, element_loop): diff --git a/src/compas_timber/ghpython/components/CT_Model_From_Surface/code.py b/src/compas_timber/ghpython/components/CT_Model_From_Surface/code.py index 13b0f4297..af807b77f 100644 --- a/src/compas_timber/ghpython/components/CT_Model_From_Surface/code.py +++ b/src/compas_timber/ghpython/components/CT_Model_From_Surface/code.py @@ -19,21 +19,55 @@ def RunScript(self, surface, stud_spacing, beam_width, frame_depth, z_axis, opti return if not isinstance(surface, RhinoBrep): raise TypeError("Expected a compas.geometry.Surface, got: {}".format(type(surface))) + + units = Rhino.RhinoDoc.ActiveDoc.GetUnitSystemName(True, True, True, True) + tol = None + if units == "m": + tol = Tolerance(unit="M", absolute=1e-6, relative=1e-6) + elif units == "cm": + tol = Tolerance(unit="CM", absolute=1e-4, relative=1e-4) + elif units == "mm": + tol = Tolerance(unit="MM", absolute=1e-3, relative=1e-3) + if not stud_spacing: - self.AddRuntimeMessage(Warning, "Input parameter 'spacing' failed to collect data") - return - if stud_spacing is not None and not isinstance(stud_spacing, float): + self.AddRuntimeMessage( + Warning, "Input parameter 'stud_spacing' failed to collect data, using default value of 625mm" + ) + if tol.unit == "M": + stud_spacing = 0.625 + elif tol.unit == "MM": + stud_spacing = 625.0 + elif tol.unit == "CM": + stud_spacing = 62.5 + elif not isinstance(stud_spacing, float): raise TypeError("stud_spacing expected a float, got: {}".format(type(stud_spacing))) + if not beam_width: - self.AddRuntimeMessage(Warning, "Input parameter 'beam_width' failed to collect data") - return - if beam_width is not None and not isinstance(beam_width, float): - raise TypeError("stud_spacing expected a float, got: {}".format(type(stud_spacing))) + self.AddRuntimeMessage( + Warning, "Input parameter 'beam_width' failed to collect data, using default value of 60mm" + ) + if tol.unit == "M": + beam_width = 0.06 + elif tol.unit == "MM": + beam_width = 60.0 + elif tol.unit == "CM": + beam_width = 6.0 + elif not isinstance(beam_width, float): + raise TypeError("beam_width expected a float, got: {}".format(type(beam_width))) + if not frame_depth: - self.AddRuntimeMessage(Warning, "Input parameter 'frame_depth' failed to collect data") - return - if frame_depth is not None and not isinstance(frame_depth, float): - raise TypeError("stud_spacing expected a float, got: {}".format(type(stud_spacing))) + self.AddRuntimeMessage( + Warning, "Input parameter 'frame_depth' failed to collect data, using default value of 140mm" + ) + if tol.unit == "M": + frame_depth = 0.14 + elif tol.unit == "MM": + frame_depth = 140.0 + elif tol.unit == "CM": + frame_depth = 14.0 + elif not isinstance(frame_depth, float): + raise TypeError("frame_depth expected a float, got: {}".format(type(frame_depth))) + if z_axis is not None and not isinstance(z_axis, RhinoVector): raise TypeError("Expected a compas.geometry.Vector, got: {}".format(type(z_axis))) @@ -43,15 +77,6 @@ def RunScript(self, surface, stud_spacing, beam_width, frame_depth, z_axis, opti if not options: options = {} - units = Rhino.RhinoDoc.ActiveDoc.GetUnitSystemName(True, True, True, True) - tol = None - if units == "m": - tol = Tolerance(unit="M", absolute=1e-6, relative=1e-6) - elif units == "cm": - tol = Tolerance(unit="CM", absolute=1e-4, relative=1e-4) - elif units == "mm": - tol = Tolerance(unit="MM", absolute=1e-3, relative=1e-3) - surface_model = SurfaceModel( Brep.from_native(surface), stud_spacing, beam_width, frame_depth, z_axis, tol, **options ) From c8b94db0c82ea82e6155177d728147995231aa7f Mon Sep 17 00:00:00 2001 From: obucklin Date: Mon, 16 Sep 2024 10:40:01 +0200 Subject: [PATCH 2/3] format, lint, changelog --- CHANGELOG.md | 4 +++- src/compas_timber/design/wall_from_surface.py | 4 ++-- .../ghpython/components/CT_Model_From_Surface/code.py | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c532b0de9..5f31c8fad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,11 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -* Added bake component for `Plate` eleents. +* Added bake component for `Plate` elements. +* Added default paramteters for `Surface Model` in the GH Component ### Changed * Fixed wrong image file paths in the Documentation. +* Fixed polyline analysis for generating `SurfaceModel` ### Removed diff --git a/src/compas_timber/design/wall_from_surface.py b/src/compas_timber/design/wall_from_surface.py index 3f10e77cb..2a8296bff 100644 --- a/src/compas_timber/design/wall_from_surface.py +++ b/src/compas_timber/design/wall_from_surface.py @@ -274,10 +274,10 @@ def create_model(self): model.add_element(element) topologies = [] solver = ConnectionSolver() - found_pairs = solver.find_intersecting_pairs(model.beams, rtree=True, max_distance=self.dist_tolerance*100) + found_pairs = solver.find_intersecting_pairs(model.beams, rtree=True, max_distance=self.dist_tolerance * 100) for pair in found_pairs: beam_a, beam_b = pair - detected_topo, beam_a, beam_b = solver.find_topology(beam_a, beam_b, max_distance=self.dist_tolerance*100) + detected_topo, beam_a, beam_b = solver.find_topology(beam_a, beam_b, max_distance=self.dist_tolerance * 100) if not detected_topo == JointTopology.TOPO_UNKNOWN: topologies.append({"detected_topo": detected_topo, "beam_a": beam_a, "beam_b": beam_b}) for rule in self.rules: diff --git a/src/compas_timber/ghpython/components/CT_Model_From_Surface/code.py b/src/compas_timber/ghpython/components/CT_Model_From_Surface/code.py index af807b77f..1adf7cdb9 100644 --- a/src/compas_timber/ghpython/components/CT_Model_From_Surface/code.py +++ b/src/compas_timber/ghpython/components/CT_Model_From_Surface/code.py @@ -12,6 +12,7 @@ from compas_timber.design import DebugInfomation from compas_timber.design import SurfaceModel + class SurfaceModelComponent(component): def RunScript(self, surface, stud_spacing, beam_width, frame_depth, z_axis, options, CreateGeometry=False): # minimum inputs required From b19b51261135a5150ab280eda8b3b6c794eb5288 Mon Sep 17 00:00:00 2001 From: obucklin Date: Mon, 16 Sep 2024 10:48:02 +0200 Subject: [PATCH 3/3] removed bad tolerance multiplier --- src/compas_timber/design/wall_from_surface.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compas_timber/design/wall_from_surface.py b/src/compas_timber/design/wall_from_surface.py index 3b51387f3..b9e6fd35d 100644 --- a/src/compas_timber/design/wall_from_surface.py +++ b/src/compas_timber/design/wall_from_surface.py @@ -277,7 +277,7 @@ def create_model(self): found_pairs = solver.find_intersecting_pairs(list(model.beams), rtree=True, max_distance=self.dist_tolerance) for pair in found_pairs: beam_a, beam_b = pair - detected_topo, beam_a, beam_b = solver.find_topology(beam_a, beam_b, max_distance=self.dist_tolerance * 100) + detected_topo, beam_a, beam_b = solver.find_topology(beam_a, beam_b, max_distance=self.dist_tolerance) if not detected_topo == JointTopology.TOPO_UNKNOWN: topologies.append({"detected_topo": detected_topo, "beam_a": beam_a, "beam_b": beam_b}) for rule in self.rules: