Skip to content

Commit

Permalink
Merge pull request #378 from gramaziokohler/Show_beam_ref_sides
Browse files Browse the repository at this point in the history
Show beam ref sides
  • Loading branch information
obucklin authored Feb 10, 2025
2 parents e3844dd + 959b1a7 commit 781d582
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 50 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,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
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."
}
]
}
}

0 comments on commit 781d582

Please sign in to comment.