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?
Thanks.
-
On 20/12/2016 at 03:02, xxxxxxxx wrote:
Hi,
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: return shader = mat[c4d.MATERIAL_COLOR_SHADER] if shader is None or shader.GetType() != c4d.Xlayer: return layer = shader.GetFirstLayer() if layer is None: return layer.SetParameter(c4d.LAYER_S_PARAM_ALL_ACTIVE, True) shader.Message(c4d.MSG_CHANGE) c4d.EventAdd() if __name__=='__main__': 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.