Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. alcol68
    A
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 7
    • Best 0
    • Controversial 0
    • Groups 0

    alcol68

    @alcol68

    0
    Reputation
    4
    Profile views
    7
    Posts
    0
    Followers
    0
    Following
    Joined Last Online
    Website www.artby.space/ Location Boulder, CO, USA Age 32

    alcol68 Unfollow Follow

    Latest posts made by alcol68

    • RE: DescID and DescLevel for Shader Layers and properties

      @ferdinand Thank you for your in-depth analysis. It would have taken me way too long to figure this out lol, especially finding "CUSTOMDATA_BLEND_LIST". The first example seems to work for me, but like you said, it may not be reliable. The Python node example also works great. Again, thank you for your time.

      posted in Cinema 4D SDK
      A
      alcol68
    • RE: DescID and DescLevel for Shader Layers and properties

      hahaha I apreciate your help. Yea this has been wild trying to figure this out, but the creator id note gives me even more direction. Thank you.

      posted in Cinema 4D SDK
      A
      alcol68
    • RE: DescID and DescLevel for Shader Layers and properties

      To slightly answer my own, most recent question and to complete my second initial question about adding keyframes to an animation track for the Gradient in a Gradient Layer of the Shader:

      As shown in the picture below, if you right-click on the “Layer” parameter of the Shader, navigate over User Interface, and click ‘Show Subchannels,” you can then see all the parameters of the Shader Layers. You can then drag the Transform Angle parameter into the console and get its description ID. Doing this, I was able to get that the dynamic DescID of the Transform Angle parameter (like you showed before): “Layer[c4d.SLA_LAYER_BLEND, 10120].”
      dev response1.PNG
      Putting this into the correct DescID format, I can create an animation track for any of the Layer parameters. I can create an animation track for this specific Transform Angle parameter with the above DescID.

      c4d.DescID(c4d.DescLevel(c4d.SLA_LAYER_BLEND), c4d.DescLevel(10120, c4d.DTYPE_REAL))
      

      HOWEVER, when I use this same DescID to add a port into the Layer/Object operator that I am working with, an empty port is created, not the Transform Angle port I want. But, if I go to manually add the correct port I want on this same operator, it is renamed to “Color Profile” and greyed out, as if it is currently being used (shown in the picture below). So, there is something missing in how I’m adding this port, either another level or a declared type with the first “c4d.SLA_LAYER_BLEND” level. I’m not sure what exactly is incorrect or missing with the adding of this port.
      dev response2.PNG
      We are getting closer to the answer, though.

      posted in Cinema 4D SDK
      A
      alcol68
    • RE: DescID and DescLevel for Shader Layers and properties

      I appreciate your help, Ferdinand. I'm in no rush for this. I am now going through the C++ header files to try to get a better understanding of this and the code you posted.

      I saw an older post where you noted that A LayerShaderLayer is not a scene element, but stored in the data container of a LayerShader. If that is true, is there a way to return a list of all the data stored within that LayerShader data container, like you can with the "GetUserDataContainer" function?

      posted in Cinema 4D SDK
      A
      alcol68
    • RE: DescID and DescLevel for Shader Layers and properties

      I guess another way to do this is to create a Python node, rather than an object node, and access the Shader Layer parameters that way.

      posted in Cinema 4D SDK
      A
      alcol68
    • RE: DescID and DescLevel for Shader Layers and properties

      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] = Shader
      

      Using 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.

      posted in Cinema 4D SDK
      A
      alcol68
    • DescID and DescLevel for Shader Layers and properties

      So, I am working on a couple things dealing with layer shaders from a Shader Field.

      1.) Adding ports to an Object Xpresso Operator with the Shader as the linked object.
      2.) Adding keyframes to an animation track for the Gradient in a Gradient Layer of the Shader.

      I have had no issue creating XPresso nodes and ports in general. As an example, here is a snippet of how I add ports for object operators:

      ObjectNode = NodeMaster.CreateNode(Root,c4d.ID_OPERATOR_OBJECT, insert=None, x=700, y=850)
      
      ObjectNode.SetParameter(c4d.DescID(c4d.GV_OBJECT_OBJECT_ID), Null, c4d.DESCFLAGS_SET_NONE)
      
      ObjectNodeIn = ObjectNode.AddPort(c4d.GV_PORT_INPUT, c4d.DescID(c4d.DescLevel(c4d.ID_BASEOBJECT_GLOBAL_POSITION)), flag=c4d.GV_PORT_FLAG_IS_VISIBLE, message=False)
      

      I can add an object operator, and link the shader to the object operator, but I am having trouble creating the ports using the DescID and DescLevels, simply because I’m not sure what IDs to use in the DescLevel to access the parameters (as shown in the image below).

      Similarly, I have no problems creating tracks and keys for animated parameters, so long as I know the DescID and DescLevels for those parameters. I have combed through the forum and SDKs, and can’t seem to find how to access the shader layer parameters through this method. I also have no problem creating Shader Layers and accessing their parameters after instantiation, but not how to reference them through the DescLevel method.

      Here is an example of how I set key and tracks normally:

      pid_pmix = c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA, c4d.DTYPE_SUBCONTAINER, 0), c4d.DescLevel(4))
      
      mixtrack = c4d.CTrack(Xpresso, pid_pmix)
      
      Xpresso.InsertTrackSorted(mixtrack)
      
      defkey, dub = doc.GetDefaultKey()
      
      mixcurve = mixtrack.GetCurve()
      
      mixval1 = 0
      
      mixkey1 = defkey.GetClone()
      
      mixkey1.SetValue(mixcurve, mixval1)
      
      mixkey1.SetTime(mixcurve, c4d.BaseTime(46/20))
      
      mixcurve.InsertKey(mixkey1, True
      

      As mentioned above, the only problem I’m having is finding and accessing the DescLevel IDs for the shader layers and their properties for these two scenarios. I am currently working on C4D 2025.2.0. Any advice or direction would be greatly appreciated. Thank you.

      dev post.PNG

      posted in Cinema 4D SDK 2025 python windows
      A
      alcol68