Add Python Scripting Component via Python Script

I have found python code to create rigdbodies, joints and most other components. But how can I add a Python Scripting Component to a prim via a python script?

Can you please guide me to the documentation?

Hi @MartinBischoff

You can use kit commands to add a Python Scripting Component to a prim as follow:

import omni.usd
from pxr import Sdf

stage = omni.usd.get_context().get_stage()
prim = stage.GetPrimAtPath("/World")

# add the Python Scripting Component
prim_paths = [prim.GetPath()]
omni.kit.commands.execute("ApplyScriptingAPICommand", paths=prim_paths)

# add script
scripts = Sdf.AssetPathArray(["/home/toni/Documents/"])
1 Like

Thank you ! omni.kit.commands is what I was looking for.

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