I have previously looked at the “How to Create and Populate a Layer Shader” post. The shader that I am referencing above, I can easily create using those same methods. Below is the code for creating the Shader I am working with:
Field1 = doc.SearchObject("Shader Field") Shader = c4d.LayerShader() ShaderLayer1 = Shader.AddLayer(c4d.TypeShader) GradientShader1 = c4d.BaseList2D(c4d.Xgradient) GradientShader1[c4d.ID_BASELIST_NAME] = "Gradient Circular" GradientShader1[c4d.SLA_GRADIENT_TYPE] = c4d.SLA_GRADIENT_TYPE_2D_CIRC GradientShader1[c4d.SLA_GRADIENT_CYCLE] = False GradientShader1[c4d.SLA_GRADIENT_ANGLE] = 3.14159 Gradient1 = GradientShader1[c4d.SLA_GRADIENT_GRADIENT] Gradient1.FlushKnots() Gradient1.InsertKnot(c4d.Vector(0,0,0), 1, 0, 0.5, 0) Gradient1.InsertKnot(c4d.Vector(0,0,0), 1, 1, 0.5, 1) GradientShader1[c4d.SLA_GRADIENT_GRADIENT] = Gradient1 GradientShader1.InsertUnder(Shader) ShaderLayer1.SetParameter(c4d.LAYER_S_PARAM_SHADER_LINK, GradientShader1) ShaderLayer2 = Shader.AddLayer(c4d.TypeShader) GradientShader2 = c4d.BaseList2D(c4d.Xgradient) GradientShader2[c4d.ID_BASELIST_NAME] = "Gradient U" GradientShader2[c4d.SLA_GRADIENT_CYCLE] = False GradientShader2[c4d.SLA_GRADIENT_ANGLE] = 3.14159 Gradient2 = GradientShader1[c4d.SLA_GRADIENT_GRADIENT] Gradient2.FlushKnots() Gradient2.InsertKnot(c4d.Vector(0,0,0), 1, 0.125, 0.5, 0) Gradient2.InsertKnot(c4d.Vector(1,1,1), 1, 1, 0.5, 1) GradientShader2[c4d.SLA_GRADIENT_GRADIENT] = Gradient2 GradientShader2.InsertUnder(Shader) ShaderLayer2.SetParameter(c4d.LAYER_S_PARAM_SHADER_LINK, GradientShader2) ShaderLayer3 = Shader.AddLayer(c4d.TypeShader) NoiseShader = c4d.BaseList2D(c4d.Xnoise) NoiseShader[c4d.SLA_NOISE_COLOR1] = c4d.Vector(1,1,1) NoiseShader[c4d.SLA_NOISE_COLOR2] = c4d.Vector(0,0,0) NoiseShader[c4d.SLA_NOISE_SEED] = 666 NoiseShader[c4d.SLA_NOISE_GLOBAL_SCALE] = 2 NoiseShader[c4d.SLA_NOISE_ANI_SPEED] = 1 NoiseShader[c4d.SLA_NOISE_CONTRAST] = 1 NoiseShader.InsertUnder(Shader) ShaderLayer3.SetParameter(c4d.LAYER_S_PARAM_SHADER_LINK, NoiseShader) ShaderLayer3.SetParameter(c4d.LAYER_S_PARAM_SHADER_MODE, 11) ShaderLayer4 = Shader.AddLayer(c4d.TypeTransform) ShaderLayer4.SetParameter(c4d.LAYER_S_PARAM_TRANS_ANGLE, 3.14159) Field1.InsertShader(Shader) Field1[c4d.ID_MG_SHADER_SHADER] = ShaderUsing the port-creation example I gave before, for an object operator, I use the DescLevel to get the ID of the property I want to create a port for. In the above example, I use the integer “c4d.ID_BASEOBJECT_GLOBAL_POSITION.” Then if I want to use the specific Z parameter, I use the second level integer of “c4d.VECTOR_Z.”
I assume there is a similar level system to grab the angle parameter of the Transform layer in my Shader. The Shader itself is linked to the object operator, so accessing its layers should be the first level.
ObjectNode.AddPort(c4d.GV_PORT_INPUT, c4d.DescID(c4d.DescLevel(c4d.SLA_LAYER_BLEND), c4d.DescLevel(c4d.LAYER_S_PARAM_TRANS_ANGLE)), flag=c4d.GV_PORT_FLAG_IS_VISIBLE, message=False)If I use just the single level integer of “c4d. LAYER_S_PARAM_TRANS_ANGLE” the port is not created. So, I assume there is another level above this one that needs to be called as well, namely the actual Transform layer itself. But I don’t know how to call that layer as an integer in the DescLevel method, because I cannot pass an object (“ShaderLayer4” from my above creation code) in the integer parameter of DescLevel. I used the placeholder of “c4d.SLA_LAYER_BLEND” as that first level, but it creates an empty port, not the angle parameter port. Using “c4d.TypeTransform” or “c4d. LAYER_S_PARAM_ALL_ACTIVE” do not work either.
This is what I am trying to figure out: What is the integer that I need to use in order to access the Transform Layer itself to use in the DescLevel method, to use in the AddPort method? Unless there is a different way to add a port, I cannot find any information on this particular issue.