Created
December 6, 2015 05:16
-
-
Save ksobon/77f81df525c2ab9ecaa1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
from scriptcontext import doc | |
def GetColor(inStr): | |
splitStr = inStr.split(',') | |
if len(splitStr) != 1: | |
r = int(splitStr[0]) | |
g = int(splitStr[1]) | |
b = int(splitStr[2]) | |
color = System.Drawing.Color.FromArgb(r,g,b) | |
return color | |
else: | |
try: | |
decimal = int(inStr) | |
chunks = len(inStr) | |
chunk_size = len(inStr)//3 | |
splitStr1 = [ inStr[i:i+chunk_size] for i in range(0, chunks, chunk_size) ] | |
r1 = int(splitStr1[0]) | |
g1 = int(splitStr1[1]) | |
b1 = int(splitStr1[2]) | |
color = System.Drawing.Color.FromArgb(r1,g1,b1) | |
return color | |
except: | |
color = System.Drawing.Color.FromName(inStr) | |
return color | |
pass | |
def GetLineType(name): | |
lineTypes = rc.RhinoDoc.ActiveDoc.Linetypes | |
return lineTypes.Find(name, True) | |
def GetLayer(name): | |
index = rc.RhinoDoc.ActiveDoc.Layers.Find(name, True) | |
return rc.RhinoDoc.ActiveDoc.Layers[index] | |
if RunIt: | |
output = [] | |
ltCount = rc.RhinoDoc.ActiveDoc.Layers.Count | |
for i in range(0, ltCount, 1): | |
layer = rc.RhinoDoc.ActiveDoc.Layers[i] | |
if layer.Name in layerNames: | |
index = layerNames.index(layer.Name) | |
# set line weight | |
layer.PlotWeight = float(plotWeight[index]) | |
rc.RhinoDoc.ActiveDoc.Layers.Modify(layer, layer.LayerIndex, False) | |
# set line color | |
color = GetColor(plotColor[index]) | |
layer.PlotColor = color | |
rc.RhinoDoc.ActiveDoc.Layers.Modify(layer, layer.LayerIndex, False) | |
# set line type | |
lineTypeIndex = GetLineType(lineType[index]) | |
if lineTypeIndex != -1: | |
layer.LinetypeIndex = lineTypeIndex | |
rc.RhinoDoc.ActiveDoc.Layers.Modify(layer, layer.LayerIndex, False) | |
output.append(layer.Name) | |
else: | |
output.append("Fail") | |
a = output | |
else: | |
out = "Set Run it to True" | |
a = None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment