Need additional button for specific color code

I Need a additional button in toolbar which will apply gray color with RGB 135,135,135 to a selected object.
Can someone please help me into this?
Thank you in advance.

You can create a button with the following Python code in it:

! _-RunPythonScript (

import rhinoscriptsyntax as rs
objs = rs.GetObjects(preselect=True)
if objs:
    color = (135,135,135)
    if color:
        for obj in objs: rs.ObjectColor( obj, color )

)

Hello Martin,
Thank you for your quick response.
Yes it’s working in addition to what line I need to add to get object un selected so that I can quickly able to see that colour get’s changed.
Is there any way to add properties into this like name and which color?
Thanks a lot.

Name and unselect added.

You can also look at the example here:

rhinoscriptsyntax (rhino3d.com)

I took this and changed the color input to your grey color. The example let’s you choose a color

! _-RunPythonScript (

import rhinoscriptsyntax as rs
objs = rs.GetObjects(preselect=True)
if objs:
    color = (135,135,135)
    if color:
        for obj in objs: rs.ObjectColor( obj, color )
        rs.ObjectName(obj, 'name')
        rs.UnselectObjects(obj)

)