Turning Reflectance Layers On / Off

On 15/10/2014 at 17:34, xxxxxxxx wrote:

Hey there!

Is there a way to turn on / off different layers in the Reflectance channel using the Python API?  I want to be able to toggle the eyeball switch on my Specular layer based on some User Data.  Any help would be greatly appreciated.

Thanks!

joey

On 16/10/2014 at 07:15, xxxxxxxx wrote:

Hello,

Reflectance is currently not supported by the Python API. You can only access it with the C++ Material class.

Best wishes,
Sebastian

On 10/10/2017 at 18:05, xxxxxxxx wrote:

This is now possible.

  
"""Name-US: Toggle Reflectance   
Description-US: Toggle the first reflectance layer on/off.   
"""   
  
import c4d   
from c4d import gui   
  
def main() :   
    mat = doc.GetActiveMaterial()   
    if not mat:   
        return   
       
    doc.StartUndo()   
    doc.AddUndo(c4d.UNDOTYPE_CHANGE, mat)   
       
    layer = mat.GetReflectionLayerIndex(0) # Get the top-most layer   
    if not layer:   
        return   
       
    flags = layer.GetFlags()   
    if flags is None:   
        return   
       
    active_toggled_flags = flags ^ c4d.REFLECTION_FLAG_ACTIVE   
    layer.SetFlags(active_toggled_flags)   
       
    doc.EndUndo()   
    c4d.EventAdd()   
  
if __name__=='__main__':   
    main()   

On 05/11/2017 at 05:59, xxxxxxxx wrote:

thanks for the update, is it now possible to enable/disable individual Reflectance Layers in Xpressso?

My hack is going to be just to turn the Brightness to 0% otherwise lol

On 06/11/2017 at 02:41, xxxxxxxx wrote:

Hello,

the activity state of a reflectance layer is stored in a flag, not a parameter. So I'm afraid it is not possible to edit this value using XPresso.

best wishes,
Sebastian

On 07/11/2017 at 05:44, xxxxxxxx wrote:

Hey,

Thanks for the answer.  I did test using Xpresso to turn the Brightness of the Color channel to 0% and it works the same as turning the flag to 0.  Or at least it Renders the same, not sure on the back end.

I need to get back into Python and C++ again.  Xpresso can do so much though.

Cheers,

Matt