コード例 #1
0
def unifyColor(layer):
    layer_c = rs.LayerColor(layer)
    layer_m = rs.LayerMaterialIndex(layer)
    if layer_m == -1:
        layer_m = rs.AddMaterialToLayer(layer)
    rs.MaterialColor(layer_m, layer_c)
    rs.LayerPrintColor(layer, layer_c)
コード例 #2
0
def SampleSynchronizeRenderColors():

    objects = rs.AllObjects()
    if objects is None: return

    for obj in objects:

        color = rs.ObjectColor(obj)
        source = rs.ObjectColorSource(obj)
        material = -1

        if source == 0:
            layer = rs.ObjectLayer(obj)
            material = rs.LayerMaterialIndex(layer)
            if material < 0:
                material = rs.AddMaterialToLayer(layer)

        elif source == 1:
            material = rs.ObjectMaterialIndex(obj)
            if material < 0:
                material = rs.AddMaterialToObject(obj)

        if material >= 0:
            if color != rs.MaterialColor(material):
                rs.MaterialColor(material, color)

    rs.Redraw()
コード例 #3
0
def changeColors(childLayers):
    print(childLayers)
    for childLayer in childLayers:
        for name, color in colorDict.items():
            color = rs.coercecolor(color)
            if re.search('HATCH-' + name + '$', childLayer):
                print(childLayer)
                rs.LayerPrintColor(childLayer, color)
                rs.LayerColor(childLayer, color)
                layer_c = rs.LayerColor(childLayer)
                layer_m = rs.LayerMaterialIndex(childLayer)
                if layer_m == -1:
                    layer_m = rs.AddMaterialToLayer(childLayer)
                rs.MaterialColor(layer_m, layer_c)
コード例 #4
0
import rhinoscriptsyntax as rs

layer = rs.CurrentLayer()
layer_c = rs.LayerColor(layer)
layer_m = rs.LayerMaterialIndex(layer)
if layer_m == -1:
    layer_m = rs.AddMaterialToLayer(layer)
rs.MaterialColor(layer_m, layer_c)
rs.LayerPrintColor(layer, layer_c)
コード例 #5
0
"""
For use with the Feasibility Study Workflow. 
See "F:\Resource\Strategic Initiatives\0702013.20 Research Initiative\Rhino Workflow"

For use with Feasibility Study Assistant Grasshopper Script.
See "F:\Resource\Strategic Initiatives\0702013.20 Research Initiative\Grasshopper\Grasshopper Toolset\Feasibility Drafting and modeling Assistant"

This script is to create a subfolder to a hatch layer that specifies it as an 
open area, as you might label as "OPEN TO BELOW" in floor plans.

Make sure the layer you want to add an OPEN layer to is the currently selected layer
before running.

"""

import rhinoscriptsyntax as rs

currentLayer = rs.CurrentLayer()
layerName = rs.LayerName(currentLayer, fullpath=False)
newLayer = rs.AddLayer(name=layerName+"_OPEN")
rs.ParentLayer(newLayer, currentLayer)


layer_c = rs.LayerColor(currentLayer)
layer_m = rs.LayerMaterialIndex(currentLayer)
if layer_m == -1:
    layer_m = rs.AddMaterialToLayer(newLayer)
rs.MaterialColor(layer_m, layer_c)
rs.LayerPrintColor(newLayer, layer_c)
rs.LayerColor(newLayer, layer_c)
コード例 #6
0
import rhinoscriptsyntax as rs
from System.Drawing import Color
import random
#assign different materials to layers and change layer colors to correspond with it for export to lumion

def randomcolor():
    red = int(255*random.random())
    green = int(255*random.random())
    blue = int(255*random.random())
    return Color.FromArgb(red,green,blue)
    
count = rs.LayerCount()
layerNames = rs.LayerNames()
print(layerNames)
print "There are", count, "layers."
for i in range(count):
    rc = randomcolor()
    rs.LayerColor(layerNames[i], rc)
    rs.MaterialColor(i,rc)
    rs.MaterialName( i, str(i))
    rs.AddMaterialToLayer(layerNames[i])
コード例 #7
0
currentLayer = rs.CurrentLayer()

for entry in layerDict:

    cLayerName = currentLayer + "::" + entry

    if cLayerName not in rs.LayerNames():
        rs.AddLayer(entry,
                    rs.coercecolor(layerDict[entry]['LayerColor']),
                    parent=currentLayer)
    elif rs.LayerLinetype(cLayerName) is not (
            layerDict[entry]['LayerLinetype']):
        rs.LayerLinetype(cLayerName, layerDict[entry]['LayerLinetype'])

    rs.LayerColor(cLayerName, rs.coercecolor(layerDict[entry]['LayerColor']))
    rs.LayerLinetype(cLayerName, layerDict[entry]['LayerLinetype'])
    rs.LayerPrintWidth(cLayerName, layerDict[entry]['LayerPrintWidth'])
    rs.LayerPrintColor(cLayerName,
                       rs.coercecolor(layerDict[entry]['LayerPrintColor']))

    if re.search("-HATCH-", cLayerName):
        layer_c = rs.coercecolor(rs.LayerColor(cLayerName))
        layer_m = rs.LayerMaterialIndex(cLayerName)
        if layer_m == -1:
            layer_m = rs.AddMaterialToLayer(cLayerName)
        rs.MaterialColor(layer_m, layer_c)
        rs.LayerPrintColor(cLayerName, layer_c)

rs.EnableRedraw(enable=True)
コード例 #8
0
ファイル: read_csv.py プロジェクト: flecheria/RhinoPython
 # check correct data structure
 # print(len(point_list), len(point_list[0]))
 # print(len(norm_list), len(norm_list[0]))
 
 point_list = sweep_2D_data(point_list)
 norm_list = sweep_2D_data(norm_list)
 """
 print( len(string_data), len(string_data[0]) )
 print( len(point_list), len(point_list[0]) )
 print( len(norm_list), len(norm_list[0]) )
 """
 for i, team in enumerate(string_data):
     
     new_color = random_color()
     new_layer = rs.AddLayer(name = team[0], color = new_color)
     mat = rs.AddMaterialToLayer(new_layer)
     # test = rs.LayerMaterialIndex("base_surf")
     # rs.MatchMaterial(rs.ObjectMaterialIndex(new_layer), rs.ObjectMaterialIndex(mat) )
     rs.MaterialColor(mat, new_color)
     rs.MaterialShine(mat, 255 * 0.03)
     
     for j, value in enumerate(team):
         
         if(j == 0):
             # print("ok")
             name_dot = rs.AddTextDot(value, point_list[i][j])
             rs.ObjectLayer(name_dot, new_layer)
         else:
             # convert to string to float
             value = float(value)
             if(value > 0):