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

    fusion shader insert shader()

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 374 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      On 06/03/2017 at 08:08, xxxxxxxx wrote:

      I am having problems filling both channels of the fusion shader with python.

      What I am trying to achieve is:
      - Take the existing shader, if any, from the colour channel.
      - Create a fusion shader
      - Insert a colour shader in the blend channel
      - Insert the original shader in the base channel
      - Insert the fusion shader into the colour channel

      I can add the colour shader & update the material with the fusion shader but when I try to add the original shader to the base channel I get the message:

      "AssertionError: Found next objects. Please add them seperately"

      I guess it is a syntax problem.

      Here is a synapsis of my code:

      existing_shader = mat[c4d.MATERIAL_COLOR_SHADER]
      col_shader = c4d.BaseList2D(c4d.Xcolor)

      fusion_shader = c4d.BaseList2D(c4d.Xfusion)

      fusion_shader[c4d.SLA_FUSION_BLEND_CHANNEL] = col_shader
      fusion_shader.InsertShader(col_shader)
      fusion_shader.Message(c4d.MSG_CHANGE)

      if existing_shader:
          fusion_shader[c4d.SLA_FUSION_BASE_CHANNEL] = existing_shader
          fusion_shader.InsertShader(existing_shader)
          fusion_shader.Message(c4d.MSG_CHANGE)

      mat[c4d.MATERIAL_COLOR_SHADER] = fusion_shader
      mat.InsertShader(fusion_shader)
      mat.Message(c4d.MSG_CHANGE)
      mat.Update(True, True)

      The error is for th eline:

      fusion_shader.InsertShader(existing_shader)

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 07/03/2017 at 01:11, xxxxxxxx wrote:

        Hello,

        any GeListNode can only be part of one single list. Before insertion into a new list, you need to remove it from the old list (existing_shader.Remove()).

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 07/03/2017 at 01:41, xxxxxxxx wrote:

          Thanks Andreas, works perfectly, I understand better now.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post