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

SurfaceModelDefaultParams #285

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
36 changes: 18 additions & 18 deletions src/compas_timber/design/wall_from_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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:
Expand All @@ -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))
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
65 changes: 45 additions & 20 deletions src/compas_timber/ghpython/components/CT_Model_From_Surface/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,62 @@
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
if not surface:
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)))

Expand All @@ -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
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
{
"name": "stud_spacing",
"description": "spacing between studs.",
"typeHintID": "float",
"typeHintID": "none",
Copy link
Contributor

Choose a reason for hiding this comment

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

Successfully tested and seems to work well.
Except: Why did you change the type hint? This causes an error message if I connect a Panel:
image
As long as it is set to "float", it recognizes an input from a Panel as a Number.

"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
},
{
Expand Down Expand Up @@ -67,4 +67,4 @@
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading