-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #378 from gramaziokohler/Show_beam_ref_sides
Show beam ref sides
- Loading branch information
Showing
6 changed files
with
86 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
src/compas_timber/ghpython/components/CT_ShowBeamFaces/code.py
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
src/compas_timber/ghpython/components/CT_ShowBeamFaces/metadata.json
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
src/compas_timber/ghpython/components/CT_Show_Ref_Sides/code.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
File renamed without changes
32 changes: 32 additions & 0 deletions
32
src/compas_timber/ghpython/components/CT_Show_Ref_Sides/metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." | ||
} | ||
] | ||
} | ||
} |