Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
Hello all,
I tried everything to figure out how to use the newly added Python-Command "LayerShader.AddLayer()" in S24. As far as I know it only adds the "Type" of Layer. For Example I want to add a certain shader to the Layer I first use AddLayer(c4d.TypeShader) and this will give me an empty "Shader". But how can I define this shader to a specific Shader then? (https://developers.maxon.net/docs/Cinema4DPythonSDK/html/modules/c4d/C4DAtom/GeListNode/BaseList2D/BaseShader/LayerShader/index.html?highlight=addlayer#LayerShader.AddLayer)
I tried everything but I dont get it... does someone know how to do it?
Thx in advance!
NOTE ( @ferdinand ) : The here provided code example contains an error, please refer to How to Create and Populate a Layer Shader? instead.
Hi @PdZ-1 welcome in plugincafe.
The type need to be one of the LayerType. So to have a regular BaseShader you first need to create a TypeShader layer and then set the link. Find a code snippet
TypeShader
import c4d # Main function def main(): # Retrieveh teh Layer Shader mat = doc.GetFirstMaterial() sha_xlayer = mat.GetFirstShader() # Create an HSL layer hsl = sha_xlayer.AddLayer(c4d.TypeHSL) # Create a Shader Layer shader_layer = sha_xlayer.AddLayer(c4d.TypeShader) # Create a Gradient Shader gradient_shader = c4d.BaseShader(c4d.Xgradient) # Insert this gradient to the material (so the material become the owner of this shader too) mat.InsertShader(gradient_shader, sha_xlayer) # Finally set the Shader Layer link to the Gradient Shader shader_layer.SetParameter(c4d.LAYER_S_PARAM_SHADER_LINK, gradient_shader) c4d.EventAdd() # Execute main() if __name__=='__main__': main()
Cheers, Maxime.
Hello @PdZ-1,
without further questions or replies, we will consider this topic as solved by Monday, the 30th and flag it accordingly.
Thank you for your understanding, Ferdinand
Hi... I'm trying to figure out how to handle nested LayerShaders
mat.InsertShader(gradient_shader, sha_xlayer) inserts gradient_shader as a child of sha_xlayer ? Would sha_xlayer.InsertShader(gradient_shader) do exactly the same thing ?
If yes, does mat.InsertShader(sha_xlayer) have to be done first as well, or can you set up a shader tree first and then add it to the material?
best, index