diff --git a/CHANGELOG.md b/CHANGELOG.md index c532b0de9..61a1361ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,8 @@ 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 dimensions to the `SurfaceModel` GH component. ### Changed diff --git a/src/compas_timber/design/wall_from_surface.py b/src/compas_timber/design/wall_from_surface.py index fb42877c1..93b594161 100644 --- a/src/compas_timber/design/wall_from_surface.py +++ b/src/compas_timber/design/wall_from_surface.py @@ -95,20 +95,20 @@ 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.stud_spacing = stud_spacing self.beam_width = beam_width self.frame_depth = frame_depth - self.stud_spacing = stud_spacing 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 = [] @@ -331,8 +331,8 @@ def generate_perimeter_beams(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: - beam_def.type = "jack_stud" + if self.use_jack_studs: + element.type = "jack_stud" else: beam_def.type = "king_stud" else: @@ -344,12 +344,12 @@ def generate_perimeter_beams(self): ): beam_def.type = "edge_stud" else: - beam_def.type = "plate" - self._beam_definitions.append(beam_def) - self._beam_definitions = self.offset_elements(self._beam_definitions) - if self.lintel_posts: - for beam_def in self._beam_definitions: - if beam_def.type == "jack_stud": + element.type = "plate" + self._elements.append(element) + self._elements = self.offset_elements(self._elements) + 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 king_line = offset_line(beam_def.centerline, offset, self.normal) self._beam_definitions.append(self.BeamDefinition(king_line, type="king_stud", parent=self)) @@ -639,8 +639,8 @@ 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: - beam_def.type = "jack_stud" + if self.parent.use_jack_studs: + element.type = "jack_stud" else: beam_def.type = "king_stud" else: @@ -658,11 +658,11 @@ def process_outlines(self): if dot_vectors(vector, self.z_axis) < 0: beam_def.type = "header" else: - beam_def.type = "sill" - self._beam_definitions.append(beam_def) - self._beam_definitions = self.parent.offset_elements(self._beam_definitions) - if self.parent.lintel_posts: - for beam_def in self.jack_studs: + element.type = "sill" + self.elements.append(element) + self.elements = self.parent.offset_elements(self.elements) + 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] ) / 2 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..4028f75a6 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 @@ -19,21 +20,54 @@ 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 ) 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 +} 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