Change object color command

I’m new to rhino and so far really impressed. I am wondering if there is a command to change an objects color that is faster then going through the property menu. I usually have the layers tab visible and don’t want to have to go to the property tab each time. I usually have colors set by layer but often want to change the color of an object without changing it’s layer or material.

Hello- if you have specific ‘canned’ colors in mind you can use the ‘dash’ version of the Properties (’-Properties’) command to set the color - it would be something like this:

! -Properties Pause Object Color Object 255,0,0 EnterEnd

You can use a macro like this on a button, an alias (see Help) or in the Object context menu (Options > ContextMenu > Object menu), which is how I use it- I have a list of half a dozen colors that I can assign via right click this way.


Thank you. I will play with this.

I use this:

import rhinoscriptsyntax as rs

def QuickColour():
    objects = rs.GetObjects("Pick objects for colour change", 0, None, True)
    if objects is None: return
    colour = rs.GetColor((255,255,255))
    if colour is None:
        for object in objects:
            rs.ObjectColor(object, colour)

if __name__ == "__main__":     

1 Like

Hi. A little bit late to the party. :slight_smile:

I need to change this command to change the colour of the SELECTED objects to “ByLayer” and unfortunately I can’t find a way to make this.

I only get: “Unknown command: ColorObject=ByLayer” or

“-Properties Object Color Object By Layer _Enter” = “Unknown command: By”

Take out the space between “by” and “layer”…

Hi Helvetosaur.

I tried your suggestion but still not working

" !-Properties Pause Object Color ByLayer _Enter "

Command: -Properties
Command: Pause
Choose option ( Object AttributeUserText ElefrontAttributes CurvePiping Visible=Yes ): Object
Property to change ( Name Layer Color Linetype PrintColor PrintLinewidth Hyperlink Match CastsShadows ReceivesShadows AdvancedTexturePreview ): Color
Color source ( Object Layer ): ByLayer
Unknown command: ByLayer

Yes, ByLayer is not the command line option - it is just “Layer”

! -Properties Pause Object Color Layer _Enter

Thank you, now it is working. Just needs an extra _Enter at end.

Yep, sorry, didn’t copy it out of the macro editor correctly.

How can I find the options for other commands to write macros?

I still need to create a scaling macro and can’t find the right keywords.

For example “Scale factor or first reference point” and “Base point”. What are the keywords for this options?

Simply type the -dash version of the command and look at the command line - you will see all the options spelled out there… Just copy/paste.

Thank you, but still are missing options. Like in the “-Scale” command, I can’t figure out how to pass the “Scale factor or first reference point” and “Base point” options.

Exactly as you do in Rhino. The first prompt is the origin, which wants a point. The second prompt is looking for either a number - which it will treat as a scale factor - or a point, which it will treat as the first reference point. If a point is entered at the second prompt, you can enter another point at the third prompt.

So a macro might look like this:

! _-Scale _Pause 0 2.0 (scale factor)

or this:

! _-Scale _Pause 0 1,0,0 2,0,0 (2 reference points)

Note this uses the active view coordinate system, if you want world coordinates, precede all point entries with a “w”.

HTH, --Mitch

Thank you. It’s working.

How to pass an argument for rotation ?

This macro: “! _-Rotate _Pause 0,0,0 0 -90” is giving-me an error: “Unknown command: -90”

One too many 0’s.

! _-Rotate _Pause 0,0,0 -90

0,0,0 is the rotation center, -90 is the degrees of rotation.

When macros fail, hit F2 to bring up command history and look at Rhino’s response to the macro prompts. It’s pretty easy to figure out from that where Rhino is getting confused.

1 Like

Yes. Thank you. Still a lot to learn.