-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
COCKATOO_RenderKnitContours.py
49 lines (40 loc) · 1.49 KB
/
COCKATOO_RenderKnitContours.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
"""Visualises KnitContours
TODO: Update docstring, implement curve behaviour
Inputs:
Toggle: {item, boolean}
KnitContours:{item, curve/polyline}
Remarks:
Author: Max Eschenbach
License: Apache License 2.0
Version: 200418
"""
# PYTHON STANDARD LIBRARY IMPORTS
from __future__ import division
# GHPYTHON SDK IMPORTS
from ghpythonlib.componentbase import executingcomponent as component
import Grasshopper, GhPython
import System
import Rhino
import rhinoscriptsyntax as rs
# LOCAL MODULE IMPORTS
from mbe.helpers import mapValuesAsColors
from mbe.component import customDisplay
# GHENV COMPONENT SETTINGS
ghenv.Component.Name = "RenderKnitContours"
ghenv.Component.NickName ="RKC"
ghenv.Component.Category = "COCKATOO"
ghenv.Component.SubCategory = "7 Visualisation"
class RenderKnitContours(component):
def RunScript(self, Toggle, KnitContours):
# VISUALISATION OF CONTOURS USING CUSTOM DISPLAY -----------------------
if Toggle and KnitContours:
# make customdisplay
viz = customDisplay(self, True)
for i, pl in enumerate(KnitContours):
segs = [Rhino.Geometry.LineCurve(s) for s in pl.GetSegments()]
numseg = len(segs)
ccols = mapValuesAsColors(range(numseg), 0, numseg, 0.0, 0.35)
for j, seg in enumerate(segs):
viz.AddCurve(seg, ccols[j], 3)
else:
viz = customDisplay(self, False)