Add a light source with Python API

Is there a way to manually add a light (e.g. a Domelight) to a world with the python API? I only found a way using the replicator class light = replicator.create.light(...)

This code works for me for creating Sphere lights:

l = UsdLux.SphereLight.Define(world.stage, Sdf.Path(some_prim_path))
l.CreateExposureAttr(...)
l.CreateRadiusAttr(...)
l.AddTranslateOp()
XFormPrim(some_prim_path).set_local_pose(translation=...)

You could use UsdLux.DomeLight for dome lights.

1 Like

@robin-vetsch , you can also refer this document for lights related things:Lights — Omniverse Create documentation

This code works for me in 2023.1:

import omni.isaac.core.utils.prims as prim_utils

light_1 = prim_utils.create_prim(
    "/World/Light_1",
    "SphereLight",
    position=np.array([1.0, 1.0, 1.0]),
    attributes={
        "inputs:radius": 0.01,
        "inputs:intensity": 5e3,
        "inputs:color": (1.0, 0.0, 1.0)
    }
)

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.