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

    set / get reflectance layer options

    PYTHON Development
    0
    3
    1.2k
    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
      Helper
      last edited by

      On 27/02/2018 at 04:48, xxxxxxxx wrote:

      I try to get and set some values of a reflectance layer.

      import c4d
      from c4d import gui
        
      def main() :
          
          mat1 = doc.SearchMaterial("MatReflectance")
          print "nr of reflectance layers: ", mat1.GetReflectionLayerCount()
          
          refl_shd = mat1.GetAllReflectionShaders()
          for rs in refl_shd:
              print "bitmap:" ,rs[c4d.BITMAPSHADER_FILENAME]   
              print "refl strength: ", rs[c4d.REFLECTION_LAYER_MAIN_VALUE_REFLECTION]	#!not working
       
          #setting a bitmap is working!  
          rs[c4d.BITMAPSHADER_FILENAME] = "del.hdr"      
        
          c4d.EventAdd()
        
      if __name__=='__main__':
          main()
        
      
      

      I get an error when trying to get the layer reflection strength (REFLECTION_LAYER_MAIN_VALUE_REFLECTION).

      It is also strange that I have to use BITMAPSHADER_FILENAME to get the bitmap file name and not REFLECTION_LAYER_COLOR_TEXTURE. This is the constant I get when I drag this field into the console.

      -Pim

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

        On 28/02/2018 at 01:31, xxxxxxxx wrote:

        Hi Pim,

        GetAllReflectionShaders Actually retrieve all shaders inside all reflections layers.
        That mean if you add a BitmapShader or a Filter or any other shader, it will return you the shader. Not  the Reflection Layer.

        So here a code sample to iterate over all the Reflection Layer.
        The main purpose it to get the c4d.ReflectionLayer object for each layer.
        Then you can use GetDataID to retrieve the base ID of all parameters for this ReflectionLayer and simply add the parameter ID you want to this base ID.

        import c4d
          
        def main() :
            mat = doc.SearchMaterial("MatReflectance")
            cntLayer = mat.GetReflectionLayerCount()
            
            for i in xrange(0, cntLayer) :  
                layer = mat.GetReflectionLayerIndex(i)
                
                print "refl strength: ", mat[layer.GetDataID() + c4d.REFLECTION_LAYER_MAIN_VALUE_REFLECTION]  
          
            c4d.EventAdd()
          
        if __name__=='__main__':
            main()
        

        With that said I really encourage you to read the C++ Manual and give a look at this blog post[URL-REMOVED].

        Best, Maxime


        [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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

          On 01/03/2018 at 02:11, xxxxxxxx wrote:

          Hi Maxime,

          Yes, that works. Thanks a lot.

          -Pim

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