Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    How to get and create redshift light groups with python?

    Cinema 4D SDK
    2023 python
    2
    3
    471
    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.
    • gheyretG
      gheyret
      last edited by

      Hi everyone~
      How did i create and get redshift light groups with python ?

      www.boghma.com

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        Hi,

        A part of the information was on the redsfhit forum.

        Light group parameter on the light itself is only a string and you can change it as any other string.
        Creating the AOV is also straight forward once you have the code ^^. Just be careful with the name you are using for your groups they must match. For the AOV, to activate the checkbox of the lightgroup themself, you must define the parameter REDSHIFT_AOV_LIGHTGROUP_NAMES with the name of the light group separate by a newline symbol \n like so myLightGroup1\nAnotherLightGroup\n"

        import c4d
        import c4d.documents
        import redshift
        
        def CreateAOVs(vpRS):
            aovs = []
        
            # Create a new AOV and define different parameters.
            aov = redshift.RSAOV()
            aov.SetParameter(c4d.REDSHIFT_AOV_TYPE, c4d.REDSHIFT_AOV_TYPE_BEAUTY)
            aov.SetParameter(c4d.REDSHIFT_AOV_ENABLED, True)
            aov.SetParameter(c4d.REDSHIFT_AOV_NAME, "My Beauty")
            aov.SetParameter(c4d.REDSHIFT_AOV_LIGHTGROUP_NAMES, "myLightGroup1\nAnotherLightGroup\n")
            aov.SetParameter(c4d.REDSHIFT_AOV_FILE_ENABLED, True)
            aov.SetParameter(c4d.REDSHIFT_AOV_FILE_PATH, "C:/MyAOVs/MyBeauty")
            # Insert the AOV in the list
            aovs.append(aov)
            
            # Set the AOVs list in the Redshift postEffect.
            return redshift.RendererSetAOVs(vpRS, aovs)
        
        
        
        def main():
            doc = c4d.documents.GetActiveDocument()
            # Create two ligths and insert them in the document
            light1 = c4d.BaseObject(1036751)
            light2 = c4d.BaseObject(1036751)
            doc.InsertObject(light1)
            doc.InsertObject(light2)
            
            # Define the light group is as simple as setting a string for this parameter
            light1[c4d.REDSHIFT_LIGHT_LIGHT_GROUP] = "myLightGroup1"
            light2[c4d.REDSHIFT_LIGHT_LIGHT_GROUP] = "AnotherLightGroup"
            renderdata = doc.GetActiveRenderData()
        
            # Get the Redshift videoPost and render settings
            vprs = redshift.FindAddVideoPost(renderdata, redshift.VPrsrenderer)
            if vprs is None:
                return
        
            CreateAOVs(vprs)
        
        if __name__=='__main__':
            main()
        

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        gheyretG 1 Reply Last reply Reply Quote 0
        • gheyretG
          gheyret @Manuel
          last edited by

          @manuel
          Cool ! Thank you ~

          www.boghma.com

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