Get All Shaders

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()

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()