Changing the color of Guides using code

Hi All,

I am interested in writing a ruby code that will change the color of guides. I know how to change the color without the code, but I want to be able to change it with one click of the button with the code I write. The way I change the guide’s color now is: Window → Styles → Edit → Guides.

Thanks,

David

It’s controlled by model.rendering_options.

To get a full list of things you can adjust with that class: Sketchup.active_model.rendering_options.keys.sort

In this case; Sketchup.active_model.rendering_options["ConstructionColor"].

To set the color: Sketchup.active_model.rendering_options["ConstructionColor"] = Sketchup::Color.new(255, 128, 0)

Thank you. That worked perfectly. How did you learn Ruby programming for sketchup so well?

In my previous job I was doing a lot of rendering - while waiting for renders to complete I wrote tools to improve my SketchUp workflow. …there was a lot of rendering… :wink:

The code you provided does change the color. However, I am using scenes within Sketchup and for some reason when I change scenes the color changes back to black. Is there a way to maintain the same color change while changing slides?

Thanks,

David

The color of the guides is a style attribute. Set it as desired by editing the styles you are using. Make sure to update the styles after editing.

Please complete your profile. It helps us help you.

Could you provide more detailed instructions please? I am in the Styles window. I can change the colors. As soon as I change the scene the colors change back.

David

That’s why I asked you to complete your profile. What operating system and SketchUp version?

Click on the blue icon at the right end of the row below the edit tab. Change the color for guides. Click on the little color swatch and make the edit. Then update the style by clicking on its thumbnail.

I am using Sketchup 2014 pro on a windows 7 operating system.

David

Please put that information in your profile.

I updated my profile.

Thank you. Were you able to edit and update the styles in your model?

Yea I got it to work. I changed from the default style to the Assorted Styles. Now it doesn’t change. I think when Sketchup is on the default style it maintains the same settings when I change scenes.

You can edit the color of the guides for any In Model style but you have to make that change for each style individually. And after making the changes, you have to update the style to make the changes stick. If you want to update styles in local collections such as the Dewfault styles, you’ll need to replace the old version with the new. It would make more sense, though to create your own library of styles so that you don’t lose the edits when you update SketchUp.

Assorted Styles is not just one style. It’s a collection or library of styles.

I just noticed I need to follow your instructions for every scene. That is every scene has a unique library of styles.

David

It might be that every scene has a different style. A scene can’t have a whole library of styles. One per scene, max. Unless there’s some reason to have different styles for each scene, you should check to see if there are scenes with the same settings–essentially the same style and use just one. Purge the others from the In Model library. There’s no point in having multiple identical styles.

FWIW, a styles consists of attributes for Edges including Profiles, color and so on., Faces (front and back face color, face style, etc.), Background options like color, sky and ground, Watermarks and the various Modeling settings such as the color of guides, selections and section cuts. In other words, all those things you can set under the Edit tab in the Styles window.