|
3 | 3 | # r: compas_rv>=0.6.0 |
4 | 4 |
|
5 | 5 | import rhinoscriptsyntax as rs # type: ignore |
| 6 | +from compas_skeleton.datastructures import Skeleton |
6 | 7 | from compas_triangle.delaunay import conforming_delaunay_triangulation |
7 | 8 | from compas_triangle.rhino import discretise_boundary |
8 | 9 | from compas_triangle.rhino import discretise_constraints |
@@ -37,7 +38,17 @@ def RunCommand(): |
37 | 38 | # Make a Force "Pattern" |
38 | 39 | # ============================================================================= |
39 | 40 |
|
40 | | - option = rs.GetString(message="Pattern From", strings=["RhinoLines", "RhinoMesh", "RhinoSurface", "MeshGrid", "Triangulation"]) |
| 41 | + option = rs.GetString( |
| 42 | + message="Pattern From", |
| 43 | + strings=[ |
| 44 | + "RhinoLines", |
| 45 | + "RhinoMesh", |
| 46 | + "RhinoSurface", |
| 47 | + "MeshGrid", |
| 48 | + "Triangulation", |
| 49 | + "Skeleton", |
| 50 | + ], |
| 51 | + ) |
41 | 52 |
|
42 | 53 | if option == "RhinoLines": |
43 | 54 | guids = compas_rhino.objects.select_lines("Select lines") |
@@ -154,7 +165,33 @@ def RunCommand(): |
154 | 165 | pattern.smooth_area(fixed=fixed) |
155 | 166 |
|
156 | 167 | elif option == "Skeleton": |
157 | | - raise NotImplementedError |
| 168 | + guids = compas_rhino.objects.select_lines("Select skeleton lines.") |
| 169 | + if not guids: |
| 170 | + return |
| 171 | + |
| 172 | + rs.UnselectAllObjects() |
| 173 | + |
| 174 | + width = rs.GetReal("Specifiy skeleton width.", 1.0) |
| 175 | + if not width: |
| 176 | + return |
| 177 | + |
| 178 | + angle = rs.GetReal("Specifiy skeleton leaf angle (degrees).", 30) |
| 179 | + if not angle: |
| 180 | + return |
| 181 | + |
| 182 | + density = rs.GetInteger("Specifiy skeleton density.", 2) |
| 183 | + if not density: |
| 184 | + return |
| 185 | + |
| 186 | + objects = [compas_rhino.objects.find_object(guid) for guid in guids] |
| 187 | + curves = [obj.Geometry for obj in objects] |
| 188 | + lines = [compas_rhino.conversions.curve_to_compas_line(curve) for curve in curves] |
| 189 | + |
| 190 | + skeleton = Skeleton(lines) |
| 191 | + skeleton.node_width = width |
| 192 | + skeleton.leaf_angle = angle |
| 193 | + skeleton.density = density |
| 194 | + pattern = skeleton.pattern.copy(cls=Pattern) |
158 | 195 |
|
159 | 196 | else: |
160 | 197 | return |
|
0 commit comments