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

    gain access to vray shaders [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 432 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 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.

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

        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.

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

          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..

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

            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

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

              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..

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