file_path
stringlengths
21
224
content
stringlengths
0
80.8M
mati-nvidia/developer-office-hours/tools/scripts/csv2md.py
# SPDX-License-Identifier: Apache-2.0 import argparse import csv from pathlib import Path if __name__ == "__main__": parser = argparse.ArgumentParser(description="Convert DOH CSV to MD") parser.add_argument( "csvfile", help="The CSV file to convert" ) args = parser.parse_args() csvfile = Path(args.csvfile) mdfile = csvfile.with_suffix(".md") rows = [] with open(csvfile) as f: with open(mdfile, "w") as out: for row in csv.reader(f): if row[2] and not row[5]: out.write(f"1. [{row[1]}]({row[2]})\n") print("Success!")
mati-nvidia/developer-office-hours/tools/scripts/make_ext.py
# SPDX-License-Identifier: Apache-2.0 import argparse import shutil import os from pathlib import Path SOURCE_PATH = Path(__file__).parent / "template" / "maticodes.doh_YYYY_MM_DD" def text_replace(filepath, tokens_map): with open(filepath, "r") as f: data = f.read() for token, fstring in tokens_map.items(): data = data.replace(token, fstring) with open(filepath, "w") as f: f.write(data) if __name__ == "__main__": parser = argparse.ArgumentParser(description="Create folder link to Kit App installed from Omniverse Launcher") parser.add_argument( "date", help="The dates of the Office Hour in YYYY-MM-DD format." ) args = parser.parse_args() year, month, day = args.date.split("-") # copy files dest_path = Path(__file__).parent / "../.." / f"exts/maticodes.doh_{year}_{month}_{day}" shutil.copytree(SOURCE_PATH, dest_path) # rename folders template_ext_folder = dest_path / "maticodes" / "doh_YYYY_MM_DD" ext_folder = dest_path / "maticodes" / f"doh_{year}_{month}_{day}" os.rename(template_ext_folder, ext_folder) tokens_map = { "[DATE_HYPHEN]": f"{year}-{month}-{day}", "[DATE_UNDERSCORE]": f"{year}_{month}_{day}", "[DATE_PRETTY]": f"{month}/{day}/{year}", } # text replace extension.toml ext_toml = dest_path / "config" / "extension.toml" text_replace(ext_toml, tokens_map) # text replace README readme = dest_path / "docs" / "README.md" text_replace(readme, tokens_map) # text replace extension.py ext_py = ext_folder / "extension.py" text_replace(ext_py, tokens_map) print("Success!")
mati-nvidia/developer-office-hours/tools/scripts/link_app.py
import os import argparse import sys import json import packmanapi import urllib3 def find_omniverse_apps(): http = urllib3.PoolManager() try: r = http.request("GET", "http://127.0.0.1:33480/components") except Exception as e: print(f"Failed retrieving apps from an Omniverse Launcher, maybe it is not installed?\nError: {e}") sys.exit(1) apps = {} for x in json.loads(r.data.decode("utf-8")): latest = x.get("installedVersions", {}).get("latest", "") if latest: for s in x.get("settings", []): if s.get("version", "") == latest: root = s.get("launch", {}).get("root", "") apps[x["slug"]] = (x["name"], root) break return apps def create_link(src, dst): print(f"Creating a link '{src}' -> '{dst}'") packmanapi.link(src, dst) APP_PRIORITIES = ["code", "create", "view"] if __name__ == "__main__": parser = argparse.ArgumentParser(description="Create folder link to Kit App installed from Omniverse Launcher") parser.add_argument( "--path", help="Path to Kit App installed from Omniverse Launcher, e.g.: 'C:/Users/bob/AppData/Local/ov/pkg/create-2021.3.4'", required=False, ) parser.add_argument( "--app", help="Name of Kit App installed from Omniverse Launcher, e.g.: 'code', 'create'", required=False ) args = parser.parse_args() path = args.path if not path: print("Path is not specified, looking for Omniverse Apps...") apps = find_omniverse_apps() if len(apps) == 0: print( "Can't find any Omniverse Apps. Use Omniverse Launcher to install one. 'Code' is the recommended app for developers." ) sys.exit(0) print("\nFound following Omniverse Apps:") for i, slug in enumerate(apps): name, root = apps[slug] print(f"{i}: {name} ({slug}) at: '{root}'") if args.app: selected_app = args.app.lower() if selected_app not in apps: choices = ", ".join(apps.keys()) print(f"Passed app: '{selected_app}' is not found. Specify one of the following found Apps: {choices}") sys.exit(0) else: selected_app = next((x for x in APP_PRIORITIES if x in apps), None) if not selected_app: selected_app = next(iter(apps)) print(f"\nSelected app: {selected_app}") _, path = apps[selected_app] if not os.path.exists(path): print(f"Provided path doesn't exist: {path}") else: SCRIPT_ROOT = os.path.dirname(os.path.realpath(__file__)) create_link(f"{SCRIPT_ROOT}/../../app", path) print("Success!")
mati-nvidia/developer-office-hours/tools/scripts/template/maticodes.doh_YYYY_MM_DD/maticodes/doh_YYYY_MM_DD/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext import omni.ui as ui class MyWindow(ui.Window): def __init__(self, title: str = None, **kwargs): super().__init__(title, **kwargs) self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("My Label") def clicked(): carb.log_info("Button Clicked!") ui.Button("Click Me", clicked_fn=clicked) class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_[DATE_UNDERSCORE]] Dev Office Hours Extension ([DATE_HYPHEN]) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_[DATE_UNDERSCORE]] Dev Office Hours Extension ([DATE_HYPHEN]) shutdown") if self._window: self._window.destroy() self._window = None
mati-nvidia/developer-office-hours/tools/scripts/template/maticodes.doh_YYYY_MM_DD/maticodes/doh_YYYY_MM_DD/__init__.py
# SPDX-License-Identifier: Apache-2.0 from .extension import *
mati-nvidia/developer-office-hours/tools/scripts/template/maticodes.doh_YYYY_MM_DD/scripts/my_script.py
# SPDX-License-Identifier: Apache-2.0
mati-nvidia/developer-office-hours/tools/scripts/template/maticodes.doh_YYYY_MM_DD/config/extension.toml
[package] # Semantic Versionning is used: https://semver.org/ version = "1.0.0" # The title and description fields are primarily for displaying extension info in UI title = "[DATE_HYPHEN]: Dev Office Hours" description="Sample code from the Dev Office Hour held on [DATE_HYPHEN]" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # One of categories for UI. category = "Example" # Keywords for the extension keywords = ["kit", "example"] # Use omni.ui to build simple UI [dependencies] "omni.kit.uiapp" = {} # Main python module this extension provides, it will be publicly available as "import maticodes.doh_[DATE_UNDERSCORE]". [[python.module]] name = "maticodes.doh_[DATE_UNDERSCORE]"
mati-nvidia/developer-office-hours/tools/scripts/template/maticodes.doh_YYYY_MM_DD/docs/README.md
# Developer Office Hour - [DATE_PRETTY] This is the sample code from the Developer Office Hour held on [DATE_PRETTY], Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - How do I do something? ...
mati-nvidia/developer-office-hours/tools/packman/python.sh
#!/bin/bash # Copyright 2019-2020 NVIDIA CORPORATION # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. set -e PACKMAN_CMD="$(dirname "${BASH_SOURCE}")/packman" if [ ! -f "$PACKMAN_CMD" ]; then PACKMAN_CMD="${PACKMAN_CMD}.sh" fi source "$PACKMAN_CMD" init export PYTHONPATH="${PM_MODULE_DIR}:${PYTHONPATH}" export PYTHONNOUSERSITE=1 # workaround for our python not shipping with certs if [[ -z ${SSL_CERT_DIR:-} ]]; then export SSL_CERT_DIR=/etc/ssl/certs/ fi "${PM_PYTHON}" -u "$@"
mati-nvidia/developer-office-hours/tools/packman/python.bat
:: Copyright 2019-2020 NVIDIA CORPORATION :: :: Licensed under the Apache License, Version 2.0 (the "License"); :: you may not use this file except in compliance with the License. :: You may obtain a copy of the License at :: :: http://www.apache.org/licenses/LICENSE-2.0 :: :: Unless required by applicable law or agreed to in writing, software :: distributed under the License is distributed on an "AS IS" BASIS, :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. :: See the License for the specific language governing permissions and :: limitations under the License. @echo off setlocal call "%~dp0\packman" init set "PYTHONPATH=%PM_MODULE_DIR%;%PYTHONPATH%" set PYTHONNOUSERSITE=1 "%PM_PYTHON%" -u %*
mati-nvidia/developer-office-hours/tools/packman/packman.cmd
:: Reset errorlevel status (don't inherit from caller) [xxxxxxxxxxx] @call :ECHO_AND_RESET_ERROR :: You can remove the call below if you do your own manual configuration of the dev machines call "%~dp0\bootstrap\configure.bat" if %errorlevel% neq 0 ( exit /b %errorlevel% ) :: Everything below is mandatory if not defined PM_PYTHON goto :PYTHON_ENV_ERROR if not defined PM_MODULE goto :MODULE_ENV_ERROR :: Generate temporary path for variable file for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile ^ -File "%~dp0bootstrap\generate_temp_file_name.ps1"') do set PM_VAR_PATH=%%a if %1.==. ( set PM_VAR_PATH_ARG= ) else ( set PM_VAR_PATH_ARG=--var-path="%PM_VAR_PATH%" ) "%PM_PYTHON%" -S -s -u -E "%PM_MODULE%" %* %PM_VAR_PATH_ARG% if %errorlevel% neq 0 ( exit /b %errorlevel% ) :: Marshall environment variables into the current environment if they have been generated and remove temporary file if exist "%PM_VAR_PATH%" ( for /F "usebackq tokens=*" %%A in ("%PM_VAR_PATH%") do set "%%A" ) if %errorlevel% neq 0 ( goto :VAR_ERROR ) if exist "%PM_VAR_PATH%" ( del /F "%PM_VAR_PATH%" ) if %errorlevel% neq 0 ( goto :VAR_ERROR ) set PM_VAR_PATH= goto :eof :: Subroutines below :PYTHON_ENV_ERROR @echo User environment variable PM_PYTHON is not set! Please configure machine for packman or call configure.bat. exit /b 1 :MODULE_ENV_ERROR @echo User environment variable PM_MODULE is not set! Please configure machine for packman or call configure.bat. exit /b 1 :VAR_ERROR @echo Error while processing and setting environment variables! exit /b 1 :ECHO_AND_RESET_ERROR @echo off if /I "%PM_VERBOSITY%"=="debug" ( @echo on ) exit /b 0
mati-nvidia/developer-office-hours/tools/packman/config.packman.xml
<config remotes="cloudfront"> <remote2 name="cloudfront"> <transport actions="download" protocol="https" packageLocation="d4i3qtqj3r0z5.cloudfront.net/${name}@${version}" /> </remote2> </config>
mati-nvidia/developer-office-hours/tools/packman/bootstrap/generate_temp_file_name.ps1
<# Copyright 2019 NVIDIA CORPORATION Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. #> $out = [System.IO.Path]::GetTempFileName() Write-Host $out # SIG # Begin signature block # MIIaVwYJKoZIhvcNAQcCoIIaSDCCGkQCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG # KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCAK+Ewup1N0/mdf # 1l4R58rxyumHgZvTmEhrYTb2Zf0zd6CCCiIwggTTMIIDu6ADAgECAhBi50XpIWUh # PJcfXEkK6hKlMA0GCSqGSIb3DQEBCwUAMIGEMQswCQYDVQQGEwJVUzEdMBsGA1UE # ChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0 # IE5ldHdvcmsxNTAzBgNVBAMTLFN5bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUg # U2lnbmluZyBDQSAtIEcyMB4XDTE4MDcwOTAwMDAwMFoXDTIxMDcwOTIzNTk1OVow # gYMxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRQwEgYDVQQHDAtT # YW50YSBDbGFyYTEbMBkGA1UECgwSTlZJRElBIENvcnBvcmF0aW9uMQ8wDQYDVQQL # DAZJVC1NSVMxGzAZBgNVBAMMEk5WSURJQSBDb3Jwb3JhdGlvbjCCASIwDQYJKoZI # hvcNAQEBBQADggEPADCCAQoCggEBALEZN63dA47T4i90jZ84CJ/aWUwVtLff8AyP # YspFfIZGdZYiMgdb8A5tBh7653y0G/LZL6CVUkgejcpvBU/Dl/52a+gSWy2qJ2bH # jMFMKCyQDhdpCAKMOUKSC9rfzm4cFeA9ct91LQCAait4LhLlZt/HF7aG+r0FgCZa # HJjJvE7KNY9G4AZXxjSt8CXS8/8NQMAN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K # EwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xMTAvBgNV # BAMTKERpZ2lDZXJ0IFNIQTIgQXNzdXJlZCBJRCBUaW1lc3RhbXBpbmcgQ0ECEA1C # SuC+Ooj/YEAhzhQA8N0wDQYJYIZIAWUDBAIBBQCggZgwGgYJKoZIhvcNAQkDMQ0G # CyqGSIb3DQEJEAEEMBwGCSqGSIb3DQEJBTEPFw0yMTA0MDgwOTExMDlaMCsGCyqG # SIb3DQEJEAIMMRwwGjAYMBYEFOHXgqjhkb7va8oWkbWqtJSmJJvzMC8GCSqGSIb3 # DQEJBDEiBCCHEAmNNj2zWjWYRfEi4FgzZvrI16kv/U2b9b3oHw6UVDANBgkqhkiG # 9w0BAQEFAASCAQCdefEKh6Qmwx7xGCkrYi/A+/Cla6LdnYJp38eMs3fqTTvjhyDw # HffXrwdqWy5/fgW3o3qJXqa5o7hLxYIoWSULOCpJRGdt+w7XKPAbZqHrN9elAhWJ # vpBTCEaj7dVxr1Ka4NsoPSYe0eidDBmmvGvp02J4Z1j8+ImQPKN6Hv/L8Ixaxe7V # mH4VtXIiBK8xXdi4wzO+A+qLtHEJXz3Gw8Bp3BNtlDGIUkIhVTM3Q1xcSEqhOLqo # PGdwCw9acxdXNWWPjOJkNH656Bvmkml+0p6MTGIeG4JCeRh1Wpqm1ZGSoEcXNaof # wOgj48YzI+dNqBD9i7RSWCqJr2ygYKRTxnuU # SIG # End signature block
mati-nvidia/developer-office-hours/tools/packman/bootstrap/configure.bat
:: Copyright 2019 NVIDIA CORPORATION :: :: Licensed under the Apache License, Version 2.0 (the "License"); :: you may not use this file except in compliance with the License. :: You may obtain a copy of the License at :: :: http://www.apache.org/licenses/LICENSE-2.0 :: :: Unless required by applicable law or agreed to in writing, software :: distributed under the License is distributed on an "AS IS" BASIS, :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. :: See the License for the specific language governing permissions and :: limitations under the License. set PM_PACKMAN_VERSION=6.33.2 :: Specify where packman command is rooted set PM_INSTALL_PATH=%~dp0.. :: The external root may already be configured and we should do minimal work in that case if defined PM_PACKAGES_ROOT goto ENSURE_DIR :: If the folder isn't set we assume that the best place for it is on the drive that we are currently :: running from set PM_DRIVE=%CD:~0,2% set PM_PACKAGES_ROOT=%PM_DRIVE%\packman-repo :: We use *setx* here so that the variable is persisted in the user environment echo Setting user environment variable PM_PACKAGES_ROOT to %PM_PACKAGES_ROOT% setx PM_PACKAGES_ROOT %PM_PACKAGES_ROOT% if %errorlevel% neq 0 ( goto ERROR ) :: The above doesn't work properly from a build step in VisualStudio because a separate process is :: spawned for it so it will be lost for subsequent compilation steps - VisualStudio must :: be launched from a new process. We catch this odd-ball case here: if defined PM_DISABLE_VS_WARNING goto ENSURE_DIR if not defined VSLANG goto ENSURE_DIR echo The above is a once-per-computer operation. Unfortunately VisualStudio cannot pick up environment change echo unless *VisualStudio is RELAUNCHED*. echo If you are launching VisualStudio from command line or command line utility make sure echo you have a fresh launch environment (relaunch the command line or utility). echo If you are using 'linkPath' and referring to packages via local folder links you can safely ignore this warning. echo You can disable this warning by setting the environment variable PM_DISABLE_VS_WARNING. echo. :: Check for the directory that we need. Note that mkdir will create any directories :: that may be needed in the path :ENSURE_DIR if not exist "%PM_PACKAGES_ROOT%" ( echo Creating directory %PM_PACKAGES_ROOT% mkdir "%PM_PACKAGES_ROOT%" ) if %errorlevel% neq 0 ( goto ERROR_MKDIR_PACKAGES_ROOT ) :: The Python interpreter may already be externally configured if defined PM_PYTHON_EXT ( set PM_PYTHON=%PM_PYTHON_EXT% goto PACKMAN ) set PM_PYTHON_VERSION=3.7.9-windows-x86_64 set PM_PYTHON_BASE_DIR=%PM_PACKAGES_ROOT%\python set PM_PYTHON_DIR=%PM_PYTHON_BASE_DIR%\%PM_PYTHON_VERSION% set PM_PYTHON=%PM_PYTHON_DIR%\python.exe if exist "%PM_PYTHON%" goto PACKMAN if not exist "%PM_PYTHON_BASE_DIR%" call :CREATE_PYTHON_BASE_DIR set PM_PYTHON_PACKAGE=python@%PM_PYTHON_VERSION%.cab for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_file_name.ps1"') do set TEMP_FILE_NAME=%%a set TARGET=%TEMP_FILE_NAME%.zip call "%~dp0fetch_file_from_packman_bootstrap.cmd" %PM_PYTHON_PACKAGE% "%TARGET%" if %errorlevel% neq 0 ( echo !!! Error fetching python from CDN !!! goto ERROR ) for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_folder.ps1" -parentPath "%PM_PYTHON_BASE_DIR%"') do set TEMP_FOLDER_NAME=%%a echo Unpacking Python interpreter ... "%SystemRoot%\system32\expand.exe" -F:* "%TARGET%" "%TEMP_FOLDER_NAME%" 1> nul del "%TARGET%" :: Failure during extraction to temp folder name, need to clean up and abort if %errorlevel% neq 0 ( echo !!! Error unpacking python !!! call :CLEAN_UP_TEMP_FOLDER goto ERROR ) :: If python has now been installed by a concurrent process we need to clean up and then continue if exist "%PM_PYTHON%" ( call :CLEAN_UP_TEMP_FOLDER goto PACKMAN ) else ( if exist "%PM_PYTHON_DIR%" ( rd /s /q "%PM_PYTHON_DIR%" > nul ) ) :: Perform atomic rename rename "%TEMP_FOLDER_NAME%" "%PM_PYTHON_VERSION%" 1> nul :: Failure during move, need to clean up and abort if %errorlevel% neq 0 ( echo !!! Error renaming python !!! call :CLEAN_UP_TEMP_FOLDER goto ERROR ) :PACKMAN :: The packman module may already be externally configured if defined PM_MODULE_DIR_EXT ( set PM_MODULE_DIR=%PM_MODULE_DIR_EXT% ) else ( set PM_MODULE_DIR=%PM_PACKAGES_ROOT%\packman-common\%PM_PACKMAN_VERSION% ) set PM_MODULE=%PM_MODULE_DIR%\packman.py if exist "%PM_MODULE%" goto ENSURE_7ZA set PM_MODULE_PACKAGE=packman-common@%PM_PACKMAN_VERSION%.zip for /f "delims=" %%a in ('powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0\generate_temp_file_name.ps1"') do set TEMP_FILE_NAME=%%a set TARGET=%TEMP_FILE_NAME% call "%~dp0fetch_file_from_packman_bootstrap.cmd" %PM_MODULE_PACKAGE% "%TARGET%" if %errorlevel% neq 0 ( echo !!! Error fetching packman from CDN !!! goto ERROR ) echo Unpacking ... "%PM_PYTHON%" -S -s -u -E "%~dp0\install_package.py" "%TARGET%" "%PM_MODULE_DIR%" if %errorlevel% neq 0 ( echo !!! Error unpacking packman !!! goto ERROR ) del "%TARGET%" :ENSURE_7ZA set PM_7Za_VERSION=16.02.4 set PM_7Za_PATH=%PM_PACKAGES_ROOT%\7za\%PM_7ZA_VERSION% if exist "%PM_7Za_PATH%" goto END set PM_7Za_PATH=%PM_PACKAGES_ROOT%\chk\7za\%PM_7ZA_VERSION% if exist "%PM_7Za_PATH%" goto END "%PM_PYTHON%" -S -s -u -E "%PM_MODULE%" pull "%PM_MODULE_DIR%\deps.packman.xml" if %errorlevel% neq 0 ( echo !!! Error fetching packman dependencies !!! goto ERROR ) goto END :ERROR_MKDIR_PACKAGES_ROOT echo Failed to automatically create packman packages repo at %PM_PACKAGES_ROOT%. echo Please set a location explicitly that packman has permission to write to, by issuing: echo. echo setx PM_PACKAGES_ROOT {path-you-choose-for-storing-packman-packages-locally} echo. echo Then launch a new command console for the changes to take effect and run packman command again. exit /B %errorlevel% :ERROR echo !!! Failure while configuring local machine :( !!! exit /B %errorlevel% :CLEAN_UP_TEMP_FOLDER rd /S /Q "%TEMP_FOLDER_NAME%" exit /B :CREATE_PYTHON_BASE_DIR :: We ignore errors and clean error state - if two processes create the directory one will fail which is fine md "%PM_PYTHON_BASE_DIR%" > nul 2>&1 exit /B 0 :END
mati-nvidia/developer-office-hours/tools/packman/bootstrap/fetch_file_from_packman_bootstrap.cmd
:: Copyright 2019 NVIDIA CORPORATION :: :: Licensed under the Apache License, Version 2.0 (the "License"); :: you may not use this file except in compliance with the License. :: You may obtain a copy of the License at :: :: http://www.apache.org/licenses/LICENSE-2.0 :: :: Unless required by applicable law or agreed to in writing, software :: distributed under the License is distributed on an "AS IS" BASIS, :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. :: See the License for the specific language governing permissions and :: limitations under the License. :: You need to specify <package-name> <target-path> as input to this command @setlocal @set PACKAGE_NAME=%1 @set TARGET_PATH=%2 @echo Fetching %PACKAGE_NAME% ... @powershell -ExecutionPolicy ByPass -NoLogo -NoProfile -File "%~dp0download_file_from_url.ps1" ^ -source "http://bootstrap.packman.nvidia.com/%PACKAGE_NAME%" -output %TARGET_PATH% :: A bug in powershell prevents the errorlevel code from being set when using the -File execution option :: We must therefore do our own failure analysis, basically make sure the file exists and is larger than 0 bytes: @if not exist %TARGET_PATH% goto ERROR_DOWNLOAD_FAILED @if %~z2==0 goto ERROR_DOWNLOAD_FAILED @endlocal @exit /b 0 :ERROR_DOWNLOAD_FAILED @echo Failed to download file from S3 @echo Most likely because endpoint cannot be reached or file %PACKAGE_NAME% doesn't exist @endlocal @exit /b 1
mati-nvidia/developer-office-hours/tools/packman/bootstrap/download_file_from_url.ps1
<# Copyright 2019 NVIDIA CORPORATION Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. #> param( [Parameter(Mandatory=$true)][string]$source=$null, [string]$output="out.exe" ) $filename = $output $triesLeft = 3 do { $triesLeft -= 1 try { Write-Host "Downloading from bootstrap.packman.nvidia.com ..." $wc = New-Object net.webclient $wc.Downloadfile($source, $fileName) $triesLeft = 0 } catch { Write-Host "Error downloading $source!" Write-Host $_.Exception|format-list -force } } while ($triesLeft -gt 0)
mati-nvidia/developer-office-hours/tools/packman/bootstrap/generate_temp_folder.ps1
<# Copyright 2019 NVIDIA CORPORATION Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. #> param( [Parameter(Mandatory=$true)][string]$parentPath=$null ) [string] $name = [System.Guid]::NewGuid() $out = Join-Path $parentPath $name New-Item -ItemType Directory -Path ($out) | Out-Null Write-Host $out # SIG # Begin signature block # MIIaVwYJKoZIhvcNAQcCoIIaSDCCGkQCAQExDzANBglghkgBZQMEAgEFADB5Bgor # BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG # KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCB29nsqMEu+VmSF # 7ckeVTPrEZ6hsXjOgPFlJm9ilgHUB6CCCiIwggTTMIIDu6ADAgECAhBi50XpIWUh # PJcfXEkK6hKlMA0GCSqGSIb3DQEBCwUAMIGEMQswCQYDVQQGEwJVUzEdMBsGA1UE # ChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xHzAdBgNVBAsTFlN5bWFudGVjIFRydXN0 # IE5ldHdvcmsxNTAzBgNVBAMTLFN5bWFudGVjIENsYXNzIDMgU0hBMjU2IENvZGUg # U2lnbmluZyBDQSAtIEcyMB4XDTE4MDcwOTAwMDAwMFoXDTIxMDcwOTIzNTk1OVow # gYMxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRQwEgYDVQQHDAtT # YW50YSBDbGFyYTEbMBkGA1UECgwSTlZJRElBIENvcnBvcmF0aW9uMQ8wDQYDVQQL # DAZJVC1NSVMxGzAZBgNVBAMMEk5WSURJQSBDb3Jwb3JhdGlvbjCCASIwDQYJKoZI # hvcNAQEBBQADggEPADCCAQoCggEBALEZN63dA47T4i90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GxuSh1t5ljhSKMYcp5lH5Z/IwP42+1ASa2bKXuh1Eh # 5Fhgm7oMLSttosR+u8QlK0cCCHxJrhO24XxCQijGGFbPQTS2Zl22dHv1VjMiLyI2 # skuiSpXY9aaOUjGCAk0wggJJAgEBMIGGMHIxCzAJBgNVBAYTAlVTMRUwEwYDVQQK # EwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5jb20xMTAvBgNV # BAMTKERpZ2lDZXJ0IFNIQTIgQXNzdXJlZCBJRCBUaW1lc3RhbXBpbmcgQ0ECEA1C # SuC+Ooj/YEAhzhQA8N0wDQYJYIZIAWUDBAIBBQCggZgwGgYJKoZIhvcNAQkDMQ0G # CyqGSIb3DQEJEAEEMBwGCSqGSIb3DQEJBTEPFw0yMTA0MDgwOTExMDlaMCsGCyqG # SIb3DQEJEAIMMRwwGjAYMBYEFOHXgqjhkb7va8oWkbWqtJSmJJvzMC8GCSqGSIb3 # DQEJBDEiBCDvFxQ6lYLr8vB+9czUl19rjCw1pWhhUXw/SqOmvIa/VDANBgkqhkiG # 9w0BAQEFAASCAQB9ox2UrcUXQsBI4Uycnhl4AMpvhVXJME62tygFMppW1l7QftDy # LvfPKRYm2YUioak/APxAS6geRKpeMkLvXuQS/Jlv0kY3BjxkeG0eVjvyjF4SvXbZ # 3JCk9m7wLNE+xqOo0ICjYlIJJgRLudjWkC5Skpb1NpPS8DOaIYwRV+AWaSOUPd9P # O5yVcnbl7OpK3EAEtwDrybCVBMPn2MGhAXybIHnth3+MFp1b6Blhz3WlReQyarjq # 1f+zaFB79rg6JswXoOTJhwICBP3hO2Ua3dMAswbfl+QNXF+igKLJPYnaeSVhBbm6 # VCu2io27t4ixqvoD0RuPObNX/P3oVA38afiM # SIG # End signature block
mati-nvidia/developer-office-hours/tools/packman/bootstrap/install_package.py
# Copyright 2019 NVIDIA CORPORATION # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # http://www.apache.org/licenses/LICENSE-2.0 # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import logging import zipfile import tempfile import sys import shutil __author__ = "hfannar" logging.basicConfig(level=logging.WARNING, format="%(message)s") logger = logging.getLogger("install_package") class TemporaryDirectory: def __init__(self): self.path = None def __enter__(self): self.path = tempfile.mkdtemp() return self.path def __exit__(self, type, value, traceback): # Remove temporary data created shutil.rmtree(self.path) def install_package(package_src_path, package_dst_path): with zipfile.ZipFile( package_src_path, allowZip64=True ) as zip_file, TemporaryDirectory() as temp_dir: zip_file.extractall(temp_dir) # Recursively copy (temp_dir will be automatically cleaned up on exit) try: # Recursive copy is needed because both package name and version folder could be missing in # target directory: shutil.copytree(temp_dir, package_dst_path) except OSError as exc: logger.warning( "Directory %s already present, packaged installation aborted" % package_dst_path ) else: logger.info("Package successfully installed to %s" % package_dst_path) install_package(sys.argv[1], sys.argv[2])
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_06/maticodes/doh_2023_01_06/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext import omni.ui as ui class MyWindow(ui.Window): def __init__(self, title: str = None, **kwargs): super().__init__(title, **kwargs) self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("My Label") def clicked(): carb.log_info("Button Clicked!") ui.Button("Click Me", clicked_fn=clicked) class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2023_01_06] Dev Office Hours Extension (2023-01-06) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2023_01_06] Dev Office Hours Extension (2023-01-06) shutdown") if self._window: self._window.destroy() self._window = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_06/maticodes/doh_2023_01_06/__init__.py
# SPDX-License-Identifier: Apache-2.0 from .extension import *
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_06/scripts/query_script_components.py
# SPDX-License-Identifier: Apache-2.0 from pxr import Sdf import omni.usd stage = omni.usd.get_context().get_stage() prim = stage.GetPrimAtPath("/World/Cube") attr = prim.GetAttribute("omni:scripting:scripts") if attr.IsValid(): scripts = attr.Get() if scripts: for script in scripts: print(script)
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_06/scripts/add_script_component.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.commands from pxr import Sdf import omni.usd omni.kit.commands.execute('ApplyScriptingAPICommand', paths=[Sdf.Path('/World/Cube')]) omni.kit.commands.execute('RefreshScriptingPropertyWindowCommand') stage = omni.usd.get_context().get_stage() prim = stage.GetPrimAtPath("/World/Cube") attr = prim.GetAttribute("omni:scripting:scripts") scripts = attr.Get() attr.Set([r"C:\Users\mcodesal\Downloads\new_script2.py"]) # attr.Set(["omniverse://localhost/Users/mcodesal/new_script2.py"]) omni.kit.commands.execute('ChangeProperty', prop_path=Sdf.Path('/World/Cube.omni:scripting:scripts'), value=Sdf.AssetPathArray(1, (Sdf.AssetPath('C:\\mcodesal\\Downloads\\new_script2.py'))), prev=None) attr = prim.GetAttribute("omni:scripting:scripts") scripts = list(attr.Get()) scripts.append(r"C:\mcodesal\Downloads\new_script.py") attr.Set(scripts)
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_06/scripts/interact_script_components.py
# SPDX-License-Identifier: Apache-2.0 import carb.events import omni.kit.app MY_CUSTOM_EVENT = carb.events.type_from_string("omni.my.extension.MY_CUSTOM_EVENT") bus = omni.kit.app.get_app().get_message_bus_event_stream() bus.push(MY_CUSTOM_EVENT, payload={"prim_path": "/World/Cube", "x": 1})
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_06/config/extension.toml
[package] # Semantic Versionning is used: https://semver.org/ version = "1.0.0" # The title and description fields are primarily for displaying extension info in UI title = "2023-01-06: Dev Office Hours" description="Sample code from the Dev Office Hour held on 2023-01-06" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # One of categories for UI. category = "Example" # Keywords for the extension keywords = ["kit", "example"] # Use omni.ui to build simple UI [dependencies] "omni.kit.uiapp" = {} # Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_01_06". [[python.module]] name = "maticodes.doh_2023_01_06"
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_06/docs/README.md
# Developer Office Hour - 01/06/2023 This is the sample code from the Developer Office Hour held on 01/06/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - 3:47 - How do you add an extension via the Extension Manager? - 8:48 - How do you programmatically add a Python Script to a prim? (Python Scripting Component) - 23:45 - How do you check what Python scripts a prim has? (Python Scripting Component) - 27:00 - How can you have your extension interact with a Python Scripting Component?
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_21/maticodes/doh_2023_04_21/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext import omni.ui as ui class MyWindow(ui.Window): def __init__(self, title: str = None, **kwargs): super().__init__(title, **kwargs) self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("My Label") def clicked(): carb.log_info("Button Clicked!") ui.Button("Click Me", clicked_fn=clicked) class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2023_04_21] Dev Office Hours Extension (2023-04-21) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2023_04_21] Dev Office Hours Extension (2023-04-21) shutdown") if self._window: self._window.destroy() self._window = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_21/maticodes/doh_2023_04_21/__init__.py
# SPDX-License-Identifier: Apache-2.0 from .extension import *
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_21/scripts/pass_arg_to_callback.py
# SPDX-License-Identifier: Apache-2.0 from functools import partial import omni.ui as ui def do_something(p1, p2): print(f"Hello {p1} {p2}") window = ui.Window("My Window", width=300, height=300) with window.frame: ui.Button("Click Me", clicked_fn=partial(do_something, "a", "b"))
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_21/scripts/create_mdl_mtl.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.commands omni.kit.commands.execute('CreateAndBindMdlMaterialFromLibrary', mdl_name='OmniPBR.mdl', mtl_name='OmniPBR', mtl_created_list=None)
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_21/scripts/lock_prim.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.commands from pxr import Sdf omni.kit.commands.execute('LockSpecs', spec_paths=['/Desk'], hierarchy=False)
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_21/config/extension.toml
[package] # Semantic Versionning is used: https://semver.org/ version = "1.0.0" # The title and description fields are primarily for displaying extension info in UI title = "2023-04-21: Dev Office Hours" description="Sample code from the Dev Office Hour held on 2023-04-21" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # One of categories for UI. category = "Example" # Keywords for the extension keywords = ["kit", "example"] # Use omni.ui to build simple UI [dependencies] "omni.kit.uiapp" = {} # Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_04_21". [[python.module]] name = "maticodes.doh_2023_04_21"
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_21/docs/README.md
# Developer Office Hour - 04/21/2023 This is the sample code from the Developer Office Hour held on 04/21/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - 2:02 - How do I change the label of an Action Graph UI button? - 17:29 - How do I style and Action Graph UI Button? - 30:36 - How do I pass extra parameters to a button's clicked_fn callback? - 40:00 - How do I programmatically Lock Selected for a prim? - 44:08 - How do I create an MDL material on a stage?
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_14/maticodes/doh_2023_04_14/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext import omni.ui as ui class MyWindow(ui.Window): def __init__(self, title: str = None, **kwargs): super().__init__(title, **kwargs) self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("My Label") def clicked(): carb.log_info("Button Clicked!") ui.Button("Click Me", clicked_fn=clicked) class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2023_04_14] Dev Office Hours Extension (2023-04-14) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2023_04_14] Dev Office Hours Extension (2023-04-14) shutdown") if self._window: self._window.destroy() self._window = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_14/maticodes/doh_2023_04_14/__init__.py
# SPDX-License-Identifier: Apache-2.0 from .extension import *
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_14/scripts/toggle_fullscreen.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.actions.core action_registry = omni.kit.actions.core.get_action_registry() action = action_registry.get_action("omni.kit.ui.editor_menu_bridge", "action_editor_menu_bridge_window_fullscreen_mode") action.execute()
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_14/scripts/move_prim_forward.py
# SPDX-License-Identifier: Apache-2.0 from pxr import Gf, UsdGeom, Usd import omni.usd stage = omni.usd.get_context().get_stage() prim = stage.GetPrimAtPath("/World/Camera") xform = UsdGeom.Xformable(prim) local_transformation: Gf.Matrix4d = xform.GetLocalTransformation() # Apply the local matrix to the start and end points of the camera's default forward vector (-Z) a: Gf.Vec4d = Gf.Vec4d(0,0,0,1) * local_transformation b: Gf.Vec4d = Gf.Vec4d(0,0,-1,1) * local_transformation # Get the vector between those two points to get the camera's current forward vector cam_fwd_vec = b-a # Convert to Vec3 and then normalize to get unit vector cam_fwd_unit_vec = Gf.Vec3d(cam_fwd_vec[:3]).GetNormalized() # Multiply the forward direction vector with how far forward you want to move forward_step = cam_fwd_unit_vec * 100 # Create a new matrix with the translation that you want to perform offset_mat = Gf.Matrix4d() offset_mat.SetTranslate(forward_step) # Apply the translation to the current local transform new_transform = local_transformation * offset_mat # Extract the new translation translate: Gf.Vec3d = new_transform.ExtractTranslation() # Update the attribute prim.GetAttribute("xformOp:translate").Set(translate)
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_14/scripts/execute_action.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.actions.core action_registry = omni.kit.actions.core.get_action_registry() action = action_registry.get_action("ext_id", "action_id") action.execute()
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_14/config/extension.toml
[package] # Semantic Versionning is used: https://semver.org/ version = "1.0.0" # The title and description fields are primarily for displaying extension info in UI title = "2023-04-14: Dev Office Hours" description="Sample code from the Dev Office Hour held on 2023-04-14" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # One of categories for UI. category = "Example" # Keywords for the extension keywords = ["kit", "example"] # Use omni.ui to build simple UI [dependencies] "omni.kit.uiapp" = {} # Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_04_14". [[python.module]] name = "maticodes.doh_2023_04_14"
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_14/docs/README.md
# Developer Office Hour - 04/14/2023 This is the sample code from the Developer Office Hour held on 04/14/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - How do I find and execute a Kit Action? - How do I programatically toggle fullscreen mode? - How do I move a prim in the forward direction?
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_13/graphs/swap_materials.usda
#usda 1.0 ( customLayerData = { dictionary cameraSettings = { dictionary Front = { double3 position = (0, 0, 50000) double radius = 500 } dictionary Perspective = { double3 position = (500, 500, 500) double3 target = (-0.00000397803842133726, 0.000007956076785831101, -0.000003978038307650422) } dictionary Right = { double3 position = (-50000, 0, 0) double radius = 500 } dictionary Top = { double3 position = (0, 50000, 0) double radius = 500 } string boundCamera = "/OmniverseKit_Persp" } dictionary omni_layer = { dictionary muteness = { } } dictionary renderSettings = { float3 "rtx:debugView:pixelDebug:textColor" = (0, 1e18, 0) float3 "rtx:dynamicDiffuseGI:probeCounts" = (6, 6, 6) float3 "rtx:dynamicDiffuseGI:probeGridOrigin" = (-210, -250, -10) float3 "rtx:dynamicDiffuseGI:volumeSize" = (600, 440, 300) int "rtx:externalFrameCounter" = 373484 float3 "rtx:fog:fogColor" = (0.75, 0.75, 0.75) float3 "rtx:lightspeed:material:overrideAlbedo" = (0.5, 0.5, 0.5) float3 "rtx:lightspeed:material:overrideEmissiveColor" = (0.5, 0.5, 0.5) float3 "rtx:post:backgroundZeroAlpha:backgroundDefaultColor" = (0, 0, 0) float3 "rtx:post:colorcorr:contrast" = (1, 1, 1) float3 "rtx:post:colorcorr:gain" = (1, 1, 1) float3 "rtx:post:colorcorr:gamma" = (1, 1, 1) float3 "rtx:post:colorcorr:offset" = (0, 0, 0) float3 "rtx:post:colorcorr:saturation" = (1, 1, 1) float3 "rtx:post:colorgrad:blackpoint" = (0, 0, 0) float3 "rtx:post:colorgrad:contrast" = (1, 1, 1) float3 "rtx:post:colorgrad:gain" = (1, 1, 1) float3 "rtx:post:colorgrad:gamma" = (1, 1, 1) float3 "rtx:post:colorgrad:lift" = (0, 0, 0) float3 "rtx:post:colorgrad:multiply" = (1, 1, 1) float3 "rtx:post:colorgrad:offset" = (0, 0, 0) float3 "rtx:post:colorgrad:whitepoint" = (1, 1, 1) float3 "rtx:post:lensDistortion:lensFocalLengthArray" = (10, 30, 50) float3 "rtx:post:lensFlares:anisoFlareFalloffX" = (450, 475, 500) float3 "rtx:post:lensFlares:anisoFlareFalloffY" = (10, 10, 10) float3 "rtx:post:lensFlares:cutoffPoint" = (2, 2, 2) float3 "rtx:post:lensFlares:haloFlareFalloff" = (10, 10, 10) float3 "rtx:post:lensFlares:haloFlareRadius" = (75, 75, 75) float3 "rtx:post:lensFlares:isotropicFlareFalloff" = (50, 50, 50) float3 "rtx:post:tonemap:whitepoint" = (1, 1, 1) float3 "rtx:raytracing:inscattering:singleScatteringAlbedo" = (0.9, 0.9, 0.9) float3 "rtx:raytracing:inscattering:transmittanceColor" = (0.5, 0.5, 0.5) float3 "rtx:sceneDb:ambientLightColor" = (0.1, 0.1, 0.1) } } defaultPrim = "World" endTimeCode = 100 metersPerUnit = 0.01 startTimeCode = 0 timeCodesPerSecond = 24 upAxis = "Y" ) def Xform "World" { def Mesh "Cube" { float3[] extent = [(-50, -50, -50), (50, 50, 50)] int[] faceVertexCounts = [4, 4, 4, 4, 4, 4] int[] faceVertexIndices = [0, 1, 3, 2, 0, 4, 5, 1, 1, 5, 6, 3, 2, 3, 6, 7, 0, 2, 7, 4, 4, 7, 6, 5] rel material:binding = </World/Looks/Ash_Planks> ( bindMaterialAs = "weakerThanDescendants" ) normal3f[] normals = [(0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, 0, -1), (0, 0, -1), (0, 0, -1), (0, 0, -1), (1, 0, 0), (1, 0, 0), (1, 0, 0), (1, 0, 0), (0, 0, 1), (0, 0, 1), (0, 0, 1), (0, 0, 1), (-1, 0, 0), (-1, 0, 0), (-1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0)] ( interpolation = "faceVarying" ) point3f[] points = [(-50, -50, -50), (50, -50, -50), (-50, -50, 50), (50, -50, 50), (-50, 50, -50), (50, 50, -50), (50, 50, 50), (-50, 50, 50)] bool primvars:doNotCastShadows = 0 float2[] primvars:st = [(1, 0), (0, 0), (0, 1), (1, 1), (1, 0), (1, 1), (0, 1), (0, 0), (1, 0), (0, 0), (0, 1), (1, 1), (1, 0), (0, 0), (0, 1), (1, 1), (1, 0), (1, 1), (0, 1), (0, 0), (1, 0), (1, 1), (0, 1), (0, 0)] ( interpolation = "faceVarying" ) uniform token subdivisionScheme = "none" double3 xformOp:rotateXYZ = (0, 0, 0) double3 xformOp:scale = (1, 1, 1) double3 xformOp:translate = (0, 0, 0) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] } def Scope "Looks" { def Material "Adobe_Octagon_Dots" { token outputs:mdl:displacement.connect = </World/Looks/Adobe_Octagon_Dots/Shader.outputs:out> token outputs:mdl:surface.connect = </World/Looks/Adobe_Octagon_Dots/Shader.outputs:out> token outputs:mdl:volume.connect = </World/Looks/Adobe_Octagon_Dots/Shader.outputs:out> def Shader "Shader" { reorder properties = ["inputs:diffuse_color_constant", "inputs:diffuse_texture", "inputs:albedo_desaturation", "inputs:albedo_add", "inputs:albedo_brightness", "inputs:diffuse_tint", "inputs:reflection_roughness_constant", "inputs:reflection_roughness_texture_influence", "inputs:reflectionroughness_texture", "inputs:metallic_constant", "inputs:metallic_texture_influence", "inputs:metallic_texture", "inputs:specular_level", "inputs:enable_ORM_texture", "inputs:ORM_texture", "inputs:ao_to_diffuse", "inputs:ao_texture", "inputs:enable_emission", "inputs:emissive_color", "inputs:emissive_color_texture", "inputs:emissive_mask_texture", "inputs:emissive_intensity", "inputs:enable_opacity", "inputs:opacity_texture", "inputs:opacity_constant", "inputs:enable_opacity_texture", "inputs:opacity_mode", "inputs:opacity_threshold", "inputs:bump_factor", "inputs:normalmap_texture", "inputs:detail_bump_factor", "inputs:detail_normalmap_texture", "inputs:flip_tangent_u", "inputs:flip_tangent_v", "inputs:project_uvw", "inputs:world_or_object", "inputs:uv_space_index", "inputs:texture_translate", "inputs:texture_rotate", "inputs:texture_scale", "inputs:detail_texture_translate", "inputs:detail_texture_rotate", "inputs:detail_texture_scale"] uniform token info:implementationSource = "sourceAsset" uniform asset info:mdl:sourceAsset = @http://omniverse-content-production.s3-us-west-2.amazonaws.com/Materials/Base/Stone/Adobe_Octagon_Dots.mdl@ uniform token info:mdl:sourceAsset:subIdentifier = "Adobe_Octagon_Dots" token outputs:out ( renderType = "material" ) } } def Material "Ash_Planks" { token outputs:mdl:displacement.connect = </World/Looks/Ash_Planks/Shader.outputs:out> token outputs:mdl:surface.connect = </World/Looks/Ash_Planks/Shader.outputs:out> token outputs:mdl:volume.connect = </World/Looks/Ash_Planks/Shader.outputs:out> def Shader "Shader" { reorder properties = ["inputs:diffuse_color_constant", "inputs:diffuse_texture", "inputs:albedo_desaturation", "inputs:albedo_add", "inputs:albedo_brightness", "inputs:diffuse_tint", "inputs:reflection_roughness_constant", "inputs:reflection_roughness_texture_influence", "inputs:reflectionroughness_texture", "inputs:metallic_constant", "inputs:metallic_texture_influence", "inputs:metallic_texture", "inputs:specular_level", "inputs:enable_ORM_texture", "inputs:ORM_texture", "inputs:ao_to_diffuse", "inputs:ao_texture", "inputs:enable_emission", "inputs:emissive_color", "inputs:emissive_color_texture", "inputs:emissive_mask_texture", "inputs:emissive_intensity", "inputs:enable_opacity", "inputs:opacity_texture", "inputs:opacity_constant", "inputs:enable_opacity_texture", "inputs:opacity_mode", "inputs:opacity_threshold", "inputs:bump_factor", "inputs:normalmap_texture", "inputs:detail_bump_factor", "inputs:detail_normalmap_texture", "inputs:flip_tangent_u", "inputs:flip_tangent_v", "inputs:project_uvw", "inputs:world_or_object", "inputs:uv_space_index", "inputs:texture_translate", "inputs:texture_rotate", "inputs:texture_scale", "inputs:detail_texture_translate", "inputs:detail_texture_rotate", "inputs:detail_texture_scale"] uniform token info:implementationSource = "sourceAsset" uniform asset info:mdl:sourceAsset = @http://omniverse-content-production.s3-us-west-2.amazonaws.com/Materials/Base/Wood/Ash_Planks.mdl@ uniform token info:mdl:sourceAsset:subIdentifier = "Ash_Planks" token outputs:out ( renderType = "material" ) } } def Material "Brick_Pavers" { token outputs:mdl:displacement.connect = </World/Looks/Brick_Pavers/Shader.outputs:out> token outputs:mdl:surface.connect = </World/Looks/Brick_Pavers/Shader.outputs:out> token outputs:mdl:volume.connect = </World/Looks/Brick_Pavers/Shader.outputs:out> def Shader "Shader" { reorder properties = ["inputs:diffuse_color_constant", "inputs:diffuse_texture", "inputs:albedo_desaturation", "inputs:albedo_add", "inputs:albedo_brightness", "inputs:diffuse_tint", "inputs:reflection_roughness_constant", "inputs:reflection_roughness_texture_influence", "inputs:reflectionroughness_texture", "inputs:metallic_constant", "inputs:metallic_texture_influence", "inputs:metallic_texture", "inputs:specular_level", "inputs:enable_ORM_texture", "inputs:ORM_texture", "inputs:ao_to_diffuse", "inputs:ao_texture", "inputs:enable_emission", "inputs:emissive_color", "inputs:emissive_color_texture", "inputs:emissive_mask_texture", "inputs:emissive_intensity", "inputs:enable_opacity", "inputs:opacity_texture", "inputs:opacity_constant", "inputs:enable_opacity_texture", "inputs:opacity_mode", "inputs:opacity_threshold", "inputs:bump_factor", "inputs:normalmap_texture", "inputs:detail_bump_factor", "inputs:detail_normalmap_texture", "inputs:flip_tangent_u", "inputs:flip_tangent_v", "inputs:project_uvw", "inputs:world_or_object", "inputs:uv_space_index", "inputs:texture_translate", "inputs:texture_rotate", "inputs:texture_scale", "inputs:detail_texture_translate", "inputs:detail_texture_rotate", "inputs:detail_texture_scale"] uniform token info:implementationSource = "sourceAsset" uniform asset info:mdl:sourceAsset = @http://omniverse-content-production.s3-us-west-2.amazonaws.com/Materials/Base/Masonry/Brick_Pavers.mdl@ uniform token info:mdl:sourceAsset:subIdentifier = "Brick_Pavers" token outputs:out ( renderType = "material" ) } } } def OmniGraph "ActionGraph_01" { token evaluationMode = "Automatic" token evaluator:type = "execution" token fabricCacheBacking = "Shared" int2 fileFormatVersion = (1, 5) custom int graph:variable:index = -1 ( customData = { token scope = "private" } displayName = "index" ) token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "write_prim_material" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom uint inputs:execIn prepend uint inputs:execIn.connect = </World/ActionGraph_01/on_keyboard_input.outputs:released> custom string inputs:materialPath = "" prepend string inputs:materialPath.connect = </World/ActionGraph_01/to_string.outputs:converted> custom string inputs:primPath = "" prepend string inputs:primPath.connect = </World/ActionGraph_01/constant_path.inputs:value> token node:type = "omni.graph.nodes.WritePrimMaterial" int node:typeVersion = 1 custom uint outputs:execOut ( customData = { bool isExecution = 1 } ) uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (1085.4962, 181.4497) } def OmniGraphNode "find_prims" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom token inputs:namePrefix custom bool inputs:recursive = 0 custom string inputs:requiredAttributes = "" custom token inputs:requiredRelationship custom string inputs:requiredRelationshipTarget = "" custom token inputs:rootPrimPath = "/World/Looks" custom token inputs:type token node:type = "omni.graph.nodes.FindPrims" int node:typeVersion = 1 custom token[] outputs:primPaths = [] uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (-412.52438, 451.18246) } def OmniGraphNode "on_keyboard_input" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom bool inputs:altIn = 0 custom bool inputs:ctrlIn = 0 custom token inputs:keyIn = "A" ( allowedTokens = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Apostrophe", "Backslash", "Backspace", "CapsLock", "Comma", "Del", "Down", "End", "Enter", "Equal", "Escape", "F1", "F10", "F11", "F12", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "GraveAccent", "Home", "Insert", "Key0", "Key1", "Key2", "Key3", "Key4", "Key5", "Key6", "Key7", "Key8", "Key9", "Left", "LeftAlt", "LeftBracket", "LeftControl", "LeftShift", "LeftSuper", "Menu", "Minus", "NumLock", "Numpad0", "Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9", "NumpadAdd", "NumpadDel", "NumpadDivide", "NumpadEnter", "NumpadEqual", "NumpadMultiply", "NumpadSubtract", "PageDown", "PageUp", "Pause", "Period", "PrintScreen", "Right", "RightAlt", "RightBracket", "RightControl", "RightShift", "RightSuper", "ScrollLock", "Semicolon", "Slash", "Space", "Tab", "Up"] ) custom bool inputs:onlyPlayback = 1 custom bool inputs:shiftIn = 0 token node:type = "omni.graph.action.OnKeyboardInput" int node:typeVersion = 3 custom bool outputs:isPressed custom token outputs:keyOut custom uint outputs:pressed ( customData = { bool isExecution = 1 } ) custom uint outputs:released ( customData = { bool isExecution = 1 } ) uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (59.739395, -163.04137) } def OmniGraphNode "array_index" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom token inputs:array prepend token inputs:array.connect = </World/ActionGraph_01/find_prims.outputs:primPaths> custom int inputs:index = 0 delete int inputs:index.connect = </World/ActionGraph_01/increment.outputs:result> prepend int inputs:index.connect = </World/ActionGraph_01/modulo.outputs:result> token node:type = "omni.graph.nodes.ArrayIndex" int node:typeVersion = 1 custom token outputs:value uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (334.78186, 436.3439) } def OmniGraphNode "to_string" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom token inputs:value delete token inputs:value.connect = </World/ActionGraph_01/find_prims.outputs:primPaths> prepend token inputs:value.connect = </World/ActionGraph_01/array_index.outputs:value> token node:type = "omni.graph.nodes.ToString" int node:typeVersion = 1 custom string outputs:converted uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (587.9523, 455.01645) } def OmniGraphNode "constant_path" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom string inputs:value = "/World/Cube" token node:type = "omni.graph.nodes.ConstantPath" int node:typeVersion = 1 uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (891.76935, 369.4709) } def OmniGraphNode "read_variable" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom rel inputs:graph = </World/ActionGraph_01> custom token inputs:targetPath custom token inputs:variableName = "index" token node:type = "omni.graph.core.ReadVariable" int node:typeVersion = 1 custom token outputs:value uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (-473.37006, 205.30212) } def OmniGraphNode "write_variable" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom uint inputs:execIn prepend uint inputs:execIn.connect = </World/ActionGraph_01/on_keyboard_input.outputs:released> custom rel inputs:graph = </World/ActionGraph_01> custom token inputs:targetPath custom token inputs:value delete token inputs:value.connect = [ </World/ActionGraph_01/increment.outputs:result>, </World/ActionGraph_01/modulo.outputs:result>, ] prepend token inputs:value.connect = </World/ActionGraph_01/modulo.outputs:result> custom token inputs:variableName = "index" token node:type = "omni.graph.core.WriteVariable" int node:typeVersion = 1 custom uint outputs:execOut ( customData = { bool isExecution = 1 } ) custom token outputs:value uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (622.69165, 201.77386) } def OmniGraphNode "increment" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom double inputs:increment = 1 custom token inputs:value prepend token inputs:value.connect = </World/ActionGraph_01/read_variable.outputs:value> token node:type = "omni.graph.nodes.Increment" int node:typeVersion = 1 custom token outputs:result uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (-268.92194, 176.62592) } def OmniGraphNode "modulo" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom token inputs:a prepend token inputs:a.connect = </World/ActionGraph_01/increment.outputs:result> custom token inputs:b delete token inputs:b.connect = </World/ActionGraph_01/increment.outputs:result> prepend token inputs:b.connect = </World/ActionGraph_01/array_get_size.outputs:size> token node:type = "omni.graph.nodes.Modulo" int node:typeVersion = 1 custom token outputs:result uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (110.01475, 302.82666) } def OmniGraphNode "array_get_size" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom token inputs:array prepend token inputs:array.connect = </World/ActionGraph_01/find_prims.outputs:primPaths> token node:type = "omni.graph.nodes.ArrayGetSize" int node:typeVersion = 1 custom int outputs:size uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (-148.30875, 386.24356) } } } def Xform "Environment" { double3 xformOp:rotateXYZ = (0, 0, 0) double3 xformOp:scale = (1, 1, 1) double3 xformOp:translate = (0, 0, 0) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] def DistantLight "defaultLight" ( prepend apiSchemas = ["ShapingAPI"] ) { float angle = 1 float intensity = 3000 float shaping:cone:angle = 180 float shaping:cone:softness float shaping:focus color3f shaping:focusTint asset shaping:ies:file double3 xformOp:rotateXYZ = (315, 0, 0) double3 xformOp:scale = (1, 1, 1) double3 xformOp:translate = (0, 0, 0) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] } }
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_13/maticodes/doh_2023_01_13/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext import omni.ui as ui class MyWindow(ui.Window): def __init__(self, title: str = None, **kwargs): super().__init__(title, **kwargs) self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("My Label") def clicked(): carb.log_info("Button Clicked!") ui.Button("Click Me", clicked_fn=clicked) class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2023_01_13] Dev Office Hours Extension (2023-01-13) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2023_01_13] Dev Office Hours Extension (2023-01-13) shutdown") if self._window: self._window.destroy() self._window = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_13/maticodes/doh_2023_01_13/__init__.py
# SPDX-License-Identifier: Apache-2.0 from .extension import *
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_13/scripts/add_script_component.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.commands from pxr import Sdf import omni.usd # Create the Python Scripting Component property omni.kit.commands.execute('ApplyScriptingAPICommand', paths=[Sdf.Path('/World/Cube')]) omni.kit.commands.execute('RefreshScriptingPropertyWindowCommand') # Add your script to the property stage = omni.usd.get_context().get_stage() prim = stage.GetPrimAtPath("/World/Cube") attr = prim.GetAttribute("omni:scripting:scripts") scripts = attr.Get() # Property with no script paths returns None if scripts is None: scripts = [] else: # Property with scripts paths returns VtArray. # Convert to list to make it easier to work with. scripts = list(scripts) scripts.append(r"C:\Users\mcodesal\Downloads\new_script.py") attr.Set(scripts)
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_13/config/extension.toml
[package] # Semantic Versionning is used: https://semver.org/ version = "1.0.0" # The title and description fields are primarily for displaying extension info in UI title = "2023-01-13: Dev Office Hours" description="Sample code from the Dev Office Hour held on 2023-01-13" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # One of categories for UI. category = "Example" # Keywords for the extension keywords = ["kit", "example"] # Use omni.ui to build simple UI [dependencies] "omni.kit.uiapp" = {} # Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_01_13". [[python.module]] name = "maticodes.doh_2023_01_13"
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_13/docs/README.md
# Developer Office Hour - 01/13/2023 This is the sample code from the Developer Office Hour held on 01/13/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - 3:46 - How do you programmatically add a Python Script to a prim? (Python Scripting Component) - 8:02 - What are the criteria for valid prim and property names in USD? - 11:14 - How can I swap a prim's material using Action Graph?
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_06_23/maticodes/doh_2023_06_23/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext import omni.ui as ui class MyWindow(ui.Window): def __init__(self, title: str = None, **kwargs): super().__init__(title, **kwargs) self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("My Label") def clicked(): carb.log_info("Button Clicked!") ui.Button("Click Me", clicked_fn=clicked) class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2023_06_23] Dev Office Hours Extension (2023-06-23) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2023_06_23] Dev Office Hours Extension (2023-06-23) shutdown") if self._window: self._window.destroy() self._window = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_06_23/maticodes/doh_2023_06_23/__init__.py
# SPDX-License-Identifier: Apache-2.0 from .extension import *
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_06_23/scripts/select_prims.py
# SPDX-License-Identifier: Apache-2.0 import omni.usd stage = omni.usd.get_context().get_stage() ctx = omni.usd.get_context() selection: omni.usd.Selection = ctx.get_selection() selection.set_selected_prim_paths(["/World/Cube", "/World/Sphere"], False) import omni.kit.commands import omni.usd ctx = omni.usd.get_context() selection: omni.usd.Selection = ctx.get_selection() omni.kit.commands.execute('SelectPrimsCommand', old_selected_paths=selection.get_selected_prim_paths(), new_selected_paths=["/World/Cone"], expand_in_stage=True)
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_06_23/config/extension.toml
[package] # Semantic Versionning is used: https://semver.org/ version = "1.0.0" # The title and description fields are primarily for displaying extension info in UI title = "2023-06-23: Dev Office Hours" description="Sample code from the Dev Office Hour held on 2023-06-23" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # One of categories for UI. category = "Example" # Keywords for the extension keywords = ["kit", "example"] # Use omni.ui to build simple UI [dependencies] "omni.kit.uiapp" = {} # Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_06_23". [[python.module]] name = "maticodes.doh_2023_06_23"
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_06_23/docs/README.md
# Developer Office Hour - 06/23/2023 This is the sample code from the Developer Office Hour held on 06/23/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - 03:50 - How do programmatically select a prim? - 16:00 - How do I reset the settings and preferences for a Kit app?
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_27/graphs/rotate_cube.usda
#usda 1.0 ( customLayerData = { dictionary cameraSettings = { dictionary Front = { double3 position = (0, 0, 50000) double radius = 500 } dictionary Perspective = { double3 position = (744.1314891741788, 370.53971652405943, 242.8346070647735) double3 target = (-0.0000013449548532662448, 0.00002425788107984772, -0.00003064792676354955) } dictionary Right = { double3 position = (-50000, 0, 0) double radius = 500 } dictionary Top = { double3 position = (0, 50000, 0) double radius = 500 } string boundCamera = "/OmniverseKit_Persp" } dictionary omni_layer = { dictionary muteness = { } } dictionary renderSettings = { float3 "rtx:debugView:pixelDebug:textColor" = (0, 1e18, 0) float3 "rtx:dynamicDiffuseGI:probeCounts" = (6, 6, 6) float3 "rtx:dynamicDiffuseGI:probeGridOrigin" = (-210, -250, -10) float3 "rtx:dynamicDiffuseGI:volumeSize" = (600, 440, 300) int "rtx:externalFrameCounter" = 232446 float3 "rtx:fog:fogColor" = (0.75, 0.75, 0.75) float3 "rtx:lightspeed:material:overrideAlbedo" = (0.5, 0.5, 0.5) float3 "rtx:lightspeed:material:overrideEmissiveColor" = (0.5, 0.5, 0.5) float3 "rtx:post:backgroundZeroAlpha:backgroundDefaultColor" = (0, 0, 0) float3 "rtx:post:colorcorr:contrast" = (1, 1, 1) float3 "rtx:post:colorcorr:gain" = (1, 1, 1) float3 "rtx:post:colorcorr:gamma" = (1, 1, 1) float3 "rtx:post:colorcorr:offset" = (0, 0, 0) float3 "rtx:post:colorcorr:saturation" = (1, 1, 1) float3 "rtx:post:colorgrad:blackpoint" = (0, 0, 0) float3 "rtx:post:colorgrad:contrast" = (1, 1, 1) float3 "rtx:post:colorgrad:gain" = (1, 1, 1) float3 "rtx:post:colorgrad:gamma" = (1, 1, 1) float3 "rtx:post:colorgrad:lift" = (0, 0, 0) float3 "rtx:post:colorgrad:multiply" = (1, 1, 1) float3 "rtx:post:colorgrad:offset" = (0, 0, 0) float3 "rtx:post:colorgrad:whitepoint" = (1, 1, 1) float3 "rtx:post:lensDistortion:lensFocalLengthArray" = (10, 30, 50) float3 "rtx:post:lensFlares:anisoFlareFalloffX" = (450, 475, 500) float3 "rtx:post:lensFlares:anisoFlareFalloffY" = (10, 10, 10) float3 "rtx:post:lensFlares:cutoffPoint" = (2, 2, 2) float3 "rtx:post:lensFlares:haloFlareFalloff" = (10, 10, 10) float3 "rtx:post:lensFlares:haloFlareRadius" = (75, 75, 75) float3 "rtx:post:lensFlares:isotropicFlareFalloff" = (50, 50, 50) float3 "rtx:post:tonemap:whitepoint" = (1, 1, 1) float3 "rtx:raytracing:inscattering:singleScatteringAlbedo" = (0.9, 0.9, 0.9) float3 "rtx:raytracing:inscattering:transmittanceColor" = (0.5, 0.5, 0.5) float3 "rtx:sceneDb:ambientLightColor" = (0.1, 0.1, 0.1) } } defaultPrim = "World" endTimeCode = 100 metersPerUnit = 0.01 startTimeCode = 0 timeCodesPerSecond = 24 upAxis = "Y" ) def Xform "World" { def OmniGraph "ActionGraph" { token evaluationMode = "Automatic" token evaluator:type = "execution" token fabricCacheBacking = "Shared" int2 fileFormatVersion = (1, 5) custom double graph:variable:Speed = 5 ( customData = { token scope = "private" } displayName = "Speed" ) token pipelineStage = "pipelineStageSimulation" def OmniGraphNode "on_tick" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom uint inputs:framePeriod = 0 custom bool inputs:onlyPlayback = 1 token node:type = "omni.graph.action.OnTick" int node:typeVersion = 1 custom double outputs:absoluteSimTime custom double outputs:deltaSeconds custom double outputs:frame custom bool outputs:isPlaying custom uint outputs:tick ( customData = { bool isExecution = 1 } ) custom double outputs:time custom double outputs:timeSinceStart uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (-62.488346, -44.434006) } def OmniGraphNode "break_3_vector" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom token inputs:tuple prepend token inputs:tuple.connect = </World/ActionGraph/CubeReadAttrib.outputs:value> token node:type = "omni.graph.nodes.BreakVector3" int node:typeVersion = 1 custom token outputs:x custom token outputs:y custom token outputs:z uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (289.55432, 238.81877) } def OmniGraphNode "add" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom token inputs:a prepend token inputs:a.connect = </World/ActionGraph/break_3_vector.outputs:y> custom token inputs:b delete token inputs:b.connect = [ </World/ActionGraph/read_variable.outputs:value>, </World/ActionGraph/constant_double.inputs:value>, ] prepend token inputs:b.connect = </World/ActionGraph/read_variable.outputs:value> token node:type = "omni.graph.nodes.Add" int node:typeVersion = 1 custom token outputs:sum uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (598.4194, 406.26178) } def OmniGraphNode "make_3_vector" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom token inputs:x prepend token inputs:x.connect = </World/ActionGraph/break_3_vector.outputs:x> custom token inputs:y prepend token inputs:y.connect = </World/ActionGraph/add.outputs:sum> custom token inputs:z prepend token inputs:z.connect = </World/ActionGraph/break_3_vector.outputs:z> token node:type = "omni.graph.nodes.MakeVector3" int node:typeVersion = 1 custom token outputs:tuple uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (899.36365, 221.84807) } def OmniGraphNode "read_variable" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom rel inputs:graph = </World/ActionGraph> custom token inputs:targetPath custom token inputs:variableName = "Speed" token node:type = "omni.graph.core.ReadVariable" int node:typeVersion = 1 custom token outputs:value uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (272.58438, 403.99854) } def OmniGraphNode "CubeReadAttrib" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom bool inputs:forceUSDRead = 0 custom token inputs:name = "xformOp:rotateXYZ" custom rel inputs:prim prepend rel inputs:prim = </World/Cube> custom token inputs:primPath custom timecode inputs:usdTimecode = -1 custom bool inputs:usePath = 0 token node:type = "omni.graph.nodes.ReadPrimAttribute" int node:typeVersion = 1 custom token outputs:value uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (-63.432808, 221.84807) } def OmniGraphNode "CubeWriteAttrib" ( prepend apiSchemas = ["NodeGraphNodeAPI"] ) { custom uint inputs:execIn prepend uint inputs:execIn.connect = </World/ActionGraph/on_tick.outputs:tick> custom token inputs:name = "xformOp:rotateXYZ" custom rel inputs:prim prepend rel inputs:prim = </World/Cube> custom token inputs:primPath custom bool inputs:usdWriteBack = 1 custom bool inputs:usePath = 0 custom token inputs:value prepend token inputs:value.connect = </World/ActionGraph/make_3_vector.outputs:tuple> token node:type = "omni.graph.nodes.WritePrimAttribute" int node:typeVersion = 1 custom uint outputs:execOut ( customData = { bool isExecution = 1 } ) uniform token ui:nodegraph:node:expansionState = "open" uniform float2 ui:nodegraph:node:pos = (1175.4186, 80.4267) } } def Mesh "Cube" { float3[] extent = [(-50, -50, -50), (50, 50, 50)] int[] faceVertexCounts = [4, 4, 4, 4, 4, 4] int[] faceVertexIndices = [0, 1, 3, 2, 0, 4, 5, 1, 1, 5, 6, 3, 2, 3, 6, 7, 0, 2, 7, 4, 4, 7, 6, 5] normal3f[] normals = [(0, -1, 0), (0, -1, 0), (0, -1, 0), (0, -1, 0), (0, 0, -1), (0, 0, -1), (0, 0, -1), (0, 0, -1), (1, 0, 0), (1, 0, 0), (1, 0, 0), (1, 0, 0), (0, 0, 1), (0, 0, 1), (0, 0, 1), (0, 0, 1), (-1, 0, 0), (-1, 0, 0), (-1, 0, 0), (-1, 0, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0), (0, 1, 0)] ( interpolation = "faceVarying" ) point3f[] points = [(-50, -50, -50), (50, -50, -50), (-50, -50, 50), (50, -50, 50), (-50, 50, -50), (50, 50, -50), (50, 50, 50), (-50, 50, 50)] float2[] primvars:st = [(1, 0), (0, 0), (0, 1), (1, 1), (1, 0), (1, 1), (0, 1), (0, 0), (1, 0), (0, 0), (0, 1), (1, 1), (1, 0), (0, 0), (0, 1), (1, 1), (1, 0), (1, 1), (0, 1), (0, 0), (1, 0), (1, 1), (0, 1), (0, 0)] ( interpolation = "faceVarying" ) uniform token subdivisionScheme = "none" double3 xformOp:rotateXYZ = (0, 3458, 0) double3 xformOp:scale = (1, 1, 1) double3 xformOp:translate = (0, 0, 0) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] } } def Xform "Environment" { double3 xformOp:rotateXYZ = (0, 0, 0) double3 xformOp:scale = (1, 1, 1) double3 xformOp:translate = (0, 0, 0) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] def DistantLight "defaultLight" ( prepend apiSchemas = ["ShapingAPI"] ) { float angle = 1 float intensity = 3000 float shaping:cone:angle = 180 float shaping:cone:softness float shaping:focus color3f shaping:focusTint asset shaping:ies:file double3 xformOp:rotateXYZ = (315, 0, 0) double3 xformOp:scale = (1, 1, 1) double3 xformOp:translate = (0, 0, 0) uniform token[] xformOpOrder = ["xformOp:translate", "xformOp:rotateXYZ", "xformOp:scale"] } }
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_27/maticodes/doh_2023_01_27/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext import omni.ui as ui class MyWindow(ui.Window): def __init__(self, title: str = None, **kwargs): super().__init__(title, **kwargs) self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("My Label") def clicked(): carb.log_info("Button Clicked!") ui.Button("Click Me", clicked_fn=clicked) class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2023_01_27] Dev Office Hours Extension (2023-01-27) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2023_01_27] Dev Office Hours Extension (2023-01-27) shutdown") if self._window: self._window.destroy() self._window = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_27/maticodes/doh_2023_01_27/__init__.py
# SPDX-License-Identifier: Apache-2.0 from .extension import *
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_27/scripts/sub_child_changes.py
# SPDX-License-Identifier: Apache-2.0 # UsdWatcher from pxr import Sdf, Tf, Usd import omni.usd stage = omni.usd.get_context().get_stage() def changed_paths(notice, stage): print("Change fired") for p in notice.GetChangedInfoOnlyPaths(): if str(p).startswith("/World/Parent" + "/"): print("Something happened to a descendent of /World/Parent") print(p) for p in notice.GetResyncedPaths(): if str(p).startswith("/World/Parent" + "/"): print("A descendent of /World/Parent was added or removed") print(p) objects_changed = Tf.Notice.Register(Usd.Notice.ObjectsChanged, changed_paths, None) objects_changed.Revoke()
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_27/config/extension.toml
[package] # Semantic Versionning is used: https://semver.org/ version = "1.0.0" # The title and description fields are primarily for displaying extension info in UI title = "2023-01-27: Dev Office Hours" description="Sample code from the Dev Office Hour held on 2023-01-27" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # One of categories for UI. category = "Example" # Keywords for the extension keywords = ["kit", "example"] # Use omni.ui to build simple UI [dependencies] "omni.kit.uiapp" = {} # Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_01_27". [[python.module]] name = "maticodes.doh_2023_01_27"
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_27/docs/README.md
# Developer Office Hour - 01/27/2023 This is the sample code from the Developer Office Hour held on 01/27/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - 3:14 - How do I listen for changes to the children of a certain prim? - 15:00 - How do I rotate a prim using Action Graph?
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/maticodes/doh_2022_07_22/extension.py
# SPDX-License-Identifier: Apache-2.0 import omni.ext import omni.ui as ui from omni.kit.widget.searchable_combobox import build_searchable_combo_widget class MyWindow(ui.Window): def __init__(self, title: str = None, delegate=None, **kwargs): super().__init__(title, **kwargs) self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("My Label") self.proj_scale_model = ui.SimpleFloatModel() self.proj_scale_model_sub = ( self.proj_scale_model.subscribe_value_changed_fn( self.slider_value_changed ) ) ui.FloatSlider(model=self.proj_scale_model, min=0, max=100) def do_rebuild(): self.frame.rebuild() ui.Button("Rebuild", clicked_fn=do_rebuild) def clicked(): # Example showing how to retreive the value from the model. print( f"Button Clicked! Slider Value: {self.proj_scale_model.as_float}" ) self.proj_scale_model.set_value(1.0) ui.Button("Set Slider", clicked_fn=clicked) def on_combo_click_fn(model): component = model.get_value_as_string() print(f"{component} selected") component_list = ["Synthetic Data", "USD", "Kit", "UX", "UX / UI"] component_index = -1 self._component_combo = build_searchable_combo_widget( component_list, component_index, on_combo_click_fn, widget_height=18, default_value="Kit", ) def slider_value_changed(self, model): # Example showing how to get the value when it changes. print("Slider Value:", model.as_float) def destroy(self) -> None: del self.proj_scale_model_sub return super().destroy() class MyExtension(omni.ext.IExt): # ext_id is current extension id. It can be used with extension manager to query additional information, like where # this extension is located on filesystem. def on_startup(self, ext_id): print( "[maticodes.doh_2022_07_22] Dev Office Hours Extension (2022-07-22) startup" ) self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): print( "[maticodes.doh_2022_07_22] Dev Office Hours Extension (2022-07-22) shutdown" ) if self._window: self._window.destroy() self._window = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/maticodes/doh_2022_07_22/__init__.py
# SPDX-License-Identifier: Apache-2.0 from .extension import *
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/scripts/cmds_more_params.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.commands from pxr import Gf, Usd omni.kit.commands.execute('SetAnimCurveKey', paths=['/World/toy_drummer.xformOp:translate'], value=Gf.Vec3d(0.0, 0.0, 18)) omni.kit.commands.execute('SetAnimCurveKey', paths=['/World/toy_drummer.xformOp:translate'], value=Gf.Vec3d(0.0, 0.0, 24), time=Usd.TimeCode(72))
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/scripts/set_current_time.py
# SPDX-License-Identifier: Apache-2.0 # https://docs.omniverse.nvidia.com/py/kit/source/extensions/omni.timeline/docs/index.html import omni.timeline timeline = omni.timeline.get_timeline_interface() # set in using seconds timeline.set_current_time(1) # set using frame number fps = timeline.get_time_codes_per_seconds() timeline.set_current_time(48 / fps)
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/scripts/reference_usdz.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.commands from pxr import Sdf import omni.usd omni.kit.commands.execute('CreateReference', path_to=Sdf.Path('/World/toy_drummer2'), asset_path='C:/Users/mcodesal/Downloads/toy_drummer.usdz', usd_context=omni.usd.get_context())
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/scripts/run_action_graph.py
# SPDX-License-Identifier: Apache-2.0 # https://docs.omniverse.nvidia.com/py/kit/source/extensions/omni.graph/docs/index.html import omni.graph.core as og keys = og.Controller.Keys og.Controller.edit("/World/ActionGraph", { keys.SET_VALUES: ("/World/ActionGraph/on_impulse_event.state:enableImpulse", True) })
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/config/extension.toml
[package] # Semantic Versionning is used: https://semver.org/ version = "1.0.0" # The title and description fields are primarily for displaying extension info in UI title = "2022-07-22: Dev Office Hours" description="Sample code from the Dev Office Hour held on 2022-07-22" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # One of categories for UI. category = "Example" # Keywords for the extension keywords = ["kit", "example"] # Use omni.ui to build simple UI [dependencies] "omni.kit.uiapp" = {} # Main python module this extension provides, it will be publicly available as "import maticodes.doh_2022_07_22". [[python.module]] name = "maticodes.doh_2022_07_22"
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_07_22/docs/README.md
# Developer Office Hour - 07/22/2022 This is the sample code from the Developer Office Hour held on 07/22/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - How do I reference a USDZ file? - How do I look up all of the parameters for a Kit Command? - How do I set the current frame using Python? - How do I execute an Action Graph using Python? - How do I align radio buttons horizontally? - How do I refresh a UI window? - How do I customize the appearance of a slider?
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_14/maticodes/doh_2022_10_14/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext import omni.ui as ui class MyWindow(ui.Window): def __init__(self, title: str = None, **kwargs): super().__init__(title, **kwargs) self.frame.set_build_fn(self._build_window) def _build_window(self): def hello(): print("Hello") ui.Button("Click Me", clicked_fn=hello) class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2022_10_14] Dev Office Hours Extension (2022-10-14) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2022_10_14] Dev Office Hours Extension (2022-10-14) shutdown") if self._window: self._window.destroy() self._window = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_14/maticodes/doh_2022_10_14/__init__.py
# SPDX-License-Identifier: Apache-2.0 from .extension import *
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_14/scripts/context_menu_inject.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.context_menu def show_menu(objects): print("show it?") return True def hello_world(objects): print(f"Hello Objects: {objects}") menu_item_config = { "name": "Hello World!", "glyph": "menu_search.svg", "show_fn": [show_menu], "onclick_fn": hello_world, } # You must keep a reference to the menu item. Set this variable to None to remove the item from the menu hello_world_menu_item = omni.kit.context_menu.add_menu(menu_item_config, "MENU", "omni.kit.window.viewport") hello_world_menu_item = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_14/config/extension.toml
[package] # Semantic Versionning is used: https://semver.org/ version = "1.0.0" # The title and description fields are primarily for displaying extension info in UI title = "2022-10-14: Dev Office Hours" description="Sample code from the Dev Office Hour held on 2022-10-14" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # One of categories for UI. category = "Example" # Keywords for the extension keywords = ["kit", "example"] # Use omni.ui to build simple UI [dependencies] "omni.kit.uiapp" = {} #"foo.bar" = {} # Main python module this extension provides, it will be publicly available as "import maticodes.doh_2022_10_14". [[python.module]] name = "maticodes.doh_2022_10_14"
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_14/docs/README.md
# Developer Office Hour - 10/14/2022 This is the sample code from the Developer Office Hour held on 10/14/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - Why doesn't OV Code start? - How do I inject my custom menu item into an existing context menu?
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_08_25/maticodes/doh_2023_08_25/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext import omni.ui as ui class MyWindow(ui.Window): def __init__(self, title: str = None, **kwargs): super().__init__(title, **kwargs) self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("My Label") def clicked(): carb.log_info("Button Clicked!") ui.Button("Click Me", clicked_fn=clicked) class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2023_08_25] Dev Office Hours Extension (2023-08-25) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2023_08_25] Dev Office Hours Extension (2023-08-25) shutdown") if self._window: self._window.destroy() self._window = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_08_25/maticodes/doh_2023_08_25/__init__.py
# SPDX-License-Identifier: Apache-2.0 from .extension import *
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_08_25/scripts/add_sbsar.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.commands omni.kit.commands.execute('AddSbsarReferenceAndBindCommand', sbsar_path=r"C:\Users\mcodesal\Downloads\blueberry_skin.sbsar", target_prim_path="/World/Sphere")
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_08_25/scripts/get_selected_meshes.py
# SPDX-License-Identifier: Apache-2.0 import omni.usd from pxr import Usd, UsdGeom stage = omni.usd.get_context().get_stage() selection = omni.usd.get_context().get_selection().get_selected_prim_paths() meshes = [] for path in selection: prim = stage.GetPrimAtPath(path) if prim.IsA(UsdGeom.Mesh): meshes.append(prim) print("Selected meshes:") print(meshes)
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_08_25/config/extension.toml
[package] # Semantic Versionning is used: https://semver.org/ version = "1.0.0" # The title and description fields are primarily for displaying extension info in UI title = "2023-08-25: Dev Office Hours" description="Sample code from the Dev Office Hour held on 2023-08-25" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # One of categories for UI. category = "Example" # Keywords for the extension keywords = ["kit", "example"] # Use omni.ui to build simple UI [dependencies] "omni.kit.uiapp" = {} # Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_08_25". [[python.module]] name = "maticodes.doh_2023_08_25"
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_08_25/docs/README.md
# Developer Office Hour - 08/25/2023 This is the sample code from the Developer Office Hour held on 08/25/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - 02:17 - How do I get just the mesh prims from my current selection? - 08:26 - How do I programmatically add an SBSAR material to my USD Stage?
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_28/maticodes/doh_2023_04_28/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext import omni.ui as ui class MyWindow(ui.Window): def __init__(self, title: str = None, **kwargs): super().__init__(title, **kwargs) self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("My Label") def clicked(): carb.log_info("Button Clicked!") ui.Button("Click Me", clicked_fn=clicked) class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2023_04_28] Dev Office Hours Extension (2023-04-28) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2023_04_28] Dev Office Hours Extension (2023-04-28) shutdown") if self._window: self._window.destroy() self._window = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_28/maticodes/doh_2023_04_28/__init__.py
# SPDX-License-Identifier: Apache-2.0 from .extension import *
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_28/scripts/toggle_hud.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.viewport.utility as okvu okvu.toggle_global_visibility()
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_28/scripts/custom_attrs.py
# SPDX-License-Identifier: Apache-2.0 # Docs: https://docs.omniverse.nvidia.com/prod_kit/prod_kit/programmer_ref/usd/properties/create-attribute.html import omni.usd from pxr import Usd, Sdf stage = omni.usd.get_context().get_stage() prim: Usd.Prim = stage.GetPrimAtPath("/World/Cylinder") attr: Usd.Attribute = prim.CreateAttribute("mySecondAttr", Sdf.ValueTypeNames.Bool) attr.Set(False)
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_28/scripts/custom_global_data.py
# SPDX-License-Identifier: Apache-2.0 import omni.usd stage = omni.usd.get_context().get_stage() layer = stage.GetRootLayer() print(type(layer)) layer.SetCustomLayerData({"Hello": "World"}) stage.DefinePrim("/World/Hello", "HelloWorld") stage.DefinePrim("/World/MyTypeless")
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_28/scripts/make_unselectable.py
# SPDX-License-Identifier: Apache-2.0 # Docs: https://docs.omniverse.nvidia.com/kit/docs/omni.usd/latest/omni.usd/omni.usd.UsdContext.html#omni.usd.UsdContext.set_pickable import omni.usd ctx = omni.usd.get_context() ctx.set_pickable("/", True)
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_28/scripts/change_viewport_camera.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.viewport.utility as vu from pxr import Sdf vp_api = vu.get_active_viewport() vp_api.camera_path = "/World/Camera_01"
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_28/config/extension.toml
[package] # Semantic Versionning is used: https://semver.org/ version = "1.0.0" # The title and description fields are primarily for displaying extension info in UI title = "2023-04-28: Dev Office Hours" description="Sample code from the Dev Office Hour held on 2023-04-28" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # One of categories for UI. category = "Example" # Keywords for the extension keywords = ["kit", "example"] # Use omni.ui to build simple UI [dependencies] "omni.kit.uiapp" = {} # Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_04_28". [[python.module]] name = "maticodes.doh_2023_04_28"
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_28/docs/README.md
# Developer Office Hour - 04/28/2023 This is the sample code from the Developer Office Hour held on 04/28/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - 02:18 - How do I make a prim unselectable in the viewport? - 07:50 - How do I create custom properties? - 26:00 - Can I write custom components for prims link in Unity? - 50:21 - How can I toggle the stats heads up display on the viewport? - 66:00 - How can you switch cameras on the active viewport?
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_09_01/maticodes/doh_2023_09_01/extension.py
# SPDX-License-Identifier: Apache-2.0 import subprocess import carb import omni.ext import omni.ui as ui class MyWindow(ui.Window): def __init__(self, title: str = None, **kwargs): super().__init__(title, **kwargs) self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("My Label") def clicked(): carb.log_info("Button Clicked!") result = subprocess.check_output(["python", "-c", "print('Hello World')"]) print(result.decode()) ui.Button("Click Me", clicked_fn=clicked) class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2023_09_01] Dev Office Hours Extension (2023-09-01) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2023_09_01] Dev Office Hours Extension (2023-09-01) shutdown") if self._window: self._window.destroy() self._window = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_09_01/maticodes/doh_2023_09_01/__init__.py
# SPDX-License-Identifier: Apache-2.0 from .extension import *
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_09_01/scripts/logging.py
# SPDX-License-Identifier: Apache-2.0 import logging import carb logger = logging.getLogger() print("Hello") carb.log_info("World") logger.info("Omniverse")
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_09_01/scripts/xforming.py
# SPDX-License-Identifier: Apache-2.0 from pxr import UsdGeom import omni.usd stage = omni.usd.get_context().get_stage() cube = stage.GetPrimAtPath("/World/Xform/Cube") cube_xformable = UsdGeom.Xformable(cube) transform = cube_xformable.GetLocalTransformation() print(transform) transform2 = cube_xformable.GetLocalTransformation() print(transform2)
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_09_01/config/extension.toml
[package] # Semantic Versionning is used: https://semver.org/ version = "1.0.0" # The title and description fields are primarily for displaying extension info in UI title = "2023-09-01: Dev Office Hours" description="Sample code from the Dev Office Hour held on 2023-09-01" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # One of categories for UI. category = "Example" # Keywords for the extension keywords = ["kit", "example"] # Use omni.ui to build simple UI [dependencies] "omni.kit.uiapp" = {} # Main python module this extension provides, it will be publicly available as "import maticodes.doh_2023_09_01". [[python.module]] name = "maticodes.doh_2023_09_01"
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_09_01/docs/README.md
# Developer Office Hour - 09/01/2023 This is the sample code from the Developer Office Hour held on 09/01/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - 7:27 - How do I validate my assets to make sure they are up-to-date with the latest USD specification?
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_28/maticodes/doh_2022_10_28/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext import omni.ui as ui class MyWindow(ui.Window): def __init__(self, title: str = None, **kwargs): super().__init__(title, **kwargs) self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("My Label") def clicked(): carb.log_info("Button Clicked!") ui.Button("Click Me", clicked_fn=clicked) class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2022_10_28] Dev Office Hours Extension (2022-10-28) startup") self._window = MyWindow("MyWindow", width=300, height=300) import omni.kit.commands omni.kit.commands.execute('CreateMeshPrimWithDefaultXform', prim_type='Cone') from pxr import UsdGeom stage = omni.usd.get_context().get_stage() sphere = UsdGeom.Sphere.Define(stage, "/World/MySphere") def on_shutdown(self): carb.log_info("[maticodes.doh_2022_10_28] Dev Office Hours Extension (2022-10-28) shutdown") if self._window: self._window.destroy() self._window = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_28/maticodes/doh_2022_10_28/__init__.py
# SPDX-License-Identifier: Apache-2.0 from .extension import *
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_28/scripts/usd_watcher.py
# SPDX-License-Identifier: Apache-2.0 import omni.usd from pxr import Gf stage = omni.usd.get_context().get_stage() cube = stage.GetPrimAtPath("/World/Cube") def print_size(changed_path): print("Size Changed:", changed_path) def print_pos(changed_path): print(changed_path) if changed_path.IsPrimPath(): prim_path = changed_path else: prim_path = changed_path.GetPrimPath() prim = stage.GetPrimAtPath(prim_path) local_transform = omni.usd.get_local_transform_SRT(prim) print("Translation: ", local_transform[3]) def print_world_pos(changed_path): world_transform: Gf.Matrix4d = omni.usd.get_world_transform_matrix(prim) translation: Gf.Vec3d = world_transform.ExtractTranslation() print(translation) size_attr = cube.GetAttribute("size") cube_sub = omni.usd.get_watcher().subscribe_to_change_info_path(cube.GetPath(), print_world_pos) cube_size_sub = omni.usd.get_watcher().subscribe_to_change_info_path(size_attr.GetPath(), print_size) cube_sub = None cube_size_sub = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_28/scripts/extras.py
# SPDX-License-Identifier: Apache-2.0 import omni.usd stage = omni.usd.get_context().get_stage() prim = stage.GetPrimAtPath("/World/Cube") if prim: print("Prim Exists") from pxr import UsdGeom # e.g., find all prims of type UsdGeom.Mesh mesh_prims = [x for x in stage.Traverse() if x.IsA(UsdGeom.Mesh)] mesh_prims = [] for x in stage.Traverse(): if x.IsA(UsdGeom.Mesh): mesh_prims.append(x) print(mesh_prims)
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_28/scripts/docking.py
# SPDX-License-Identifier: Apache-2.0 import omni.ui as ui my_window = ui.Window("Example Window", width=300, height=300) with my_window.frame: with ui.VStack(): f = ui.FloatField() def clicked(f=f): print("clicked") f.model.set_value(f.model.get_value_as_float() + 1) ui.Button("Plus One", clicked_fn=clicked) my_window.dock_in_window("Property", ui.DockPosition.SAME) ui.dock_window_in_window(my_window.title, "Property", ui.DockPosition.RIGHT, 0.2) my_window.deferred_dock_in("Content", ui.DockPolicy.TARGET_WINDOW_IS_ACTIVE)
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_28/config/extension.toml
[package] # Semantic Versionning is used: https://semver.org/ version = "1.0.0" # The title and description fields are primarily for displaying extension info in UI title = "2022-10-28: Dev Office Hours" description="Sample code from the Dev Office Hour held on 2022-10-28" # Path (relative to the root) or content of readme markdown file for UI. readme = "docs/README.md" # URL of the extension source repository. repository = "" # One of categories for UI. category = "Example" # Keywords for the extension keywords = ["kit", "example"] # Use omni.ui to build simple UI [dependencies] "omni.kit.uiapp" = {} # Main python module this extension provides, it will be publicly available as "import maticodes.doh_2022_10_28". [[python.module]] name = "maticodes.doh_2022_10_28"
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_28/docs/README.md
# Developer Office Hour - 10/28/2022 This is the sample code from the Developer Office Hour held on 10/28/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - How do I dock my window? - How do I subscribe to changes to a prim or attribute? (omni.usd.get_watcher())
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_23/maticodes/doh_2022_09_23/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext import omni.ui as ui class MyWindow(ui.Window): def __init__(self, title: str = None, **kwargs): super().__init__(title, **kwargs) self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("My Label") def clicked(): carb.log_info("Button Clicked!") ui.Button("Click Me", clicked_fn=clicked) class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2022_09_23] Dev Office Hours Extension (2022-09-23) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2022_09_23] Dev Office Hours Extension (2022-09-23) shutdown") if self._window: self._window.destroy() self._window = None
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_23/maticodes/doh_2022_09_23/__init__.py
# SPDX-License-Identifier: Apache-2.0 from .extension import *
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_23/scripts/combobox_selected_item.py
# SPDX-License-Identifier: Apache-2.0 import omni.ui as ui my_window = ui.Window("Example Window", width=300, height=300) combo_sub = None options = ["One", "Two", "Three"] with my_window.frame: with ui.VStack(): combo_model: ui.AbstractItemModel = ui.ComboBox(0, *options).model def combo_changed(item_model: ui.AbstractItemModel, item: ui.AbstractItem): value_model = item_model.get_item_value_model(item) current_index = value_model.as_int option = options[current_index] print(f"Selected '{option}' at index {current_index}.") combo_sub = combo_model.subscribe_item_changed_fn(combo_changed) def clicked(): value_model = combo_model.get_item_value_model() current_index = value_model.as_int option = options[current_index] print(f"Button Clicked! Selected '{option}' at index {current_index}.") ui.Button("Print Combo Selection", clicked_fn=clicked)