Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

developer:scriptsamples:randomcolorscript [2015/09/14] (current)
Line 1: Line 1:
 +====== Random Color Script for Rhino 4.0 ======
 +
 +  Dim r, g, b
 +  Dim dr, dg, db
 +  Dim upperbound, lowerbound
 +
 +  If (0) Then
 +    r=80
 +    g=40
 +    b=40
 +    rub =  10
 +    rlb = -10
 +    gub = 5
 +    glb = -5
 +  Else
 +    r=130
 +    g=120
 +    b=120
 +    rub =  5
 +    rlb = -5
 +    gub = 2
 +    glb = -2
 +  End If
 +
 +  Randomize
 +  arrobjs = Rhino.SelectedObjects
 +  For Each obj In arrobjs
 +    dr = Int((rub - rlb + 1) * Rnd + rlb)
 +    dg = Int((gub - glb + 1) * Rnd + glb)
 +    db = Int((gub - glb + 1) * Rnd + glb)
 +    c = RGB(r+dr,​g+dg,​b+dg)
 +    c = RGB(r+dr,​r+dr+dg,​r+dr+dg)
 +    i = Rhino.AddMaterialToObject(obj)
 +    Rhino.MaterialColor i, c
 +  Next
 +
 +
  
developer/scriptsamples/randomcolorscript.txt ยท Last modified: 2015/09/14 (external edit)