Пример #1
0
def organize_annotations():
    """
    - puts all dimensions found in all pages on layer 'dim' and annotations on 'annotation'
    - creates layer called 'dim' + 'annotation' if it doesn't exist and changes its color to black
    version 1.0
    www.studiogijs.nl
    """

    #check if layer 'dim' exist, else create it
    if not rs.IsLayer("dim"): rs.AddLayer("dim")
    rs.LayerColor("dim", Col.Black)

    #check if layer 'annotation' exist, else create it
    if not rs.IsLayer("annotation"): rs.AddLayer("annotation")
    rs.LayerColor("annotation", Col.Black)

    objects = Rhino.RhinoDoc.ActiveDoc.Objects.FindByObjectType(
        Rhino.DocObjects.ObjectType.Annotation)

    for obj in objects:

        if type(obj) == Rhino.DocObjects.LeaderObject or type(
                obj) == Rhino.DocObjects.TextObject:
            rs.ObjectLayer(obj, "annotation")
        else:
            rs.ObjectLayer(obj, "dim")
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)
Пример #3
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)
def cutAtPlan(level):
    planPlane = rs.AddPlaneSurface([-1000,-1000,level], 3000, 3000)
    baseLayer = rs.AddLayer("60_PLANS")
    newParent = rs.AddLayer("PLAN_"+str(level), parent = baseLayer)
    origLayer = rs.CurrentLayer()
    shortName = rs.LayerName(origLayer, fullpath = False)
    
    #newChildsParent = rs.AddLayer( , parent = newParent)
    newChild = rs.AddLayer(shortName, parent = newParent, color = rs.LayerColor(origLayer))
    rs.CurrentLayer(newChild)
    
    objs = rs.ObjectsByLayer(origLayer)
    #if len(objs)<1:
    #    skip = True
    intersectCrvs = []
    tempCrv = None
    for obj in objs:
        if rs.IsBrep(obj):
            
            tempCrv = rs.IntersectBreps(obj, planPlane)
        if tempCrv != None:
            intersectCrvs.append(tempCrv)
    
    for crv in intersectCrvs:
        if not None:
            rs.ObjectLayer(crv, newChild)
    
    rs.DeleteObject(planPlane)
    rs.CurrentLayer(origLayer)
Пример #5
0
def iterate():
    colDelta = 20
    origLayer = rs.GetLayer("Select Layer to Iterate")
    if origLayer is None:
        return

    shortName = origLayer.split("::")[-1]
    parentLay = rs.ParentLayer(origLayer)
    nameParts = shortName.split("_")
    if len(nameParts) > 1:
        num = int(nameParts[1]) + 1
    else:
        num = 1
    if len(str(num)) == 1:
        newNum = "0" + str(num)
    else:
        newNum = str(num)
    newName = nameParts[0] + "_" + newNum
    lay1 = rs.CurrentLayer(origLayer)

    #MAterials
    matIndex = rs.LayerMaterialIndex(lay1)

    #New Color
    oldCol = rs.LayerColor(lay1)
    oldRed = rs.ColorRedValue(oldCol)
    oldGreen = rs.ColorGreenValue(oldCol)
    oldBlue = rs.ColorBlueValue(oldCol)

    newRed = oldRed + randCol(colDelta)
    if newRed > 255:
        newRed = 255 - (newRed - 255)
    if newRed < 0:
        newRed = abs(newRed)

    newGreen = oldGreen + randCol(colDelta)
    if newGreen > 255:
        newGreen = 255 - (newGreen - 255)
    if newGreen < 0:
        newGreen = abs(newGreen)

    newBlue = oldBlue + randCol(colDelta)
    if newBlue > 255:
        newBlue = 255 - (newBlue - 255)
    if newBlue < 0:
        newBlue = abs(newBlue)
    newCol = (newBlue, newGreen, newBlue)
    newLay = rs.AddLayer(newName, color=newCol, parent=parentLay)
    #print nameParts
    #print newName
    finalLayer = rs.CurrentLayer(newLay)
    #sc.doc.Layers.CurrentLayer.RenderMaterialIndex = 3
    #c = sc.doc.Layers.CurrentLayer.RenderMaterialIndex
    #sc.doc.Layers.Modify(
    #Rhino.DocObjects.Tables.LayerTable.CurrentLayer.r
    #sc.doc.Views.Redraw()
    #b = sc.doc.Layers.CurrentLayer
    #print ""
    return
Пример #6
0
def translateColor(layer, colorString):
    if len(colorString) > 1:
        newColor = (int(colorString.split("-")[0]),
                    int(colorString.split("-")[1]),
                    int(colorString.split("-")[2]))
    else:
        newColor = rs.LayerColor(layer)
    return newColor
Пример #7
0
def duplicateLayer(name, source, destination):
    newLayer = rs.AddLayer(name,
                           color=rs.LayerColor(source),
                           parent=destination)
    rs.ParentLayer(newLayer, destination)
    #    print(name, source, destination)
    matchLayer(newLayer, source)
    return (newLayer)
Пример #8
0
def main():
    """
    Creates a part list for all blocks in a document. Numbers will correspond with 
    balloons, but balloons don't need to be present for the table to be generated
    
    version 1.3
    www.studiogijs.nl
    
    version 1.1 adds table heading
    version 1.2 option for choosing between all or only top level blocks
    version 1.3 adds block description. Use change_block_description.py
    or change in block manager
   
    """
    t = sc.sticky['top_level_only'] if sc.sticky.has_key(
        'top_level_only') else 0  #0 = top level only, 1= all blocks
    if t == None:
        t = 0
    top_level_only = rs.GetBoolean("annotate top level blocks only?",
                                   ["top_level_only", "yes", "no"], t)
    if not top_level_only:
        return
    sc.sticky['top_level_only'] = top_level_only[0]

    previous_layer = rs.CurrentLayer()
    #check if layer 'annotation' exist, else create it
    if not rs.IsLayer("annotation"): rs.AddLayer("annotation")
    rs.LayerColor("annotation", Col.Black)

    rs.CurrentLayer("annotation")

    groups = sc.doc.ActiveDoc.Groups
    partlist = []

    blocknames = get_block_names()
    if not blocknames:
        print "This file does not contain block items (titleblock will be ignored)"
        return
    #add headings
    texts = ["ITEM", "PART NAME", "DESCR", "QTY"]
    partlist.append(texts)
    texts = []
    for block_nr, blockname in enumerate(blocknames, 1):
        texts.append(str(block_nr))
        texts.append(blockname)
        description = rs.BlockDescription(blockname)
        if description is None:
            description = ""
        texts.append(description)
        blockcount = get_block_count(blockname)
        texts.append(str(blockcount))
        partlist.append(texts)
        texts = []
    create_table(partlist)
    #change back to previous layer
    rs.CurrentLayer(previous_layer)
Пример #9
0
def set_layer_properties(layer, properties):
    """Set Rhino layer properties."""

    rs.LayerVisible(layer, properties.get("LayerVisible"))
    rs.LayerLocked(layer, properties.get("LayerLocked"))
    rs.LayerColor(layer, hex_to_rbg(properties.get("LayerColor")))
    rs.LayerMaterialIndex(layer, properties.get("LayerMaterialIndex"))
    rs.LayerLinetype(layer, properties.get("LayerLinetype"))
    rs.LayerPrintColor(layer, hex_to_rbg(properties.get("LayerPrintColor")))
    rs.LayerPrintWidth(layer, properties.get("LayerPrintWidth"))
Пример #10
0
def DupAllSubLayers(layer, layerCopy):
    subs = rs.LayerChildren(layer)
    if subs:
        for sub in subs:
            color = rs.LayerColor(sub)
            objs = rs.ObjectsByLayer(sub)
            name = UniqueLayerCopyName(sub, False)
            addLayer = rs.AddLayer(name, color, parent=layerCopy)
            CopyObjectsToLayer(objs, addLayer)
            rs.ExpandLayer(addLayer, rs.IsLayerExpanded(sub))
            DupAllSubLayers(sub, addLayer)
Пример #11
0
    def set_color(self, c):
        """Sets layer color.
        Parameters:
          c = color as an RGB value array
        Returns:
          self
        """

        rs.LayerColor(self.name, c)

        return self
Пример #12
0
def get_layer_properties(layer):
    """Get Rhino layer properties."""

    return {
        "LayerVisible": rs.LayerVisible(layer),
        "LayerLocked": rs.LayerLocked(layer),
        "LayerColor": rgb_to_hex(rs.LayerColor(layer)),
        "LayerMaterialIndex": rs.LayerMaterialIndex(layer),
        "LayerLinetype": rs.LayerLinetype(layer),
        "LayerPrintColor": rgb_to_hex(rs.LayerPrintColor(layer)),
        "LayerPrintWidth": rs.LayerPrintWidth(layer)
    }
Пример #13
0
def annotation_balloon():
    """
    Adds a numbered balloon to the document based on the numbering in part list.
    Works only with block items, similar to how this works in 'solid modelers'
    on parts in assemblies
    www.studiogijs.nl
    
    version 1.1: option for choosing between all or only top level blocks
    
    """
    
    t = sc.sticky['top_level_only'] if sc.sticky.has_key('top_level_only') else 0 #0 = top level only, 1= all blocks
    if t==None:
        t=0
    top_level_only = rs.GetBoolean("annotate top level blocks only?", ["top_level_only", "yes", "no"],t)
    if not top_level_only:
        return
    sc.sticky['top_level_only'] = top_level_only[0]
    
    name = get_blockname()
    if not name:
        return
    
    previous_layer = rs.CurrentLayer()
    #check if layer 'annotation' exist, else create it
    if not rs.IsLayer("annotation"): rs.AddLayer("annotation")
    rs.LayerColor("annotation",Col.Black)
    
    rs.CurrentLayer("annotation")
    
    block_nr = get_block_index(name)+1 
    
    curve, size = get_input()
    if curve and size:
        aCircle, aText, aCurve = add_annotation_circle(curve, block_nr, size)
        aEndDot = add_end_dot(curve, size)
    else:
        rs.CurrentLayer(previous_layer)
        return
    #create annotation object
    groupname = 'annotation-object_'+str(block_nr)
    rs.AddGroup(groupname)
    rs.AddObjectsToGroup([aCircle, aText, aCurve, aEndDot], groupname)
    
    groups = sc.doc.ActiveDoc.Groups
    for group in groups:
        if group.Name == groupname:
            group.SetUserString("group-nr", str(block_nr))
            group.SetUserString("block-name", name)
    #change back to previous layer
    rs.CurrentLayer(previous_layer)
Пример #14
0
def DupLayersSublayersAndObjs():
    layer = rs.GetLayer()
    if layer == None: return
    #do initial run with selected layer
    color = rs.LayerColor(layer)
    objs = rs.ObjectsByLayer(layer)
    parentLayer = rs.ParentLayer(layer)

    copyName = UniqueLayerCopyName(layer, True)
    layerCopy = rs.AddLayer(copyName, color, parent=parentLayer)
    CopyObjectsToLayer(objs, layerCopy)
    rs.ExpandLayer(layerCopy, rs.IsLayerExpanded(layer))
    DupAllSubLayers(layer, layerCopy)
    rs.CurrentLayer(layerCopy)
Пример #15
0
def ColorizeLayers(aObj):
    rs.EnableRedraw(False)  # turn off redraw for faster script exectution.

    # the start value of r g b
    r = 1
    g = 0
    b = 0

    for i in range(0, len(aObj)):  #iterate through all selected objects
        r, g, b = GetColor(
            r, g, b)  #I made a function from your script to modify aColor.
        RGBColor = [int(r * 255), int(g * 255), int(b * 255)]
        rs.LayerColor(aObj[i], RGBColor)

    rs.EnableRedraw(True)  #turn screen redraw back on
Пример #16
0
def organize_details():
    """
    - puts all details on layer 'details'
    - creates layer called 'details' if it doesn't exist and changes its color to green
    version 1.0
    www.studiogijs.nl
    """

    #check if layer 'details' exist, else create it
    if not rs.IsLayer("details"): rs.AddLayer("details")
    rs.LayerColor("details",Col.Aquamarine)
    pageviews = sc.doc.Views.GetPageViews()
    for pageview in pageviews:
        #get all details
        details = pageview.GetDetailViews()
        for detail in details:
            rs.ObjectLayer(details, "details")
Пример #17
0
def AddCNCLayers():

    LayerNames = [
        "Work layer", "CNC drill", "CNC pocket", "CNC engrave", "CNC cut",
        "CNC 3D", "CNC tabs"
    ]
    LayerColors = [(221, 221, 221), (255, 191, 0), (253, 0, 255),
                   (255, 125, 218), (0, 163, 184), (100, 113, 113),
                   (191, 191, 255)]
    Count = 0
    for x in LayerNames:
        layer.Name = x
        sc.doc.Layers.Add(layer)
        sc.doc.Layers.Add

        rs.LayerColor(x, LayerColors[Count])
        Count += 1
Пример #18
0
def Iterate():
    block = rs.GetObject("Select Design Option Block to iterate",
                         rs.filter.instance, True)
    if block is None: return

    try:
        prevBlockName = rs.BlockInstanceName(block)
        prevBlockLayer = rs.ObjectLayer(block)
        prevBlockLayerColor = rs.LayerColor(prevBlockLayer)

        newBlock = ReplicateBlock(block)
        newBlockName = rs.BlockInstanceName(newBlock)

        #Ensure 3_DESIGN OPTIONS already exists
        parentLayer = layers.AddLayerByNumber(3000, False)[0]
        rs.LayerVisible(parentLayer, True)

        #Create new design option layer
        #newBlockLayer = rs.AddLayer(parentLayer + "::" + newBlockName, color = utils.StepColor(prevBlockLayerColor))
        newBlockLayer = rs.AddLayer(parentLayer + "::" + newBlockName,
                                    color=utils.GetRandomColor())
        rs.LayerPrintColor(newBlockLayer, (0, 0, 0))
        rs.ObjectLayer(newBlock, newBlockLayer)

        #Save user text
        try:
            parentsUserTest = rs.GetUserText(block,
                                             'Design Option History') + "<--"
        except:
            parentsUserTest = ''
        rs.SetUserText(newBlock, 'Design Option History',
                       parentsUserTest + newBlockName)

        #Turn off prev blocks layer
        if rs.CurrentLayer() != prevBlockLayer:
            rs.LayerVisible(prevBlockLayer, False)

        result = True
    except:
        result = False
        newBlockName = ''
    utils.SaveFunctionData(
        'Blocks-Iterate',
        [__version__,
         rs.BlockInstanceName(block), newBlockName, result])
    return result
Пример #19
0
def setup_layer(name, options):
    parent = options.get('parent', None)
    locked = options.get('locked', False)

    if not rs.IsLayer(name):
        layer = rs.AddLayer(name=name, parent=parent, locked=locked)
    else:
        rs.ParentLayer(name, parent)
        layer = rs.LayerName(name)

    color = options.get('color', (0, 0, 0))
    print_width = options.get('lineWeight', 0)
    linetype = options.get('lineType', 'Continuous')

    rs.LayerColor(name, color)
    rs.LayerPrintWidth(name, print_width)
    rs.LayerLinetype(name, linetype)

    return layer
Пример #20
0
def ImportLighthouseSensorsFromJSON(filename):
    print "Reading", filename
    contents = file(filename).read()
    if "{" not in contents:
        raise Exception("Malformed JSON")
    header = contents[0:contents.find('{')]
    print header

    try:
        layername = os.path.splitext(os.path.basename(filename))[0].lower()
    except:
        layername = "sensors"

    jsonstr = contents[contents.find('{'):]
    data = json.loads(jsonstr)

    originalLayer = rs.CurrentLayer()
    layername = rs.AddLayer(layername)
    rs.CurrentLayer(layername)
    rs.LayerColor(layername, RandomSaturatedColor())

    groupName = rs.AddGroup(layername)

    SENSOR_RADIUS_MM = 3.0
    SENSOR_NORMAL_LENGTH_MM = 8.0

    for point, normal in zip(data['modelPoints'], data['modelNormals']):
        position = rs.coerce3dvector([x * 1000.0 for x in point])
        normal = rs.VectorUnitize(normal)
        normalOrthoA = Orthogonal(normal)
        normalOrthoB = rs.VectorCrossProduct(normalOrthoA, normal)

        objID = rs.AddCircle3Pt(position + SENSOR_RADIUS_MM * normalOrthoA,
                                position - SENSOR_RADIUS_MM * normalOrthoA,
                                position + SENSOR_RADIUS_MM * normalOrthoB)
        rs.AddObjectToGroup(objID, groupName)

        objID = rs.AddLine(position,
                           position + SENSOR_NORMAL_LENGTH_MM * normal)
        rs.AddObjectToGroup(objID, groupName)

    rs.CurrentLayer(originalLayer)
Пример #21
0
def ExportAsSKP(objs, newFolder, newFolderName):
    tempLayers = []
    
    copiedObjs = []
    
    rs.StatusBarProgressMeterShow('Exporting to SKP', 0, len(objs))
    
    for i, obj in enumerate(objs):
        tempCopy = rs.CopyObject(obj)
        rs.ObjectLayer(tempCopy, rs.ObjectLayer(obj))
        copiedObjs.append(tempCopy)
        rs.StatusBarProgressMeterUpdate(i)
    
    for obj in copiedObjs:
        shortName = rs.LayerName(rs.ObjectLayer(obj), False)
        layerName = newFolderName + '_' + shortName
        if rs.IsLayer(layerName):
            rs.ObjectLayer(obj, layerName)
        else:
            matIndex = rs.LayerMaterialIndex(rs.ObjectLayer(obj))
            newLayer = rs.AddLayer(layerName, rs.LayerColor(rs.ObjectLayer(obj)))
            rs.LayerMaterialIndex(newLayer, matIndex)
            tempLayers.append(newLayer)
            rs.ObjectLayer(obj, newLayer)
    rs.StatusBarProgressMeterHide()
    
    try:
        filepath = os.path.join(newFolder,newFolderName + '.skp')
        rs.SelectObjects(copiedObjs)
        rs.Command('-_Export ' + '"' + filepath + '"' + ' s SketchUp2015 Enter ', False)
        
        #CLEANUP
        rs.UnselectAllObjects() 
        try:
            rs.DeleteObjects(copiedObjs)
        except:
            rs.DeleteObject(copiedObjs)
        for layer in tempLayers:
            rs.DeleteLayer(layer)
    except:
        print "export failed"
Пример #22
0
def setTemplateLayerColors():
    """ Set Rhino layer colors to the AHD style """

    # Set context to Rhino document and disable redraw
    sc.doc = rc.RhinoDoc.ActiveDoc
    rs.EnableRedraw(False)

    # Set layer colors
    for i, l in enumerate(rs.LayerNames()):
        if i == 0:
            rs.LayerColor(l, Color.FromArgb(255, 105, 105, 105))
        elif i == 1:
            rs.LayerColor(l, Color.FromArgb(255, 255, 0, 90))
        elif i == 2:
            rs.LayerColor(l, Color.FromArgb(255, 70, 190, 190))
        elif i == 3:
            rs.LayerColor(l, Color.FromArgb(255, 0, 85, 255))
        elif i == 4:
            rs.LayerColor(l, Color.FromArgb(255, 130, 255, 0))
        elif i == 5:
            rs.LayerColor(l, Color.FromArgb(255, 190, 190, 190))
Пример #23
0
def text_background_color():
    lay_curr = rs.CurrentLayer()
    col_lay = rs.LayerColor(lay_curr)
    rs.AppearanceColor(12,col_lay)
Пример #24
0
    'show.vertices': True,
    'show.edges': True,
    'show.forces': True,
    'show.forces_as_vectors': True,
    'show.interfaces': True,
    'mode.interface': 0,
    'mode.force': 0,
    'scale.force': 10.0
})

rs.CurrentLayer('Assembly')
rs.LayerVisible('Blocks', False)
rs.LayerVisible('Supports', False)

rs.AddLayer('forces')
rs.LayerColor('forces', (255, 0, 0))
rs.DeleteObjects(rs.ObjectsByLayer('forces'))
rs.CurrentLayer('forces')

g = 9.81  #m/s^2
d = 1000  #Kg/m^3
for a, b, attr in assembly.edges(True):
    if attr['interface_forces'] is None:
        continue
    s = attr['interface_size']
    sp = attr['interface_points']
    fff = []
    for i in range(len(attr['interface_points'])):
        t = attr['interface_forces'][i]['c_nn']
        cp = centroid_points(sp)
        if t >= 0.0001:
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)
Y_Step = 10000

#Define the prefix of each file
Sail_Name = rs.GetString("Input Sail Number")
x = rs.GetInteger("Number of Drawings in X direction")
y = rs.GetInteger("Number of Drawings in Y direction")
direct = rs.BrowseForFolder(None, "Choose a folder", None)

#Define color to exort geometry to DWG cause cannot see black in DWG
Black = Color.Black
White = Color.White

#Change black color to white
layers = rs.LayerIds()
for layer in layers:
    print rs.LayerColor(layer)
    if rs.LayerColor(layer) == Black:
        rs.LayerColor(layer, White)

#Select the drawings which are in grid and export.
for j in range(y):
    for i in range(x):
        x_cnt = X_ST + i * X_Step
        y_cnt = Y_ST + j * Y_Step
        x1 = x_cnt - X_Step / 2
        x2 = x_cnt + X_Step / 2
        y1 = y_cnt - 2300
        y2 = y_cnt + 4900
        k = str(int(i + 1)).zfill(2)
        l = str(int(j + 1)).zfill(2)
        #Define path
"""
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)
 def __set_render_color(self):
     r = self.emotion_properties["color"]["r"]
     g = self.emotion_properties["color"]["g"]
     b = self.emotion_properties["color"]["b"]
     rs.LayerColor("Default", (r, g, b))
Пример #29
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])
Пример #30
0
import rhinoscriptsyntax as rs
import random
from System.Drawing import Color

layers = rs.LayerNames()


def randomcolor():
    red = int(255 * random.random())
    green = int(255 * random.random())
    blue = int(255 * random.random())
    return Color.FromArgb(red, green, blue)


for layer in layers:
    rs.LayerColor(layer, randomcolor())