On 02/11/2015 at 10:51, xxxxxxxx wrote:
Hi everyone, I've made a little script to "search" the name or type of a shader among all materials and so far is working, I get the number of occurrences and in which material they are. So far so good, BUT...what if I want to know also in which channel?
Here's the code:
import c4d, os
from c4d import gui
def shadertree(shader,parola,nome) :
# Loop through the BaseList
k = 0
while(shader) :
if str.lower(parola) in str.lower(shader.GetName()) or parola in str.lower(shader.GetTypeName()) : k = k+1
# Check for child shaders & recurse
if shader.GetDown() :
shadertree(shader.GetDown(),parola,nome)
# Get the Next Shader
shader = shader.GetNext()
return k
def main() :
parola = gui.InputDialog('Search')
if not parola :
return
mat = doc.GetFirstMaterial()
nome = mat.GetName()
n = 0
while(mat) :
shd = mat.GetFirstShader()
if shadertree(shd,parola,nome) > 0:
print "Found "+str(shadertree(shd,parola,nome)) + " occurrences of '"+parola+"' in material: "+str(mat.GetName())
n=n+1
# Get the Next material
mat = mat.GetNext()
if n == 0:
print "Not Found"
if __name__=='__main__':
main()