Assign a texture to a face is displaying the average color


Sorry for my english

I have to create a material and add it a texture through Ruby API.

When i assign the material to a face, it displays the average color of the texture. At contrary, when i colorize a face through UI with the same material (from my code), it works fine.

Here is my code

    model = Sketchup.active_model
    materials = model.materials
    material = materials.add("test")
    material.texture = params.to_s #path to texture
    material.texture.size =

    for parent_entity in model.entities
        if parent_entity.is_a? Sketchup::ComponentInstance
            definition = parent_entity.definition
            for entity in definition.entities
                if entity.is_a? Sketchup::Face

Any idea ?

Thank you for you help

I just found a solution

Sketchup.send_action "renderTextures:"


It is preferable to set the rendering options via:

Texture rendering is controlled via “Texture” attribute, which can be true|false

ropts = Sketchup.active_model.rendering_options

The “RenderMode” values are:

0 = Wireframe
1 = HiddenLine
2 = Shaded
5 = Monochrome

XRay mode is controlled via “ModelTransparency” which can be true|false

Show back dashed edges mode is controlled via “DrawBackEdges” which can be true|false (This only works for SketchUp v15+)


Could this also be related to this method in the API?


Maybe if you try one of the two options it will work as well.