How can I use python code for adding new environment?

How can i do for this?
I want to use python code made rhino environment panel ( _-EnvironmentEditor), New environment then Add HDR Light Studio environment,How can I write the python code?

then add HDR Light Studio Environment faster


i do not have the “HDR Light Studio environment” on my system but you could try to add one of those environments manually in the UI and save it as *.renv file. Then import it using this python code:

import scriptcontext
import rhinoscriptsyntax as rs
def LoadEnvironment():
    # valid path and name of the saved environment
    path = r"D:\Temp\Rhino Sky.renv"
    name = "Rhino Sky"
    # if an environment with this name exists, skip loading it
    env_names = [e.Name for e in scriptcontext.doc.RenderEnvironments]
    if not name in env_names:
        # load from file
        cmd = "_RenderLoadEnvironmentFromFile " + chr(34) + path + chr(34)
        if not rs.Command(cmd, False): return

    # set current environment    
    cmd = "_RenderSetCurrentEnvironment " + chr(34) + name + chr(34)
    rs.Command(cmd, True)
if __name__=="__main__":

There are a few other environment related commands listed here.


Hi Clement,
Thank you very much. It works well. Good Job!