-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
COCKATOO_CreateWeftConnections.py
56 lines (45 loc) · 2.02 KB
/
COCKATOO_CreateWeftConnections.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""Creates 'weft' edges in a given initialized KnitNetwork.
Inputs:
Toggle: Set to True to activate the component {item, boolean}
KnitNetwork: An initialized KnitNetwork. {item, KnitNetwork}
SplittingIndex: Optional splitting index for splitting the contours into two sets (left and right). If no value or -1 is supplied, the longest contour will be used. {item, integer}
Precise: If True, the more precise DistanceTo() function will be used instead of DistanceToSquared(). Default is False. {item, boolean}
Output:
KnitNetwork: The KnitNetwork with 'weft' connections created. {item, polyline}
Remarks:
Author: Max Eschenbach
License: Apache License 2.0
Version: 200325
"""
# PYTHON LIBRARY IMPORTS
from __future__ import division
# GPYTHON SDK IMPORTS
from ghpythonlib.componentbase import executingcomponent as component
import Grasshopper, GhPython
import System
import Rhino
import rhinoscriptsyntax as rs
# CUSTOM MODULE IMPORTS
import Cockatoo
ghenv.Component.Name = "CreateWeftConnections"
ghenv.Component.NickName ="CWC"
ghenv.Component.Category = "COCKATOO"
ghenv.Component.SubCategory = "6 KnitNetwork"
class CreateWeftConnections(component):
def RunScript(self, Toggle, KN, SplittingIndex, Precise=False):
if Toggle and KN:
# copy the input network to not mess with previous components
KN = Cockatoo.KnitNetwork(KN)
if SplittingIndex < 0:
SplittingIndex = None
# create weft connections on the copy of the network
KN.CreateWeftConnections(start_index=SplittingIndex,
include_leaves=True,
least_connected=False,
precise=Precise,
verbose=False)
elif not Toggle and KN:
return KN
else:
return Grasshopper.DataTree[object]()
return KN