Retrieve the color of an entity

Continuing the discussion from Retrieve the geometry of an entity:

(Breaking this out into it’s own topic.)

Colors in SketchUp, as applied to entities, is a property of the entity’s material attribute.

So to set a component to color it’s faces, you first create a material object, and set it’s properties (color and/or texture image.) Then you use the material= method to set the group or component instance to use that material object instance you just created.

To do the opposite, use the group or component instance’s material getter method, to receive a reference to it’s material object instance. Then check it’s color property to receive a reference to the Sketchup::Color object instance it uses. If unset (both color and material,) you will get nil returned.

So see the API documentation for:
Sketchup::Color
and
Sketchup::Material

1 Like