I have this code where I create a light sphere in Isaac Sim and I have some attributes added to it that work and the information from the code is handled correctly in the Isaac Sim properties tab. But when I tried to add the last attribute (“visibleInPrimaryRay”: True) from the dictionary, I got an error.
Here is the code:
import omni.isaac.core.utils.prims as prim_utils
import numpy as np
import requests
light_1 = prim_utils.create_prim(
“/World/light_1”,
“SphereLight”,
position=np.array([-0.02, -0.13, 0.08]),
attributes={
“inputs:radius”: 0.02,
“inputs:intensity”: 5e3,
“inputs:exposure”: 0.1,
“inputs:color”: (1.0, 0.0, 1.0),
“inputs:enableColorTemperature”: True,
“visibleInPrimaryRay”: True
}
)
…
The error and the property that I tried to add are in the print screens.
@haiduc.hory i am just another OV user, but someone else on Discord had similar issue a while back. it was explained by one of the devs that the visibleInPrimaryRay attribute doesn’t actually exist until the user toggles it in the property UI. so, that’s likely the reason why you are getting that error when initiating the prim.
so one way to work around this programmatically is to create and set the attribute after prim creation:
import numpy as np
import omni.isaac.core.utils.prims as prims_utils
from pxr import Usd, UsdGeom, Sdf
import omni.usd
light = prims_utils.create_prim(
prim_path= '/World/light_1',
prim_type= 'SphereLight',
position=np.array([-0.02, -0.13, 0.08]),
attributes={'inputs:radius': 0.02, 'inputs:intensity': 5e3, 'inputs:exposure': 0.1, 'inputs:color': (1.0, 0.0, 1.0), 'inputs:enableColorTemperature': True}
)
# create and set attribute for visible in primary ray after initiating prim creation
light.CreateAttribute("visibleInPrimaryRay", Sdf.ValueTypeNames.Bool).Set(True)