This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Rhino as rc | |
def meshEndFaces(mesh): | |
""" Get indices of faces with only one neighbour """ | |
endFaces = [] | |
for i in range(mesh.Faces.Count): | |
af = mesh.Faces.AdjacentFaces(i) | |
if len(af) == 1: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Rhino as rc | |
def meshEdgeLines(mesh): | |
lines = [] | |
for i in range(mesh.Vertices.Count): | |
neighbours = mesh.Vertices.GetConnectedVertices(i) | |
for n in neighbours: | |
if n > i: | |
line = rc.Geometry.Line(mesh.Vertices.Item[i],mesh.Vertices.Item[n]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hex = ["#%02x%02x%02x" % (c.R,c.G,c.B) for c in RGB] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sortCurvesByEuclideanCoords(crvs,t): | |
""" Sort a list of curves by Euclidean coordinates """ | |
ptsOnCrvs = [crv.PointAt(t) for crv in crvs] | |
sortedBoth = sorted(zip(ptsOnCrvs,crvs)) | |
sortedCrvs = [l[1] for l in sortedBoth] | |
return sortedCrvs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scriptcontext import sticky as st | |
import Rhino as rc | |
def customDisplay(toggle,component): | |
""" Make a custom display which is unique to the component and lives in sticky """ | |
# Make unique name and custom display | |
displayGuid = "customDisplay_" + str(component.InstanceGuid) | |
if displayGuid not in st: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Rhino as rc | |
def mapValuesAsColors(values,srcMin,srcMax,targetMin,targetMax): | |
""" Make a list of HSL colors where the values are mapped onto a | |
targetMin-targetMax hue domain. Meaning that low values will be red, medium | |
values green and large values blue if targetMin: 0.0 and targetMax: 0.7 """ | |
# Remap numbers into new numeric domain | |
remappedValues = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Grasshopper as gh | |
def listToTree(nestedList): | |
""" Convert a nested python iterable to a datatree """ | |
dt = gh.DataTree[object]() | |
for i,l in enumerate(nestedList): | |
dt.AddRange(l,gh.Kernel.Data.GH_Path(i)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Read the Grasshopper Datatree "tree" and translates it to | |
a nested Python list """ | |
pyList = [list(b) for b in tree.Branches] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sum = 0 | |
Results = [] | |
for v in Values: | |
Sum += v | |
Results.append(Sum) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
foo = [] | |
for i in range(3): | |
bar = [] | |
for j in range(3): | |
bar.append(i*j) | |
foo.append(bar) | |
print foo |
NewerOlder