Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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 4
    • Best 0
    • Controversial 0
    • Groups 0

    alcol68

    @alcol68

    0
    Reputation
    4
    Profile views
    4
    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

      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