Embedded Scripts : Scripting inside Kit¶
This extension allows users to write scripts anywhere in omniverse without having to go through multiple steps of creating extensions to contain the code.
What it Does¶
Allows loading python files into a project.
Every file added to an embedded script project will be loaded when the scene is loaded, but it isn’t guaranteed to be loaded first.
Every update on a script file will trigger the script to be reloaded.
What it Doesn’t Do¶
This extension does not replace creating kit extensions, but it makes the first steps in developing with scripts easier.
This extension does not make any runtime safety guarantees (yet). See Warning: All Files Executed On Load.
Creating a New Project¶
In the program menu, select Project > Create New Project
In the stage view, you will see a prim named
/ProjectSettings was created. Do not move or rename that prim, it contains the project.
Adding Script Files¶
In the content browser, select any
.py file, right click it and click Add To Project:
Save the stage as always.
Editing Script Files Locally¶
Right click a script and select “Open File in Default Editor”. The file will load in the default editor. If it is remote, it will load from a temporary location. Every time the file is saved, it will be updaed in the omniverse location.
Creating Script Files¶
In the content browser, right-click on any free space and click “Create New Script” to create a script file at this location on Omniverse.
Warning: All Files Executed On Load¶
The ProjectSettings Widget¶
Clicking the ProjectSettings prim in the stage window will populate the property window with the project settings.
Inside the project settings window, selecting each file dependency allows you to reveal the file in the content browser or delete it from the project.
Deleting Files From The Project¶
Deleting files from the project removes the project’s dependency of the file. The file is not deleted from Omniverse or the filesystem, it is simply removed fromthe project
Resource leaks - Each file loaded / unloaded from Embedded Scripting creates a virtual python module in runtime. When reloading or removing these, the embedded scripting extension does its best to delete all references of the file, but isn’t always successful, due to Python’s ownership of the memory. It is recommended to use Python Weak References everywhere inside the embedded scripts when referring to outside resources and vice versa - otherwise a reference may be held indefinitely.
Reference leaks - Holding a virtual module for a loaded file also means the file may have dangling references to older versions of the code. Take extra care to keep references in their appropriate scope.