Skip to content

Commit

Permalink
Merge branch 'main' into surface_model_plus_plate
Browse files Browse the repository at this point in the history
  • Loading branch information
obucklin committed Sep 12, 2024
2 parents fa7d371 + a7a80ba commit 97b6306
Show file tree
Hide file tree
Showing 19 changed files with 170 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.10.0
current_version = 0.10.1
message = Bump version to {new_version}
commit = True
tag = True
Expand Down
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

* Added bake component for `Plate` eleents.

### Changed

* Fixed wrong image file paths in the Documentation.

### Removed


## [0.10.1] 2024-09-11

### Added

### Changed

* Implemented a workaround for https://github.com/gramaziokohler/compas_timber/issues/280.

### Removed


Expand Down Expand Up @@ -38,6 +53,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Calling `process_joinery` in `SurfaceModel`.
* Changed how `BeamDefinition` and `Plate` types are handled in `SurfaceModel`
* Changed the `get_interior_segment_indices` function to work when there are multiple openings.
* Renamed `ShowSurfaceModelBeamType` to `ShowBeamsByCategory`.
* Changed `SurfaceModel` component input handling to give warnings instead of errors.

### Removed

Expand Down
14 changes: 7 additions & 7 deletions docs/tutorials/grasshopper/joint_rules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ L-Butt
^^^^^^
The L-Butt extends one beam and shortens the other beam with a planar cut, to create a clean corner joint.

.. image:: ../images/gh_joint_L-Butt.png
.. image:: ../images/gh_joint_LButt.png
:width: 50%

Inputs:
Expand All @@ -109,7 +109,7 @@ L-HalfLap

The *L-Half Lap* topology is when two beams meet at their ends at an angle. An L-Half Lap joint extends the two beams while removing the upper half of the overlap of one beam and the lower half of the overlaps the other to create a clean corner joint.

.. image:: ../images/gh_joint_L-HalfLap.png
.. image:: ../images/gh_joint_LHalfLap.png
:width: 50%

Inputs:
Expand All @@ -124,7 +124,7 @@ L-Miter

The L-Miter joint extends and connects the two beams with a planar cut at a bisector of the angle between them.

.. image:: ../images/gh_joint_L-Miter.png
.. image:: ../images/gh_joint_LMiter.png
:width: 50%

Inputs:
Expand All @@ -145,7 +145,7 @@ The tilted cut plane is generated by sequentially connecting the following point
* a point at the top third of the outer vertical edge of the overlap along the upper beam.


.. image:: ../images/gh_joint_L-FrenchRidge.png
.. image:: ../images/gh_joint_LFrenchRidge.png
:width: 50%

|
Expand All @@ -156,7 +156,7 @@ T-Butt

The T-Butt joint shortens the *cross beam* with a planar cut, to match the side of the *main beam*. The *main beam* remains unchanged.

.. image:: ../images/gh_joint_T-Butt.png
.. image:: ../images/gh_joint_TButt.png
:width: 50%

Inputs:
Expand All @@ -172,7 +172,7 @@ T-HalfLap
A T-Half Lap joint crates an overlap between the *main beam* and the *cross beam*. The *cross beam* is extended to the opposite face of the *main beam* and cut flush with it to create a planar surface.
It is similar to a L-Half Lap joint: the upper half of the overlap of the cross beam is removed from the main beam and the lower half of the overlap of the main beam is removed from the cross beam.

.. image:: ../images/gh_joint_T-HalfLap.png
.. image:: ../images/gh_joint_THalfLap.png
:width: 50%

Inputs:
Expand All @@ -187,7 +187,7 @@ X-HalfLap

The X-Half Lap joint removes the upper half of the overlap from one beam and the lower half from the other.

.. image:: ../images/gh_joint_X-HalfLap.png
.. image:: ../images/gh_joint_XHalfLap.png
:width: 50%

Inputs:
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion src/compas_timber/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
__title__ = "compas_timber"
__description__ = "COMPAS package for modeling, designing and fabricating timber assemblies."
__url__ = "https://github.com/gramaziokohler/compas_timber"
__version__ = "0.10.0"
__version__ = "0.10.1"
__author__ = "Gramazio Kohler Research"
__author_email__ = "gramaziokohler@arch.ethz.ch"
__license__ = "MIT license"
Expand Down
85 changes: 85 additions & 0 deletions src/compas_timber/ghpython/components/CT_Bake_PlateBoxMap/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# flake8: noqa
import math
import random

import rhinoscriptsyntax as rs
from compas_rhino.conversions import frame_to_rhino
from ghpythonlib.componentbase import executingcomponent as component
from Grasshopper.Kernel.GH_RuntimeMessageLevel import Error
from Grasshopper.Kernel.GH_RuntimeMessageLevel import Warning
from Rhino import Render
from Rhino.Geometry import Interval
from Rhino.Geometry import Plane
from Rhino.RhinoDoc import ActiveDoc


class BakePlateMap(component):
def RunScript(self, model, map_size, swap_uv, bake):
if map_size and len(map_size) != 3:
self.AddRuntimeMessage(
Error, "Input parameter MapSize requires exactly three float values (scale factors in x,y,z directions)"
)
return

if map_size:
dimx, dimy, dimz = map_size
else:
# for the pine 251 material bitmap, rotated
dimx = 1.0
dimy = 1.0
dimz = 1.0

if not model:
self.AddRuntimeMessage(Warning, "Input parameters Model failed to collect any Beam objects.")
return

if not bake:
return

try:
frames = [frame_to_rhino(b.frame) for b in model.plates]
breps = [beam.geometry.native_brep for beam in model.plates]

if frames and breps:
rs.EnableRedraw(False)

for brep, frame in zip(breps, frames):
guid = ActiveDoc.Objects.Add(brep)
boxmap = self.create_box_map(frame, dimx, dimy, dimz, swap_uv)
ActiveDoc.Objects.ModifyTextureMapping(guid, 1, boxmap)
finally:
rs.EnableRedraw(True)

@staticmethod
def create_box_map(pln, sx, sy, sz, swap_uv):
"""
pln: frame of beam box, where x=main axis, y=width, z=height
sx,sy,sz: box map size in x,y,z direction
"""

v = pln.YAxis
w = pln.ZAxis
pt = pln.Origin

# random deviation
a = math.pi * 0.5
randangle = (random.random() - 0.5) * a
v.Rotate(randangle, pln.XAxis)

b = math.pi * 0.01
randangle = (random.random() - 0.5) * b
w.Rotate(randangle, pln.XAxis)

randpos = sx * random.random()
pt += pln.XAxis * randpos

# create box mapping
mappingPln = Plane(pt, w, v)
dx = Interval(-sx * 0.5, sx * 0.5)
dy = Interval(-sy * 0.5, sy * 0.5)
dz = Interval(-sz * 0.5, sz * 0.5)
if swap_uv:
mappingPln.Rotate(math.radians(90), mappingPln.XAxis)
BoxMap = Render.TextureMapping.CreateBoxMapping(mappingPln, dx, dy, dz, False)

return BoxMap
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "BakePlatesWithBoxMap",
"nickname": "BakeWPlatesithBoxMap",
"category": "COMPAS Timber",
"subcategory": "Utils",
"description": "Bakes Plate objects with a BoxMapping (by default the material is applied 'by layer' and has to be defined in the layer the objects are baked to).",
"exposure": 4,
"ghpython": {
"isAdvancedMode": true,
"iconDisplay": 0,
"inputParameters": [
{
"name": "Model",
"description": "Model object (optional).",
"typeHintID": "none",
"scriptParamAccess": 0
},
{
"name": "MapSize",
"description": "Scaling of the BoxMap in x,y,z directions (list of three positive values) (optional).",
"typeHintID": "float",
"scriptParamAccess": 1
},
{
"name": "SwapUV",
"description": "Rotates the BoxMap 90 degrees (optional).",
"typeHintID": "bool",
"scriptParamAccess": 0
},
{
"name": "Bake",
"description": "Set to True to Bake. Nothing happens if None or False.",
"typeHintID": "bool",
"scriptParamAccess": 0
}
],
"outputParameters": []
}
}
4 changes: 4 additions & 0 deletions src/compas_timber/ghpython/components/CT_Model/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
}


# workaround for https://github.com/gramaziokohler/compas_timber/issues/280
TOL.absolute = 1e-6


class ModelComponent(component):
def get_joints_from_rules(self, beams, rules, topologies):
if not isinstance(rules, list):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
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
Expand All @@ -22,7 +21,18 @@ def RunScript(self, surface, stud_spacing, beam_width, frame_depth, z_axis, opti
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")
if not isinstance(stud_spacing, float):
return
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
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
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):
raise TypeError("Expected a compas.geometry.Vector, got: {}".format(type(z_axis)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
from compas_timber.ghpython.ghcomponent_helpers import rename_gh_output


class SurfaceModelJointRule(component):
class ShowBeamsByCategory(component):
def __init__(self):
super(SurfaceModelJointRule, self).__init__()
super(ShowBeamsByCategory, self).__init__()
self.beam_type = None
if ghenv.Component.Params.Output[0].NickName == "type":
self.joint_type = None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "ShowSurfaceModelBeamTypes",
"name": "ShowBeamsByCategory",
"nickname": "ShowBeamType",
"category": "COMPAS Timber",
"subcategory": "Show",
"description": "allows user to visualize beam types in surface model.",
"description": "allows user to visualize beam categories in timber model.",
"exposure": 2,
"ghpython": {
"isAdvancedMode": true,
Expand Down

0 comments on commit 97b6306

Please sign in to comment.