GUI

Interactive Scripting

Every action in the GUI has its corresponding Python APIs
Everything that’s done in the GUI can be done with a Python command(but not the reverse, not all Python APIs have corresponding GUI)
Introduce the Script Editor inside the GUI environment and the Isaac Python REPL extension as the two interactive scripting options for running python while the stage is open
-Convenient tools for debugging and experimenting
-Will reproduce a few selected steps from previous GUI tutorials with Python snippets

Learning Objectives

-Script Editor window and python editing environment
-Isaac Python REPL extension
-Adding a Cube using USD API
-Adding a Cube using Isaac Sim API

Getting Started

Prerequisites:
Complete Add Simple Objects to have a basic understanding of the process adding a simple object onto the stage

Script Editor

Script Editor:
A python editing environment internal to Omniverse Kit
Can be used to run snippets of python code to interact with the stage
1)To open the script editor window, go to the Menu Bar and click Window > Script Editor
Nvidia_ScriptEditor1
A window will pop up, and you can dock somewhere you find convenient
2)Can open multiple tabs by going to the Tab Menu under Script Editor
All the tabs share the same environment, so libraries that are imported or variables defined in one environment can be accessed and used in other environments
Nvidia_ScriptEditor2
Nvidia_ScriptEditor3
3)Example
Nvidia_ScriptEditor4
Nvidia_ScriptEditor5
Nvidia_ScriptEditor6

REPL Extension

REPL(“Read–Evaluate–Print loop”):
A programming shell that can read and evaluate small snippets of code and allow users to interactively query the state of the variables inside the environment
-IPython, or Jupyter Notebook, is an example of a REPL environment
-Access is provided to a REPL environment through the Isaac REPL Extension (Linux only)
1)Make sure there is an instance of Isaac Sim already running
2)Enable the REPL Extension
Go to Windows > Extensions, search for Isaac Sim REPL, and enable it if it’s not already
Nvidia_ScriptEditor7
Check Autoload if you wish to have the extensions always enabled when you start Isaac Sim
3)Open a new terminal, and on the command line run telnet localhost 8223. A python shell will start in the terminal, and you are all set to start interacting with the stage opened in Isaac Sim via Python. Nvidia_ScriptEditor8
Copy-paste the snippets below to test it out

USD APIs

Underlying format in NVIDIA Omniverse is USD
Script to set up a ground plane, a default light, and a cuboid with physics and collision presets using raw USD APIs
Start with a fresh stage, copy and paste the code into the Script Editor window and run it, then press Play to simulate
Code:
https://drive.google.com/file/d/1QcKG6lgSgjjmBGKpdu4Znh042Q3Fiw1I/view?usp=sharing
Result:
Nvidia_ScriptEditor10
https://drive.google.com/file/d/10K4n49ogRd6GV97J_lZmZrTzjOVwQdq2/view?usp=sharing
Can execute the whole block at once, or line-by-line
Exit the shell environment by Ctrl+D

Isaac Sim Core APIs

Raw USD APIs are versatile and detailed but complex, especially for beginners
Omniverse Isaac Sim has a set of core APIs that simplifies some of the frequently used actions for robotics simulators and abstracts away default parameter settings
Here are the same actions of setting up the stage and adding a cuboid with physics and collision presets, as well as setting physics and visual material properties
Code:
Nvidia_ScriptEditor9
https://drive.google.com/file/d/1ndRR1PW7UML8uY-QcfG3MMGGM6BoOEvP/view?usp=sharing
Result:
Nvidia_ScriptEditor11
https://drive.google.com/file/d/1vUXascrkeZTQDLdzPJGxo6v0xGkIPVEB/view?usp=sharing
Using Isaac Sim Core APIs produces code that is much more lightweight and readable, though you can always resort to using USD APIs to direct the stage whenever necessary

Summary

The Script Editor window
The REPL extension
Using Python APIs to replace GUI commands
The difference between USD APIs and Isaac Sim Core APIs

Reference:
https://docs.omniverse.nvidia.com/isaacsim/latest/gui_tutorials/tutorial_gui_interactive_scripting.html