Skip to content

Commit d686f0f

Browse files
authored
Merge pull request #473 from gramaziokohler/GH_comp_fixes
GH component fixes
2 parents fce8808 + c133a3a commit d686f0f

10 files changed

Lines changed: 40 additions & 23 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5656
* Renamed `NullJoint` to `GenericJoint`.
5757
* Fixed bug in show_ref_faces GH component.
5858
* `BTLxProcessing.ref_side_index` defaults to `0` if not set, instead of the invalid `None`.
59+
* Fixed several GH Components for Rhino8 compatibility.
5960

6061
### Removed
6162

src/compas_timber/connections/plate_joint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def __data__(self):
118118
return data
119119

120120
def __init__(self, plate_a=None, plate_b=None, topology=None, a_segment_index=None, b_segment_index=None, **kwargs):
121-
super(PlateJoint, self).__init__(topology=topology,**kwargs)
121+
super(PlateJoint, self).__init__(topology=topology, **kwargs)
122122
self.plate_a = plate_a
123123
self.plate_b = plate_b
124124
self.a_segment_index = a_segment_index

src/compas_timber/elements/plate.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ def compute_geometry(self, include_features=True):
383383
"""
384384

385385
# TODO: consider if Brep.from_curves(curves) is faster/better
386-
plate_geo = self.shape()
386+
plate_geo = self.shape
387387
if include_features:
388388
for feature in self._features:
389389
try:
@@ -446,3 +446,20 @@ def compute_collision_mesh(self):
446446
447447
"""
448448
return self.obb.to_mesh()
449+
450+
def opp_side(self, ref_side_index):
451+
# type: (int) -> Frame
452+
"""Returns the the side that is directly across from the reference side, following the right-hand rule with the thumb along the beam's frame x-axis.
453+
This method does not consider the start and end sides of the beam (RS5 & RS6).
454+
455+
Parameters
456+
----------
457+
ref_side_index : int
458+
The index of the reference side to which the opposite side should be calculated.
459+
460+
Returns
461+
-------
462+
frame : :class:`~compas.geometry.Frame`
463+
The frame of the opposite side of the beam relative to the reference side.
464+
"""
465+
return self.ref_sides[(ref_side_index + 2) % 4]

src/compas_timber/ghpython/components/CT_CustomBeamDimensions/code.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Grasshopper
12
from ghpythonlib.componentbase import executingcomponent as component
23

34
from compas_timber.design import SurfaceModel
@@ -20,7 +21,7 @@ def RunScript(self, width, height):
2021

2122
if ghenv.Component.Params.Output[0].NickName != "Dimensions":
2223
dims[ghenv.Component.Params.Output[0].NickName] = (width or 0, height or 0)
23-
return (dims,) # return a tuple to allow passing dict between components
24+
return Grasshopper.Kernel.Types.GH_ObjectWrapper(dims) # return a tuple to allow passing dict between components
2425

2526
def AppendAdditionalMenuItems(self, menu):
2627
for name in beam_category_names:

src/compas_timber/ghpython/components/CT_SurfaceModelOptions/code.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Grasshopper
12
from ghpythonlib.componentbase import executingcomponent as component
23

34

@@ -24,4 +25,4 @@ def RunScript(self, sheeting_outside, sheeting_inside, lintel_posts, edge_stud_o
2425
"joint_overrides": joint_overrides,
2526
}
2627

27-
return (dict,)
28+
return Grasshopper.Kernel.Types.GH_ObjectWrapper(dict)

src/compas_timber/ghpython/components_cpython/CT_BTLx_From_Geometry/code.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"""Generates a feature from BTLx type and input geometry."""
2+
13
# r: compas_timber>=0.15.3
24
# flake8: noqa
35
import inspect
@@ -49,11 +51,10 @@ def RunScript(self, elements: System.Collections.Generic.List[object], *args):
4951
for arg, arg_name in zip(args, self.arg_names()[0 : self.geometry_count]):
5052
if arg is None:
5153
warning(self.component, f"Input parameter {arg_name} failed to collect data")
52-
5354
geometries = []
5455
for geo, arg_name in zip(args, self.arg_names()[0 : self.geometry_count]):
55-
geo = rs.coercegeometry(geo) # guid to geometry
56-
56+
if isinstance(geo, System.Guid):
57+
geo = rs.coercegeometry(geo) # guid to geometry
5758
if isinstance(geo, rg.LineCurve):
5859
geometries.append(Line(geo.PointAtStart, geo.PointAtEnd))
5960
elif isinstance(geo, rg.Plane):
@@ -76,7 +77,7 @@ def RunScript(self, elements: System.Collections.Generic.List[object], *args):
7677
return BTLxFromGeometryDefinition(self.processing_type, **kwargs)
7778

7879
def arg_names(self):
79-
names = inspect.getargspec(self.processing_type.from_shapes_and_element)[0][1:]
80+
names = inspect.getfullargspec(self.processing_type.from_shapes_and_element)[0][1:]
8081
count = 0
8182
for name in names:
8283
if name == "element":

src/compas_timber/ghpython/components_cpython/CT_CustomBeamDimensions/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def RunScript(self, width: float, height: float):
2323

2424
if ghenv.Component.Params.Output[0].NickName != "Dimensions":
2525
dims[ghenv.Component.Params.Output[0].NickName] = (width or 0, height or 0)
26-
return (dims,) # return a tuple to allow passing dict between components
26+
return Grasshopper.Kernel.Types.GH_ObjectWrapper(dims)
2727

2828
def AppendAdditionalMenuItems(self, menu):
2929
for name in beam_category_names:

src/compas_timber/ghpython/components_cpython/CT_Plate/code.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import rhinoscriptsyntax as rs
88
import System
99
from compas.scene import Scene
10-
from compas_rhino.conversions import curve_to_compas
10+
from compas_rhino.conversions import polyline_to_compas
1111

1212
from compas_timber.elements import Plate as CTPlate
1313
from compas_timber.ghpython.rhino_object_name_attributes import update_rhobj_attributes_name
@@ -58,7 +58,7 @@ def RunScript(
5858
for line, t, v, c in zip(outline, thickness, vector, category):
5959
guid, geometry = self._get_guid_and_geometry(line)
6060
rhino_polyline = rs.coercecurve(geometry)
61-
line = curve_to_compas(rhino_polyline)
61+
line = polyline_to_compas(rhino_polyline.ToPolyline())
6262

6363
plate = CTPlate.from_outline_thickness(line, t, v)
6464
plate.attributes["rhino_guid"] = str(guid) if guid else None

src/compas_timber/ghpython/components_cpython/CT_Plate_from_top_botto/code.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,30 @@
1616

1717
class PlateFromTopBottom(Grasshopper.Kernel.GH_ScriptInstance):
1818
def RunScript(
19-
self,
20-
top: System.Collections.Generic.List[object],
21-
bottom: System.Collections.Generic.List[float],
22-
category: System.Collections.Generic.List[str],
23-
updateRefObj: bool,
19+
self, Top: System.Collections.Generic.List[object], Bottom: System.Collections.Generic.List[object], category: System.Collections.Generic.List[str], updateRefObj: bool
2420
):
2521
# minimum inputs required
2622

27-
if not list_input_valid_cpython(ghenv, top, "Outline") or not list_input_valid_cpython(ghenv, bottom, "Thickness"):
23+
if not list_input_valid_cpython(ghenv, Top, "Outline") or not list_input_valid_cpython(ghenv, Bottom, "Thickness"):
2824
return
2925
else:
3026
if not category:
3127
category = [None]
3228
plates = []
3329
scene = Scene()
3430
# check list lengths for consistency
35-
if len(top) != len(bottom):
31+
if len(Top) != len(Bottom):
3632
ghenv.Component.AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, " `Top` and `Bottom` must have the same number of elements.")
37-
if len(category) not in (0, 1, len(top)):
33+
if len(category) not in (0, 1, len(Top)):
3834
ghenv.Component.AddRuntimeMessage(
3935
Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, " In 'Category' I need either none, one or the same number of inputs as the `Top` parameter."
4036
)
4137

4238
# duplicate data if None or single value
43-
if len(category) != N:
44-
category = [category[0] for _ in range(N)]
39+
if len(category) != len(Top):
40+
category = [category[0] for _ in range(len(Top))]
4541

46-
for top_line, bottom_line, c in zip(top, bottom, category):
42+
for top_line, bottom_line, c in zip(Top, Bottom, category):
4743
t_guid, t_geometry = self._get_guid_and_geometry(top_line)
4844
b_guid, b_geometry = self._get_guid_and_geometry(bottom_line)
4945
t_rhino_polyline = rs.coercecurve(t_geometry)

src/compas_timber/ghpython/components_cpython/CT_SurfaceModelOptions/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ def RunScript(
3636
"joint_overrides": joint_overrides,
3737
}
3838

39-
return (dict,)
39+
return Grasshopper.Kernel.Types.GH_ObjectWrapper(dict)

0 commit comments

Comments
 (0)