How to access to the Layer Shader parameters?

On 19/12/2016 at 19:33, xxxxxxxx wrote:

Hello there,

How to access to the Layer Shader parameters of the Color channel for example. (See the screenshot below)

I want to Enable/Disable layers using python, is it possible to do that?


On 20/12/2016 at 03:02, xxxxxxxx wrote:


A layer shader is represented by the class LayerShader.
First access the color channel of the material to retrieve it. Then call LayerShader.GetFirstLayer() to retrieve the first layer of the shader.
To loop through all the layers use LayerShaderLayer.GetNext() until it returns None.
To enable or disable a layer change LAYER_S_PARAM_ALL_ACTIVE parameter with LayerShaderLayer.SetParameter().
Layer parameter IDs aren't documented in the Python API currently but they can be found in the C++ SDK docs here.

Here's a simple script that enables the first Layer of a Layer Shader:

import c4d
def main() :
    mat = doc.GetFirstMaterial()
    if mat is None:
    shader = mat[c4d.MATERIAL_COLOR_SHADER]
    if shader is None or shader.GetType() != c4d.Xlayer:
    layer = shader.GetFirstLayer()
    if layer is None:
    layer.SetParameter(c4d.LAYER_S_PARAM_ALL_ACTIVE, True)
if __name__=='__main__':

On 20/12/2016 at 10:36, xxxxxxxx wrote:

Thank you Yannick,

I tried this script in C4D R14 and I have obtained this error message :
AttributeError: 'c4d.BaseShader' object has no attribute 'GetFirstLayer'

Is it possible to do that with R14?

PS : Tested with R17 and it works.

On 20/12/2016 at 10:56, xxxxxxxx wrote:

LayerShader class is implemented in R17.032. So you must do it in C++ if you want to support R14.

On 21/12/2016 at 10:10, xxxxxxxx wrote:

I have find an alternative to do that in Cinema 4D R14, in combining Python and XPresso, but thanks all the same.