gain access to vray shaders [SOLVED]

On 24/04/2015 at 01:36, xxxxxxxx wrote:

code snipped of a script tag. has a userdata with a link to a specific vraydistance shader:

  
vrayshader = op[c4d.ID_USERDATA,1]
print vrayshader[c4d.VRAY_SHADERS_LIST] # returns shader type // 54 == distance
if vrayshader[c4d.VRAY_SHADERS_LIST] == 54: 
   print vrayshader[c4d.ID_SW_OBJECTS 1_209556393] # should return include list for objects assign to the distance shader
    

the mayor problem is that the [c4d.ID_SW_OBJECTS 1_209556393] are causing a syntax error. 
so is there a way to avoid that and read and write the include list of an vray shader? all other values exept the [c4d.VRAY_SHADER_LIST] are creating the same issue as the include list.

On 24/04/2015 at 06:23, xxxxxxxx wrote:

Hi,

your last line looks odd, with two values as array index. I'm not sure, what you are trying to do there... so basically I'm on the side of the compiler/interpreter 😉

Also we can not provide any support on vray in these forums. Sorry. Please try to get support from LAUBlab with vray questions.

On 27/04/2015 at 19:40, xxxxxxxx wrote:

Here you go:

import c4d
#Welcome to the world of Python
  
def main() :
    vrayshader = op[c4d.ID_USERDATA,1]
    if vrayshader[c4d.VRAY_SHADERS_LIST] == 54:
        cont = vrayshader.GetDataInstance()
        l=0
        #Iterate through the ID's inside the Distance shaders BaseContainer, looking for a CUSTOMGUI_INEXCLUDE_LIST
        while cont.GetIndexId(l) != -1:
            subID = cont.GetIndexId(l)
            if cont.GetType(subID) == c4d.CUSTOMGUI_INEXCLUDE_LIST:
                #Go through the objects in the CUSTOMGUI_INEXCLUDE_LIST ( if any )
                for i in xrange(cont[subID].GetObjectCount()) :
                    print "Object = "+str(cont[subID].ObjectFromIndex(c4d.documents.GetActiveDocument(),i))
            l+=1

Grabbing an objects BaseContainer, and trawling through it, is often the way to find stuff..

Be aware though - that when i was testing, i noticed the shader i linked in the UserData , did not update when the shader in the material i dragged it from was changed - ie it's a copy not a true instance or reference.  So you'll probably want to find a way around that also..

On 06/09/2015 at 06:42, xxxxxxxx wrote:

Thanks ! Work great!

Where did you found that CUSTOMGUI_INEXCLUDE_LIST link?

I need this to grab all shaders in a tree

On 06/09/2015 at 16:12, xxxxxxxx wrote:

No problem.

Keep a copy of the C++ SDK docs side by side with the Python docs, because a number of things aren't included in the Python docs but can be found in the C++ version.  Not everything in the C++ docs is available in the Python API though, but still really useful to have as a reference..