Skip to content

Commit f11e1de

Browse files
WIP RhinoUI split between plates and beams
1 parent b64b878 commit f11e1de

File tree

92 files changed

+10404
-1518
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+10404
-1518
lines changed

docs/examples/binding_get_connection_zones_beams.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
from compas_wood.binding import get_connection_zones
2-
from compas.geometry import Polyline
2+
from compas.geometry import Polyline, Point, Rotation, Frame
33
from compas_wood import data_sets_plates
4-
4+
import math
55

66
# joinery parameters
77
division_length = 300
88
joint_parameters = [
99
100,
1010
0.5,
11-
5,
11+
4,
1212
division_length * 1.5,
1313
0.65,
1414
10,
@@ -57,6 +57,16 @@
5757
])
5858
]
5959

60+
61+
# Rotate polyline 180 degrees to check if it has any influence on the results
62+
point = Point(37, 79, 0)
63+
axis = [1, 0, 0]
64+
angle = math.pi
65+
T = Rotation.from_axis_and_angle(axis, angle, point)
66+
polylines[2].transform(T)
67+
polylines[3].transform(T)
68+
69+
6070
# generate joints
6171
polylines_lists, output_types, new_polyline_lists = get_connection_zones(
6272
polylines,
@@ -67,7 +77,7 @@
6777
joint_parameters,
6878
0,
6979
[1, 1, 1],
70-
3,
80+
2,
7181
)
7282

7383

@@ -82,7 +92,13 @@
8292
for polylines in polylines_lists:
8393
for polyline in polylines:
8494
polyline.transform(scale_transform)
85-
viewer.scene.add(Polyline(polyline), show_points=False)
95+
viewer.scene.add(polyline, show_points=False)
96+
viewer.scene.add(polyline[0])
97+
98+
viewer.scene.add(point.transformed(scale_transform))
99+
100+
101+
viewer.scene.add(polylines)
86102

87103
viewer.show()
88104

src/rhino/plugin/commands/w_dataset.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
# flags: python.reloadEngine
12
#! python3
23
# venv: timber_connections
34
import Rhino
45
import System
56
import System.IO
67
from compas_wood.binding import read_xml_polylines
78
import os
8-
from wood_rui import add_polylines, wood_rui_globals, BooleanForm, generalized_input_method
9+
from wood_rui import add_polylines_dataset, wood_rui_globals, BooleanForm, process_input
910
from wood_nano import read_xml_polylines as wood_nano_read_xml_polylines
1011
from wood_nano import double2
1112
from typing import *
@@ -83,28 +84,29 @@ def load_data_set(): # path: str = "C://brg//2_code//compas_wood//src//rhino//p
8384
wood_rui_globals.init_data(value[0])
8485
polylines = read_xml_polylines(foldername, value[0])
8586
wood_rui_globals[value[0]]["polylines"] = polylines
86-
add_polylines(polylines, value[0])
87+
add_polylines_dataset(polylines, value[0])
8788
Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.Redraw() # 0 ms
8889

8990
return file_names_without_extensions
9091

9192

92-
def my_callback(name_value_type, dataset_name):
93+
def callback(selection: dict[str, any], dataset_name: str):
9394

94-
if len(input_dict["polylines"][0]) > 0:
95+
if len(selection["polylines"]) > 0:
9596
dataset_name = "default"
9697
wood_rui_globals.init_data(dataset_name)
97-
add_polylines(input_dict["polylines"][0], dataset_name)
98+
add_polylines_dataset(selection["polylines"], dataset_name)
9899

99100

100101
if __name__ == "__main__":
101102

103+
dataset_name = "default"
104+
102105
# Define the input dictionary based on your initial dataset
103-
input_dict = {
104-
"library": (load_data_set, Callable), # Default value for weld radius (float)
105-
"polylines": ([], List[Rhino.Geometry.Polyline]), # Default value for polylines (list of polylines)
106+
selection_types = {
107+
"selection_types": (load_data_set, Callable), # Default value for weld radius (float)
108+
"polylines": ([], list[Rhino.Geometry.Polyline]), # Default value for polylines (list of polylines)
106109
}
107110

108111
# Call the generalized input method with the dataset name and input dictionary
109-
dataset_name = "default"
110-
generalized_input_method(dataset_name, input_dict, my_callback)
112+
process_input(selection_types, callback, dataset_name = dataset_name)

src/rhino/plugin/commands/w_dataset_annen.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
# flags: python.reloadEngine
12
#! python3
23
# venv: timber_connections
34
import Rhino
45
from wood_rui import (
56
wood_rui_globals,
67
ensure_layer_exists,
7-
add_polylines,
8+
add_polylines_dataset,
89
add_mesh,
910
add_adjacency,
1011
add_insertion_vectors,
@@ -750,7 +751,7 @@ def run(self, dataset_name):
750751
self.get_plates()
751752
self.get_joinery_solver_output()
752753

753-
add_polylines(self.plines, dataset_name)
754+
add_polylines_dataset(self.plines, dataset_name)
754755
add_insertion_vectors(self.insertion_vectors, dataset_name)
755756
add_joint_type(self.joints_per_face, dataset_name)
756757
add_three_valence(self.three_valence, dataset_name)

src/rhino/plugin/commands/w_dataset_beam_volume.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# flags: python.reloadEngine
12
#! python3
23
# venv: timber_connections
34
from wood_nano import beam_volumes as wood_nano_beam_volumes

src/rhino/plugin/commands/w_dataset_closest_lines_insertion.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# flags: python.reloadEngine
12
#! python3
23
# venv: timber_connections
34
import Rhino
@@ -7,7 +8,7 @@
78
from wood_rui import wood_rui_globals, get_objects_by_layer
89

910

10-
def closest_lines(dataset_name: str, lines: List[Rhino.Geometry.Line]) -> None:
11+
def closest_lines(dataset_name: str, lines: List[Rhino.Geometry.Line], tolerance) -> None:
1112
"""
1213
Match the closest lines from the selected dataset to the input lines and update
1314
the insertion vectors.
@@ -43,7 +44,7 @@ def closest_lines(dataset_name: str, lines: List[Rhino.Geometry.Line]) -> None:
4344
for j in range(len(polylines[i])):
4445
for k in range(polylines[i][j].SegmentCount):
4546
bbox = polylines[i][j].SegmentAt(k).BoundingBox
46-
bbox.Inflate(0.02)
47+
bbox.Inflate(tolerance)
4748
segments_dictionary[count] = [i, j, k, bbox, polylines[i][j].SegmentAt(k)]
4849
count += 1
4950

@@ -61,14 +62,14 @@ def search_callback(sender: Any, rtree_event_args: Rhino.Geometry.RTreeEventArgs
6162
data_by_reference: List[int] = []
6263
if rtree.Search(Rhino.Geometry.Sphere(lines[i].From, 0), search_callback, data_by_reference):
6364
for j in data_by_reference:
64-
if lines[i].From.DistanceToSquared(segments_dictionary[j][4].ClosestPoint(lines[i].From, True)) < 0.001:
65+
if lines[i].From.DistanceToSquared(segments_dictionary[j][4].ClosestPoint(lines[i].From, True)) < tolerance:
6566
vectors[segments_dictionary[j][0]][segments_dictionary[j][2] + 2] = lines[i].Direction
6667

6768
for i in range(len(lines)):
6869
data_by_reference: List[int] = []
6970
if rtree.Search(Rhino.Geometry.Sphere(lines[i].To, 0), search_callback, data_by_reference):
7071
for j in data_by_reference:
71-
if lines[i].To.DistanceToSquared(segments_dictionary[j][4].ClosestPoint(lines[i].To, True)) < 0.001:
72+
if lines[i].To.DistanceToSquared(segments_dictionary[j][4].ClosestPoint(lines[i].To, True)) < tolerance:
7273
vectors[segments_dictionary[j][0]][segments_dictionary[j][2] + 2] = -lines[i].Direction
7374

7475
# Store the insertion vectors in the global data structure
@@ -161,4 +162,4 @@ def command_line_input() -> Tuple[str, List[Rhino.Geometry.Line]]:
161162
if __name__ == "__main__":
162163
selected_case_name, selected_lines = command_line_input()
163164
if selected_case_name and selected_lines:
164-
closest_lines(selected_case_name, selected_lines)
165+
closest_lines(selected_case_name, selected_lines, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance*20)

src/rhino/plugin/commands/w_dataset_closest_points_joints.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# flags: python.reloadEngine
12
#! python3
23
# venv: timber_connections
34
import Rhino
@@ -9,7 +10,7 @@
910
import ast
1011

1112

12-
def closest_points(dataset_name: str, points: List[Rhino.Geometry.Point3d], points_ids: List[int]) -> None:
13+
def closest_points(dataset_name: str, points: List[Rhino.Geometry.Point3d], points_ids: List[int], tolerance) -> None:
1314
"""component iterates polyline edges and assigns index based on the point list and their type RTree search
1415
1516
Match the closest lines from the selected dataset to the input lines and update
@@ -50,7 +51,7 @@ def closest_points(dataset_name: str, points: List[Rhino.Geometry.Point3d], poin
5051
for j in range(len(polylines[i])):
5152
for k in range(polylines[i][j].SegmentCount):
5253
bbox = polylines[i][j].SegmentAt(k).BoundingBox
53-
bbox.Inflate(0.02)
54+
bbox.Inflate(tolerance)
5455
segments_dictionary[count] = [i, j, k, bbox, polylines[i][j].SegmentAt(k)]
5556
count = count + 1
5657

@@ -70,9 +71,10 @@ def search_callback(sender, rtree_event_args):
7071
data_by_reference = []
7172
if rtree.Search(Rhino.Geometry.Sphere(points[i], 0), search_callback, data_by_reference):
7273
for j in data_by_reference:
73-
if points[i].DistanceToSquared(segments_dictionary[j][4].ClosestPoint(points[i], True)) < 0.001:
74+
if points[i].DistanceToSquared(segments_dictionary[j][4].ClosestPoint(points[i], True)) < tolerance:
7475
joint_types[segments_dictionary[j][0]][segments_dictionary[j][2] + 2] = points_ids[i]
7576

77+
print(joint_types)
7678
###############################################################################
7779
# Output
7880
###############################################################################
@@ -169,4 +171,4 @@ def command_line_input() -> Tuple[str, List[Rhino.Geometry.Point3d], List[int]]:
169171

170172
selected_case_name, selected_points, selected_values = command_line_input()
171173
if selected_case_name and selected_points and selected_values:
172-
closest_points(selected_case_name, selected_points, selected_values)
174+
closest_points(selected_case_name, selected_points, selected_values, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance*20)

0 commit comments

Comments
 (0)