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

Show beam ref sides #378

Merged
merged 9 commits into from
Feb 10, 2025
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Changed referenced to `beam` in `Drilling` to `element`.
* Changed `Drill Hole` and `Trim Feature` GH components to generate the relevant `BTLxProcessing` type rather than the deprecated `FeatureDefinition` type.

* Changed `Show_beam_faces` gh component to `Show_ref_sides`, which now takes an `int` index and shows the corresponding face
including origin corner.

### Removed

Expand Down
2 changes: 1 addition & 1 deletion src/compas_timber/fabrication/french_ridge_lap.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __data__(self):
data["drillhole_diam"] = self.drillhole_diam
return data

def __init__(self, orientation = OrientationType.START, start_x=0.0, angle=90.0, ref_position=EdgePositionType.REFEDGE, drillhole=False, drillhole_diam=0.0, **kwargs):
def __init__(self, orientation=OrientationType.START, start_x=0.0, angle=90.0, ref_position=EdgePositionType.REFEDGE, drillhole=False, drillhole_diam=0.0, **kwargs):
super(FrenchRidgeLap, self).__init__(**kwargs)
self._orientation = None
self._start_x = None
Expand Down
29 changes: 0 additions & 29 deletions src/compas_timber/ghpython/components/CT_ShowBeamFaces/code.py

This file was deleted.

This file was deleted.

52 changes: 52 additions & 0 deletions src/compas_timber/ghpython/components/CT_Show_Ref_Sides/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# flake8: noqa
import System
import rhinoscriptsyntax as rs
from ghpythonlib.componentbase import executingcomponent as component

from compas.geometry import Line
from compas.scene import Scene
from compas_rhino.conversions import frame_to_rhino


class ShowBeamFaces(component):
def RunScript(self, Beam, RefSideIndex):
if not Beam:
return None
self.pl = []
self.txt = []
self.ht = []
srfs = []
if not RefSideIndex:
RefSideIndex = [0]
if not len(RefSideIndex) == len(Beam):
RefSideIndex = [RefSideIndex[0] for _ in Beam]

for b, i in zip(Beam, RefSideIndex):
srfs.append(self.get_srf(b, i))
ht = 1000
for side_index in range(len(b.ref_sides)):
surface = b.side_as_surface(side_index)
ht = min([self.ht, surface.xsize / 6.0, surface.ysize / 6.0])
for side_index in range(len(b.ref_sides)):
surface = b.side_as_surface(side_index)
frame = b.ref_sides[side_index]
frame.point = surface.point_at(0, ht / 4.0)

self.pl.append(frame_to_rhino(frame))
self.txt.append("RS_{}".format(side_index))
self.ht.append(ht)

return srfs

def get_srf(self, element, ref_side_index):
face = element.side_as_surface(ref_side_index)
rh_srf = rs.AddPlaneSurface(frame_to_rhino(face.frame), face.xsize, face.ysize)
return rh_srf

def DrawViewportWires(self, arg):
if self.Locked:
return
col = System.Drawing.Color.FromArgb(255, 255, 255, 255)
# https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Display_DisplayPipeline_Draw3dText_5.htm
for p, t, h in zip(self.pl, self.txt, self.ht):
arg.Display.Draw3dText(t, col, p, h, "Verdana", True, False)
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "Show Beam Reference Side",
"nickname": "ShowBeamSides",
"category": "COMPAS Timber",
"subcategory": "Show",
"description": "Shows the element side based on ref_side_index. Text labels are located at the reference side origins and oriented to the reference side frame.",
"exposure": 4,
"ghpython": {
"isAdvancedMode": true,
"iconDisplay": 0,
"inputParameters": [
{
"name": "Element",
"description": "Element",
"typeHintID": "none",
"scriptParamAccess": 1
},
{
"name": "Reference Side Index",
"description": "integer 0-5 corresponding to reference side.",
"typeHintID": "int",
"scriptParamAccess": 1
}
],
"outputParameters": [
{
"name": "Reference Side",
"description": "Reference Side as surface."
}
]
}
}