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
    • Recent
    • Tags
    • Users
    • Login

    Get All Shaders

    Scheduled Pinned Locked Moved PYTHON Development
    2 Posts 0 Posters 184 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 10/07/2014 at 11:34, xxxxxxxx wrote:

      I am trying to get all of the shaders that are in a material.

      This returns some of the shaders but not all of them. I am using it on an Octane material but that shouldn't make a difference. Drag and dropping my material into the timeline will show all of the shaders, basically I want that list.

      Here is the code: Just a simple search down and next script. Any help would be great!

      import c4d,sys
      from c4d import gui
        
      def main() :
          
          c4d.CallCommand(13957)
          
          def ShaderSearch(shader) :
              next = shader.GetNext()
              down = shader.GetDown()
              
              print shader.GetName()
              
              if down:
                  ShaderSearch(down)
              if next:
                  ShaderSearch(next)
          
              
          shader = doc.GetActiveMaterial().GetFirstShader()
          ShaderSearch(shader)
          c4d.EventAdd()
          
      if __name__=='__main__':
          main()
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 10/07/2014 at 12:08, xxxxxxxx wrote:

        I figured it out, I had to treat each shader like a separate object. simple addition, heres the code:

        import c4d,sys
        from c4d import gui
          
        def main() :
            
            c4d.CallCommand(13957)
            ShaderList[]
            def ShaderSearch(shader) :
                next = shader.GetNext()
                down = shader.GetDown()
                try:
                    ShaderSearch(shader.GetFirstShader())
                except AttributeError:
                    pass
                print shader.GetName()
                if down:
                    ShaderSearch(down)
                if next:
                    ShaderSearch(next)
            
            shader = doc.GetActiveMaterial().GetFirstShader()
            ShaderSearch(shader)
            
            c4d.EventAdd()
            
        if __name__=='__main__':
            main()
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post