Skip to content

Commit

Permalink
ADD: w_parameters.py, w_dataset_folded_plates.py
Browse files Browse the repository at this point in the history
  • Loading branch information
petrasvestartas committed Oct 9, 2024
1 parent 1ad9d20 commit 50aff4d
Show file tree
Hide file tree
Showing 121 changed files with 8,502 additions and 492 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/examples/binding_read_xml_polylines.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import compas_wood
import os

dataset_index = 3
dataset_index = -1
module_path = os.path.dirname(compas_wood.__file__)
foldername = os.path.join(module_path, "datasets")
foldername = os.path.join(module_path, "datasets") + os.sep
Expand Down
2 changes: 1 addition & 1 deletion src/compas_wood/datasets/type_plates_name_vda_floor_2.xml

Large diffs are not rendered by default.

91 changes: 58 additions & 33 deletions src/rhino/gh/cpy/beam_volume/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
from wood_nano import cut_type2
import System


class BeamVolume(component):
def beam_volumes(self,
def beam_volumes(
self,
input_polyline_axes,
input_polylines_segment_radii,
input_polylines_segment_direction,
Expand Down Expand Up @@ -82,19 +84,22 @@ def beam_volumes(self,
from_int1(joints_types),
)

def RunScript(self,
_circles: Grasshopper.DataTree[Rhino.Geometry.Circle],
_length_of_box: float,
_distance_tolerance: float,
_cross_or_toptoside: float,
_create_pipes: bool):
def RunScript(
self,
_circles: Grasshopper.DataTree[Rhino.Geometry.Circle],
_length_of_box: float,
_distance_tolerance: float,
_cross_or_toptoside: float,
_create_pipes: bool,
):

if _circles is None: return
if _circles is None:
return
length_of_box = _length_of_box if _length_of_box else 1
distance_tolerance = _distance_tolerance if _distance_tolerance else 10
cross_or_top_to_side= _cross_or_toptoside if _cross_or_toptoside else 0.91
cross_or_top_to_side = _cross_or_toptoside if _cross_or_toptoside else 0.91
create_pipes = _create_pipes if _create_pipes else False

# Initialize outputs
input_polylines = []
input_polylines_segment_radii = []
Expand All @@ -104,7 +109,7 @@ def RunScript(self,
# Processing each branch which represents a polyline
for i in range(_circles.BranchCount):
points = []
radii= []
radii = []
normals = []
parameters = []
for index, circle in enumerate(_circles.Branch(i)):
Expand All @@ -119,38 +124,58 @@ def RunScript(self,
input_polylines_segment_radii.append(radii)
# input_polylines_segment_direction.append(normals)

if(create_pipes):
if create_pipes:
curves = []
for j in range (_circles.Branch(i).Count):
for j in range(_circles.Branch(i).Count):
curves.append(_circles.Branch(i)[j].ToNurbsCurve())

brep = Rhino.Geometry.Brep.CreateFromLoft(curves, Rhino.Geometry.Point3d.Unset, Rhino.Geometry.Point3d.Unset, Rhino.Geometry.LoftType.Loose, False)[0]
brep = Rhino.Geometry.Brep.CreateFromLoft(
curves,
Rhino.Geometry.Point3d.Unset,
Rhino.Geometry.Point3d.Unset,
Rhino.Geometry.LoftType.Loose,
False,
)[0]
brep = brep.CapPlanarHoles(Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance)

faces = []
for j in range(brep.Faces.Count):
faces.append(brep.Faces[j].DuplicateFace(False))

brep = Rhino.Geometry.Brep.JoinBreps(
faces, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance*10
)[0]


brep = Rhino.Geometry.Brep.JoinBreps(faces, Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance * 10)[0]

if brep:
brep.Faces.SplitKinkyFaces(Rhino.RhinoMath.DefaultAngleTolerance, True)
if (Rhino.Geometry.BrepSolidOrientation.Inward is brep.SolidOrientation):
brep.Flip();

if Rhino.Geometry.BrepSolidOrientation.Inward is brep.SolidOrientation:
brep.Flip()
_pipes.append(brep)


_index_polylines, _index_polylines_segment, _distance, _point_pairs, _volume_pairs, _joints_areas, _joints_types = self.beam_volumes(
input_polylines,
input_polylines_segment_radii,
input_polylines_segment_direction,
input_allowed_types_per_polyline=[1],
input_min_distance=distance_tolerance,
input_volume_length=length_of_box,
input_cross_or_side_to_end=cross_or_top_to_side,
(
_index_polylines,
_index_polylines_segment,
_distance,
_point_pairs,
_volume_pairs,
_joints_areas,
_joints_types,
) = self.beam_volumes(
input_polylines,
input_polylines_segment_radii,
input_polylines_segment_direction,
input_allowed_types_per_polyline=[1],
input_min_distance=distance_tolerance,
input_volume_length=length_of_box,
input_cross_or_side_to_end=cross_or_top_to_side,
)

return th.list_to_tree(_index_polylines), th.list_to_tree( _index_polylines_segment), th.list_to_tree(_distance), th.list_to_tree(_point_pairs), th.list_to_tree( _volume_pairs), th.list_to_tree( _joints_areas), th.list_to_tree( _joints_types), th.list_to_tree( _pipes)
return (
th.list_to_tree(_index_polylines),
th.list_to_tree(_index_polylines_segment),
th.list_to_tree(_distance),
th.list_to_tree(_point_pairs),
th.list_to_tree(_volume_pairs),
th.list_to_tree(_joints_areas),
th.list_to_tree(_joints_types),
th.list_to_tree(_pipes),
)
1 change: 0 additions & 1 deletion src/rhino/gh/cpy/closest_indexed_points/code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from ghpythonlib.componentbase import executingcomponent as component
import Grasshopper
import Rhino
Expand Down
2 changes: 1 addition & 1 deletion src/rhino/gh/cpy/closest_lines/code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from ghpythonlib.componentbase import executingcomponent as component
import Grasshopper
import Rhino
Expand All @@ -9,6 +8,7 @@
import ghpythonlib.treehelpers as th
import System


class MyComponent(component):
def RunScript(
self, _polylines: Grasshopper.DataTree[Rhino.Geometry.Curve], _lines: Grasshopper.DataTree[Rhino.Geometry.Line]
Expand Down
1 change: 0 additions & 1 deletion src/rhino/gh/cpy/custom_joints/code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from ghpythonlib.componentbase import executingcomponent as component
import System
import Rhino
Expand Down
7 changes: 4 additions & 3 deletions src/rhino/gh/cpy/cut_group/code.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
"""match data tree of beam-nodes component with the output of the solver"""

from ghpythonlib.componentbase import executingcomponent as component
import Grasshopper, GhPython
import System
import Rhino


class MyComponent(component):
def RunScript(self,
_geometry: Grasshopper.DataTree[Rhino.Geometry.GeometryBase],
_group_id: Grasshopper.DataTree[int]):
def RunScript(
self, _geometry: Grasshopper.DataTree[Rhino.Geometry.GeometryBase], _group_id: Grasshopper.DataTree[int]
):

tree_temp = Grasshopper.DataTree[Rhino.Geometry.GeometryBase]()

Expand Down
1 change: 0 additions & 1 deletion src/rhino/gh/cpy/input_get/code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from ghpythonlib.componentbase import executingcomponent as component
import Grasshopper
import ghpythonlib.treehelpers as th
Expand Down
1 change: 0 additions & 1 deletion src/rhino/gh/cpy/input_set/code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from ghpythonlib.componentbase import executingcomponent as component
import Grasshopper
import Rhino
Expand Down
3 changes: 2 additions & 1 deletion src/rhino/gh/cpy/installation/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
# r: wood-nano==0.1.1, compas-wood==2.1.0, compas==2.1.1

from wood_nano import test as wood_nano_test
wood_nano_test()

wood_nano_test()
1 change: 0 additions & 1 deletion src/rhino/gh/cpy/joint_parameters/code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import System
import Rhino
from ghpythonlib.componentbase import executingcomponent as component
Expand Down
1 change: 0 additions & 1 deletion src/rhino/gh/cpy/line_volume/code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from ghpythonlib.componentbase import executingcomponent as component # noqa: E402
import Rhino
import System
Expand Down
1 change: 0 additions & 1 deletion src/rhino/gh/cpy/orient_data/code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from Rhino.Geometry import Polyline
from Rhino.Geometry import Transform
from Rhino.Geometry import Vector3d
Expand Down
18 changes: 9 additions & 9 deletions src/rhino/gh/cpy/solver/code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from ghpythonlib.componentbase import executingcomponent as component
import Rhino
import System
Expand Down Expand Up @@ -35,13 +34,15 @@ def DrawViewportWires(self, args):
def get_ClippingBox(self):
return self.bbox

def RunScript(self,
_data,
_joint_p: System.Collections.Generic.IList[float],
_scale: System.Collections.Generic.IList[float],
_extension: System.Collections.Generic.IList[float],
_find: int,
_get: int):
def RunScript(
self,
_data,
_joint_p: System.Collections.Generic.IList[float],
_scale: System.Collections.Generic.IList[float],
_extension: System.Collections.Generic.IList[float],
_find: int,
_get: int,
):

# ==============================================================================
# clear input
Expand Down Expand Up @@ -89,7 +90,6 @@ def RunScript(self,
input_adjacency = _data.adjacency
joint_parameters = wood_globals.joints_parameters_and_types


if _joint_p:
for i in range(0, len(_joint_p), 3):
insertion_id = floor(_joint_p[i + 2] / 10)
Expand Down
23 changes: 12 additions & 11 deletions src/rhino/gh/cpy/solver_custom/code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from ghpythonlib.componentbase import executingcomponent as component
import Rhino
import System
Expand Down Expand Up @@ -36,15 +35,17 @@ def DrawViewportWires(self, args):
def get_ClippingBox(self):
return self.bbox

def RunScript(self,
_data,
_joint_p: System.Collections.Generic.IList[float],
_scale: System.Collections.Generic.IList[float],
_extension: System.Collections.Generic.IList[float],
_find: int,
_get: int,
_custom_joints: System.Collections.Generic.IList[Rhino.Geometry.Polyline],
_custom_types: System.Collections.Generic.IList[int]):
def RunScript(
self,
_data,
_joint_p: System.Collections.Generic.IList[float],
_scale: System.Collections.Generic.IList[float],
_extension: System.Collections.Generic.IList[float],
_find: int,
_get: int,
_custom_joints: System.Collections.Generic.IList[Rhino.Geometry.Polyline],
_custom_types: System.Collections.Generic.IList[int],
):

# ==============================================================================
# clear input
Expand Down Expand Up @@ -168,7 +169,7 @@ def RunScript(self,
int(input_output_type),
w_output_plines,
w_output_types,
to_double1(input_joint_volume_parameters)
to_double1(input_joint_volume_parameters),
)

self.polylines = from_point3(w_output_plines)
Expand Down
7 changes: 3 additions & 4 deletions src/rhino/gh/cpy/xml_write/code.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"""Write a data tree of polylines to an xml file."""

import System
from ghpythonlib.componentbase import executingcomponent as component
import clr
import Grasshopper
import Rhino
import Grasshopper

clr.AddReference("System.Xml")
import System.Xml # noqa: E402
Expand Down Expand Up @@ -31,9 +32,7 @@ def xml_polyline(self, xmlWriter, pline, name):

xmlWriter.WriteEndElement()

def RunScript(self,
_plines: Grasshopper.DataTree[Rhino.Geometry.Polyline],
_path: str):
def RunScript(self, _plines: Grasshopper.DataTree[Rhino.Geometry.Polyline], _path: str):
if _path is None or _plines.AllData().Count == 0:
return False
##########################################################################
Expand Down
Binary file modified src/rhino/gh/examples/13_diamond_subdivision.gh
Binary file not shown.
Binary file added src/rhino/plugin/Workflow.pptx
Binary file not shown.
Loading

0 comments on commit 50aff4d

Please sign in to comment.