Operating System:
Windows
Kit Version:
107 (Kit App Template)
Kit Template:
Kit Base Editor
GPU Hardware:
3050 series
GPU Driver:
Latest
**
I have downloaded a Kitchen Set USD scene somewhere in internet. In there, there is a light object of type Mesh:** /Kitchen_set/Props_grp/Ceiling_grp/CeilingLight_1/Geom/pCylinder164
I want to turn this light on.
Because I’m very new to Omniverse and USD so I ask chatgpt and it give me this function
def enable_mesh_light_meshlightapi(prim_path, intensity=200.0, color=(1.0,1.0,1.0)):
stage = omni.usd.get_context().get_stage()
if not stage:
print(“No stage open.”); return False
prim = stage.GetPrimAtPath(prim_path)
if not prim or not prim.IsValid():
print(“Prim not found:”, prim_path);
return False
try:
if UsdLux.MeshLightAPI.CanApply(prim):
print("Applying MeshLightAPI to", prim_path)
UsdLux.MeshLightAPI.Apply(prim)
print('11111')
lightApi = UsdLux.LightAPI(prim)
print('22222')
lightApi.CreateIntensityAttr().Set(float(intensity))
print('33333')
lightApi.CreateColorAttr().Set(Gf.Vec3f(*color))
print('44444')
# optional normalization by area:
# lightApi.CreateNormalizeAttr().Set(True)
prim.SetActive(True)
print("MeshLightAPI applied & light attributes set.")
return True
else:
print("MeshLightAPI cannot be applied to prim (CanApply==False).")
return False
except Exception as e:
print("Error applying MeshLightAPI:", e)
return False
This is what it print in console
Applying MeshLightAPI to /Kitchen_set/Props_grp/Ceiling_grp/CeilingLight_1/Geom/pCylinder164
11111
22222
And it hang there forever. 33333 and 44444 and so on were never reached.
And my Kit become Not responding so I must kill it via Task Manager (or CMD)
What am I missing? Thanks

