From 27bc1ea96c24afdc2eff8dc82cfe38ba41ae1e66 Mon Sep 17 00:00:00 2001 From: obucklin Date: Thu, 12 Sep 2024 13:45:36 +0200 Subject: [PATCH 1/6] added defaults --- src/compas_timber/design/wall_from_surface.py | 46 +++++++++++++++---- .../components/CT_SurfaceModelOptions/code.py | 8 ++-- .../CT_SurfaceModelOptions/metadata.json | 2 +- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/compas_timber/design/wall_from_surface.py b/src/compas_timber/design/wall_from_surface.py index 37efe2777..c1bb51b82 100644 --- a/src/compas_timber/design/wall_from_surface.py +++ b/src/compas_timber/design/wall_from_surface.py @@ -24,7 +24,7 @@ from compas_timber.connections import LButtJoint from compas_timber.connections import TButtJoint from compas_timber.design import CategoryRule -from compas_timber.elements import Beam +from compas_timber.elements import Beam, beam from compas_timber.model import TimberModel @@ -90,20 +90,48 @@ def __init__( tolerance=Tolerance(unit="MM", absolute=1e-3, relative=1e-3), sheeting_outside=None, sheeting_inside=None, - lintel_posts=True, + use_jack_studs=True, edge_stud_offset=0.0, custom_dimensions=None, joint_overrides=None, ): self.surface = surface - self.beam_width = beam_width - self.frame_depth = frame_depth - self.stud_spacing = stud_spacing + + if stud_spacing is not None: + self.stud_spacing = stud_spacing + else: + if tolerance.unit == "M": + self.stud_spacing = 0.625 + elif tolerance.unit == "MM": + self.stud_spacing = 625.0 + elif tolerance.unit == "CM": + self.stud_spacing = 62.5 + + if beam_width is not None: + self.beam_width = beam_width + else: + if tolerance.unit == "M": + self.beam_width = 0.06 + elif tolerance.unit == "MM": + self.beam_width = 60.0 + elif tolerance.unit == "CM": + self.beam_width = 6.0 + + if frame_depth is not None: + self.frame_depth = frame_depth + else: + if tolerance.unit == "M": + self.frame_depth = 0.14 + elif tolerance.unit == "MM": + self.frame_depth = 140.0 + elif tolerance.unit == "CM": + self.frame_depth = 14.0 + self._z_axis = z_axis or Vector.Zaxis() self.sheeting_outside = sheeting_outside self.sheeting_inside = sheeting_inside self.edge_stud_offset = edge_stud_offset or 0.0 - self.lintel_posts = lintel_posts + self.use_jack_studs = use_jack_studs self._normal = None self.outer_polyline = None self.inner_polylines = [] @@ -118,6 +146,8 @@ def __init__( self.joint_overrides = joint_overrides self.dist_tolerance = tolerance.relative + + for key in self.BEAM_CATEGORY_NAMES: self.beam_dimensions[key] = [self.beam_width, self.frame_depth] if custom_dimensions: @@ -313,7 +343,7 @@ def generate_perimeter_elements(self): angle_vectors(segment.direction, self.z_axis, deg=True) < 45 or angle_vectors(segment.direction, self.z_axis, deg=True) > 135 ): - if self.lintel_posts: + if self.use_jack_studs: element.type = "jack_stud" else: element.type = "king_stud" @@ -329,7 +359,7 @@ def generate_perimeter_elements(self): element.type = "plate" self._elements.append(element) self._elements = self.offset_elements(self._elements) - if self.lintel_posts: + if self.use_jack_studs: for element in self._elements: if element.type == "jack_stud": offset = (self.beam_dimensions["jack_stud"][0] + self.beam_dimensions["king_stud"][0]) / 2 diff --git a/src/compas_timber/ghpython/components/CT_SurfaceModelOptions/code.py b/src/compas_timber/ghpython/components/CT_SurfaceModelOptions/code.py index d96552198..63547f3e8 100644 --- a/src/compas_timber/ghpython/components/CT_SurfaceModelOptions/code.py +++ b/src/compas_timber/ghpython/components/CT_SurfaceModelOptions/code.py @@ -3,14 +3,14 @@ class SurfaceModelOptions(component): def RunScript( - self, sheeting_outside, sheeting_inside, lintel_posts, edge_stud_offset, custom_dimensions, joint_overrides + self, sheeting_outside, sheeting_inside, use_jack_studs, edge_stud_offset, custom_dimensions, joint_overrides ): if sheeting_outside is not None and not isinstance(sheeting_outside, float): raise TypeError("sheeting_outside expected a float, got: {}".format(type(sheeting_outside))) if sheeting_inside is not None and not isinstance(sheeting_inside, float): raise TypeError("sheeting_inside expected a float, got: {}".format(type(sheeting_inside))) - if lintel_posts is not None and not isinstance(lintel_posts, bool): - raise TypeError("lintel_posts expected a bool, got: {}".format(type(lintel_posts))) + if use_jack_studs is not None and not isinstance(use_jack_studs, bool): + raise TypeError("lintel_posts expected a bool, got: {}".format(type(use_jack_studs))) dims = {} for item in custom_dimensions: @@ -20,7 +20,7 @@ def RunScript( dict = { "sheeting_outside": sheeting_outside, "sheeting_inside": sheeting_inside, - "lintel_posts": lintel_posts, + "use_jack_studs": use_jack_studs, "edge_stud_offset": edge_stud_offset, "custom_dimensions": dims, "joint_overrides": joint_overrides, diff --git a/src/compas_timber/ghpython/components/CT_SurfaceModelOptions/metadata.json b/src/compas_timber/ghpython/components/CT_SurfaceModelOptions/metadata.json index 7aa82aee1..35c3b282e 100644 --- a/src/compas_timber/ghpython/components/CT_SurfaceModelOptions/metadata.json +++ b/src/compas_timber/ghpython/components/CT_SurfaceModelOptions/metadata.json @@ -22,7 +22,7 @@ "scriptParamAccess": 0 }, { - "name": "lintel_posts", + "name": "use_jack_studs", "description": "(optional) If False, jack studs will not be generated and headers will butt directly onto king studs.", "typeHintID": "bool", "scriptParamAccess": 0 From 3174f2350c811637294a7fdc6aa26f1214286964 Mon Sep 17 00:00:00 2001 From: obucklin Date: Thu, 12 Sep 2024 14:09:20 +0200 Subject: [PATCH 2/6] added defaults, fixed component --- src/compas_timber/design/wall_from_surface.py | 4 ++-- .../ghpython/components/CT_Model_From_Surface/code.py | 9 +++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/compas_timber/design/wall_from_surface.py b/src/compas_timber/design/wall_from_surface.py index c1bb51b82..2e0489214 100644 --- a/src/compas_timber/design/wall_from_surface.py +++ b/src/compas_timber/design/wall_from_surface.py @@ -626,7 +626,7 @@ def process_outlines(self): angle_vectors(segment.direction, self.z_axis, deg=True) < 1 or angle_vectors(segment.direction, self.z_axis, deg=True) > 179 ): - if self.parent.lintel_posts: + if self.parent.use_jack_studs: element.type = "jack_stud" else: element.type = "king_stud" @@ -648,7 +648,7 @@ def process_outlines(self): element.type = "sill" self.elements.append(element) self.elements = self.parent.offset_elements(self.elements) - if self.parent.lintel_posts: + if self.parent.use_jack_studs: for element in self.jack_studs: offset = ( self.parent.beam_dimensions["jack_stud"][0] + self.parent.beam_dimensions["king_stud"][0] 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 f0b3a12e7..595064dcd 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 @@ -20,18 +20,15 @@ def RunScript(self, surface, stud_spacing, beam_width, frame_depth, z_axis, opti if not isinstance(surface, RhinoBrep): raise TypeError("Expected a compas.geometry.Surface, got: {}".format(type(surface))) if not stud_spacing: - self.AddRuntimeMessage(Warning, "Input parameter 'spacing' failed to collect data") - return + self.AddRuntimeMessage(Warning, "Input parameter 'stud_spacing' failed to collect data, using default value of 625mm") if stud_spacing is not None and 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 + self.AddRuntimeMessage(Warning, "Input parameter 'beam_width' failed to collect data, using default value of 60mm") if beam_width is not None and not isinstance(beam_width, float): raise TypeError("stud_spacing expected a float, got: {}".format(type(stud_spacing))) if not frame_depth: - self.AddRuntimeMessage(Warning, "Input parameter 'frame_depth' failed to collect data") - return + self.AddRuntimeMessage(Warning, "Input parameter 'frame_depth' failed to collect data, using default value of 140mm") if frame_depth is not None and not isinstance(frame_depth, float): raise TypeError("stud_spacing expected a float, got: {}".format(type(stud_spacing))) if z_axis is not None and not isinstance(z_axis, RhinoVector): From 2de42bc56c4c88338dd4ac901a10dcdbb80440f5 Mon Sep 17 00:00:00 2001 From: obucklin Date: Thu, 12 Sep 2024 14:11:25 +0200 Subject: [PATCH 3/6] format, lint --- src/compas_timber/design/wall_from_surface.py | 4 +--- .../components/CT_Model_From_Surface/code.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/compas_timber/design/wall_from_surface.py b/src/compas_timber/design/wall_from_surface.py index 2e0489214..166438fd1 100644 --- a/src/compas_timber/design/wall_from_surface.py +++ b/src/compas_timber/design/wall_from_surface.py @@ -24,7 +24,7 @@ from compas_timber.connections import LButtJoint from compas_timber.connections import TButtJoint from compas_timber.design import CategoryRule -from compas_timber.elements import Beam, beam +from compas_timber.elements import Beam from compas_timber.model import TimberModel @@ -146,8 +146,6 @@ def __init__( self.joint_overrides = joint_overrides self.dist_tolerance = tolerance.relative - - for key in self.BEAM_CATEGORY_NAMES: self.beam_dimensions[key] = [self.beam_width, self.frame_depth] if custom_dimensions: 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 595064dcd..bed38c992 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 @@ -20,15 +21,21 @@ def RunScript(self, surface, stud_spacing, beam_width, frame_depth, z_axis, opti if not isinstance(surface, RhinoBrep): raise TypeError("Expected a compas.geometry.Surface, got: {}".format(type(surface))) if not stud_spacing: - self.AddRuntimeMessage(Warning, "Input parameter 'stud_spacing' failed to collect data, using default value of 625mm") + self.AddRuntimeMessage( + Warning, "Input parameter 'stud_spacing' failed to collect data, using default value of 625mm" + ) if stud_spacing is not None and 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, using default value of 60mm") + self.AddRuntimeMessage( + Warning, "Input parameter 'beam_width' failed to collect data, using default value of 60mm" + ) if beam_width is not None and not isinstance(beam_width, float): raise TypeError("stud_spacing expected a float, got: {}".format(type(stud_spacing))) if not frame_depth: - self.AddRuntimeMessage(Warning, "Input parameter 'frame_depth' failed to collect data, using default value of 140mm") + self.AddRuntimeMessage( + Warning, "Input parameter 'frame_depth' failed to collect data, using default value of 140mm" + ) if frame_depth is not None and not isinstance(frame_depth, float): raise TypeError("stud_spacing expected a float, got: {}".format(type(stud_spacing))) if z_axis is not None and not isinstance(z_axis, RhinoVector): From 399e25cb49401931051dcede0de02c22dcc1f90c Mon Sep 17 00:00:00 2001 From: obucklin Date: Thu, 12 Sep 2024 14:30:07 +0200 Subject: [PATCH 4/6] moved default values to component --- CHANGELOG.md | 2 +- src/compas_timber/design/wall_from_surface.py | 34 ++----------- .../components/CT_Model_From_Surface/code.py | 51 ++++++++++++++----- .../CT_Model_From_Surface/metadata.json | 8 +-- 4 files changed, 45 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15f919da3..b75275e1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ 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. ### Changed diff --git a/src/compas_timber/design/wall_from_surface.py b/src/compas_timber/design/wall_from_surface.py index 166438fd1..928d0ad77 100644 --- a/src/compas_timber/design/wall_from_surface.py +++ b/src/compas_timber/design/wall_from_surface.py @@ -96,37 +96,9 @@ def __init__( joint_overrides=None, ): self.surface = surface - - if stud_spacing is not None: - self.stud_spacing = stud_spacing - else: - if tolerance.unit == "M": - self.stud_spacing = 0.625 - elif tolerance.unit == "MM": - self.stud_spacing = 625.0 - elif tolerance.unit == "CM": - self.stud_spacing = 62.5 - - if beam_width is not None: - self.beam_width = beam_width - else: - if tolerance.unit == "M": - self.beam_width = 0.06 - elif tolerance.unit == "MM": - self.beam_width = 60.0 - elif tolerance.unit == "CM": - self.beam_width = 6.0 - - if frame_depth is not None: - self.frame_depth = frame_depth - else: - if tolerance.unit == "M": - self.frame_depth = 0.14 - elif tolerance.unit == "MM": - self.frame_depth = 140.0 - elif tolerance.unit == "CM": - self.frame_depth = 14.0 - + self.stud_spacing = stud_spacing + self.beam_width = beam_width + self.frame_depth = frame_depth self._z_axis = z_axis or Vector.Zaxis() self.sheeting_outside = sheeting_outside self.sheeting_inside = sheeting_inside 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 bed38c992..f3573fe75 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 @@ -20,24 +20,56 @@ 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 'stud_spacing' failed to collect data, using default value of 625mm" ) - if stud_spacing is not None and not isinstance(stud_spacing, float): + 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, using default value of 60mm" ) - if beam_width is not None and not isinstance(beam_width, float): - raise TypeError("stud_spacing expected a float, got: {}".format(type(stud_spacing))) + 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, using default value of 140mm" ) - if frame_depth is not None and not isinstance(frame_depth, float): - raise TypeError("stud_spacing expected a float, got: {}".format(type(stud_spacing))) + 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))) @@ -47,15 +79,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 ) diff --git a/src/compas_timber/ghpython/components/CT_Model_From_Surface/metadata.json b/src/compas_timber/ghpython/components/CT_Model_From_Surface/metadata.json index 2a6d62612..98da1bb9c 100644 --- a/src/compas_timber/ghpython/components/CT_Model_From_Surface/metadata.json +++ b/src/compas_timber/ghpython/components/CT_Model_From_Surface/metadata.json @@ -18,19 +18,19 @@ { "name": "stud_spacing", "description": "spacing between studs.", - "typeHintID": "float", + "typeHintID": "none", "scriptParamAccess": 0 }, { "name": "beam_width", "description": "Width of the cross-section.", - "typeHintID": "float", + "typeHintID": "none", "scriptParamAccess": 0 }, { "name": "frame_depth", "description": "thickness of the frame section of the resulting model. used to set Beam.height", - "typeHintID": "float", + "typeHintID": "none", "scriptParamAccess": 0 }, { @@ -67,4 +67,4 @@ } ] } -} \ No newline at end of file +} From 2f01c1d16a53cca78223885a9a8cc25b6c5cbbe3 Mon Sep 17 00:00:00 2001 From: obucklin Date: Thu, 12 Sep 2024 14:33:32 +0200 Subject: [PATCH 5/6] changelog updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b75275e1e..bf6f79bed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added * Added bake component for `Plate` elements. +* Added default dimensions to the `SurfaceModel` GH component. ### Changed From fee1e8e08a8a08e41373fc6011414728517697b6 Mon Sep 17 00:00:00 2001 From: obucklin Date: Thu, 12 Sep 2024 14:34:40 +0200 Subject: [PATCH 6/6] format, lint --- .../ghpython/components/CT_Model_From_Surface/code.py | 2 -- 1 file changed, 2 deletions(-) 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 f3573fe75..e4e9c5827 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 @@ -29,8 +29,6 @@ def RunScript(self, surface, stud_spacing, beam_width, frame_depth, z_axis, opti elif units == "mm": tol = Tolerance(unit="MM", absolute=1e-3, relative=1e-3) - - if not stud_spacing: self.AddRuntimeMessage( Warning, "Input parameter 'stud_spacing' failed to collect data, using default value of 625mm"