Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > PYTHON Development
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

Turning Reflectance Layers On / Off

 Post Reply Post Reply
Author
Message
jkorenman View Drop Down
Member
Member


Joined: 2013 Apr 14
Location: Boston, MA
Online Status: Offline
Posts: 2
Post Options Post Options   Quote jkorenman Quote  Post ReplyReply Direct Link To This Post Topic: Turning Reflectance Layers On / Off
    Posted: 2014 Oct 15 at 5:34pm
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


Back to Top
S_Bach View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2011 Jun 27
Online Status: Offline
Posts: 1364
Post Options Post Options   Quote S_Bach Quote  Post ReplyReply Direct Link To This Post Posted: 2014 Oct 16 at 7:15am
Hello,

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

Best wishes,
Sebastian
Back to Top
Donovan Keith View Drop Down
Member
Member


Joined: 2002 Oct 30
Location: United States
Online Status: Offline
Posts: 199
Post Options Post Options   Quote Donovan Keith Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Oct 10 at 6:05pm
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()
Back to Top
Matt Workman View Drop Down
Member
Member
Avatar

Joined: 2016 Feb 27
Location: Cambridge, MA
Online Status: Offline
Posts: 16
Post Options Post Options   Quote Matt Workman Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Nov 05 at 5:59am
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
Back to Top
S_Bach View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2011 Jun 27
Online Status: Offline
Posts: 1364
Post Options Post Options   Quote S_Bach Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Nov 06 at 2:41am
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
SDK Support Engineer
Back to Top
Matt Workman View Drop Down
Member
Member
Avatar

Joined: 2016 Feb 27
Location: Cambridge, MA
Online Status: Offline
Posts: 16
Post Options Post Options   Quote Matt Workman Quote  Post ReplyReply Direct Link To This Post Posted: 2017 Nov 07 at 5:44am
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


Creator of Cine Designer and Set Designer for C4D
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.