Setting texture path to a RS Domelight with python

Hey!

So for context I'm busy with my first cinema integration plugin, its a multi DCC app that i already have working with Houdini/Maya.

I'm trying to create a dome light, adjust some parameters and link the hdr texture file to the texture input.

Seem to be having a hard time trying to find an API reference or examples of this being done and script log doesn't seem to help much with this as it only responds with the command 'c4d.REDSHIFT_LIGHT_DOME_TEX0' which cant take a string.

If anyone can help point me in the right direction would be much appreciated.

Iv stripped a script down to absolutely bare bones for an example:

import c4d


def main():
    
    doc = c4d.documents.GetActiveDocument()
    hdri_path = ''
    
    # Create Light
    light = c4d.BaseObject(1036751)
       
    # Set the attributes
    light[c4d.REDSHIFT_LIGHT_TYPE] = 4
    
    # Set Texture
    #light[c4d.REDSHIFT_LIGHT_DOME_TEX0] = hdri_path
    #c4d.REDSHIFT_LIGHT_DOME_TEX0
 
    # Insert the light into the scene
    doc.InsertObject(light)


if __name__=='__main__':
    main()
    c4d.EventAdd()

Hello @Ryan_Territory,

Welcome to the Plugin Café forum and the Cinema 4D development community, it is great to have you with us!

Getting Started

Before creating your next postings, we would recommend making yourself accustomed with our Forum and Support Guidelines, as they line out details about the Maxon SDK Group support procedures. Of special importance are:

About your First Question

This exact question of yours has been asked before here for C++. Find a Python variant of the code below. For the technical details, I would recommend reading the older thread.

Cheers,
Ferdinand

Result:
557e9ddd-793a-4d07-aa6e-5ffd7ad05687-image.png

Code:

import c4d

# Define #Orslight, only must be done in pre 2023.0 API versions.
c4d.Orslight: int = 1036751


def main():
    
    doc = c4d.documents.GetActiveDocument()
    
    # Create Light
    light = c4d.BaseObject(c4d.Orslight)
       
    # Set the attributes
    light[c4d.REDSHIFT_LIGHT_TYPE] = c4d.REDSHIFT_LIGHT_TYPE_DOME
    
    # Define the texture parameter ID.
    texturePathId: c4d.DescID = c4d.DescID(
    # 1st DescLevel for the outer unexposed datatype of "Texture".
    c4d.DescLevel(
      c4d.REDSHIFT_LIGHT_DOME_TEX0, # The parameter ID (12000) for "Texture"
      1036765,                      # The datatype ID for for "Texture", this type is not exposed, 
                                    # we must use the raw ID.
      c4d.Orslight                  # The creator ID, Orslight in this case.
    ),
    # 2nd DescLevel for the inner exposed datatype of "Texture.Path". 
    c4d.DescLevel(
      c4d.REDSHIFT_FILE_PATH,       # The sub-channel parameter ID (1000) for "Texture.Path"
      c4d.DTYPE_STRING,             # The data type ID of this component, string in this case.
      0                             # The creator ID, I just went with undefined here.
    ))

    light[texturePathId] = "asset:///file_c622e9ad3ea0e159"
 
    # Insert the light into the scene
    doc.InsertObject(light)
    c4d.EventAdd()


if __name__=='__main__':
    main()

MAXON SDK Specialist
developers.maxon.net