Can not set color of the layer by C API!

I can set the color of layer by Ruby API ,but I can not by C API.

Is this a question or you just saying… ? :wink:

Read e.g. this:
C API : Get and Set Material Color for a SULayerRef · Issue #418 · SketchUp/api-issue-tracker · GitHub


Yup as that Tracker issue mentions, you access via the Layer’s material in the C API.

But ! do not assign any layer material to anything else especially geometry or image objects. A layer’s material is owned by that layer and is unique and must not be shared.

1 Like

I can do it by RubyAPI, but I can not do it by CAPI.

Sketchup.active_model.layers.first.color = 'red'

When I copy the layer from a.skp to b.skp, I find can not copy the color of layer.

Causes the layer color to be black.

You mean that’s all right?

// get material
SULayerGetMaterial() ;
// then change color ?

This looks strange,but I will try it.