Script or Macro to set a display color to selected objects

I have this:

"""Changes selected objects' colors to a fixed color (argument)
Script by Mitch Heynick 15.12.18"""
import rhinoscriptsyntax as rs

def MakeColor(color):
    block_count=0
    selected=rs.GetObjects("Select objects to apply color",preselect=True)
    if selected:
        objs=[]
        for obj in selected:
            if rs.IsBlockInstance(obj): block_count+=1
            else: objs.append(obj)
        if objs:
            rs.EnableRedraw(False)
            rs.ObjectColor(objs,color)
            #rs.UnselectAllObjects()
        rs.Redraw()
        msg2="{} block instances found - explode before changing color!"
        if block_count: rs.MessageBox(msg2.format(block_count))
MakeColor(rs.coercecolor([0,255,0])) #change color argument as needed

It only works on discreet objects, not sub-selected faces of polysurfaces. (I might be able to modify that) Just change the 3 numbers in the last line to any other RGB color you want.

1 Like