file_path
stringlengths
20
202
content
stringlengths
9
3.85M
size
int64
9
3.85M
lang
stringclasses
9 values
avg_line_length
float64
3.33
100
max_line_length
int64
8
993
alphanum_fraction
float64
0.26
0.93
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")
164
Python
9.999999
37
0.72561
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)
355
Python
21.249999
52
0.785915
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?
352
Markdown
49.428564
114
0.775568
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
1,040
Python
31.531249
101
0.714423
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)
432
Python
23.055554
65
0.685185
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)
548
Python
26.449999
81
0.717153
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())
355
Markdown
43.499995
114
0.76338
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)
1,009
Python
35.071427
83
0.634291
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_23/scripts/use_tokens.py
# SPDX-License-Identifier: Apache-2.0 # https://docs.omniverse.nvidia.com/py/kit/docs/guide/tokens.html import carb.tokens from pathlib import Path path = Path("${shared_documents}") / "maticodes.foo" resolved_path = carb.tokens.get_tokens_interface().resolve(str(path)) print(resolved_path)
293
Python
31.666663
69
0.761092
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_23/scripts/simple_instancer.py
# SPDX-License-Identifier: Apache-2.0 import omni.usd from pxr import Usd, UsdGeom, Sdf, Gf stage: Usd.Stage = omni.usd.get_context().get_stage() prim_path = Sdf.Path("/World/MyInstancer") instancer: UsdGeom.PointInstancer = UsdGeom.PointInstancer.Define(stage, prim_path) proto_container = UsdGeom.Scope.Define(stage, prim_path.AppendPath("Prototypes")) shapes = [] shapes.append(UsdGeom.Cube.Define(stage, proto_container.GetPath().AppendPath("Cube"))) shapes.append(UsdGeom.Sphere.Define(stage, proto_container.GetPath().AppendPath("Sphere"))) shapes.append(UsdGeom.Cone.Define(stage, proto_container.GetPath().AppendPath("Cone"))) instancer.CreatePositionsAttr([Gf.Vec3f(0, 0, 0), Gf.Vec3f(2, 0, 0), Gf.Vec3f(4, 0, 0)]) instancer.CreatePrototypesRel().SetTargets([shape.GetPath() for shape in shapes]) instancer.CreateProtoIndicesAttr([0, 1, 2])
852
Python
49.176468
91
0.761737
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_23/scripts/one_widget_in_container.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(): with ui.CollapsableFrame(): with ui.VStack(): ui.FloatField() ui.FloatField() ui.Button("Button 1")
328
Python
24.30769
62
0.588415
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_23/docs/README.md
# Developer Office Hour - 09/23/2022 This is the sample code from the Developer Office Hour held on 09/23/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - How do I query the selected item in a ui.ComboBox? - How do I use Kit tokens? - Why do I only see one widget in my UI container?
378
Markdown
41.111107
114
0.761905
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_09/maticodes/doh_2022_09_09/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext import omni.kit.commands import omni.ui as ui import omni.usd from pxr import Gf, Sdf # Check out: USDColorModel # C:\ext_projects\omni-dev-office-hours\app\kit\exts\omni.example.ui\omni\example\ui\scripts\colorwidget_doc.py class MyWindow(ui.Window): def __init__(self, title: str = None, **kwargs): super().__init__(title, **kwargs) self._color_model = None self._color_changed_subs = [] self._path_model = None self._change_info_path_subscription = None self._path_changed_sub = None self._stage = omni.usd.get_context().get_stage() self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("Property Path") self._path_model = ui.StringField().model self._path_changed_sub = self._path_model.subscribe_value_changed_fn( self._on_path_changed ) ui.Label("Color") with ui.HStack(spacing=5): self._color_model = ui.ColorWidget(width=0, height=0).model for item in self._color_model.get_item_children(): component = self._color_model.get_item_value_model(item) self._color_changed_subs.append(component.subscribe_value_changed_fn(self._on_color_changed)) ui.FloatField(component) def _on_mtl_attr_changed(self, path): color_attr = self._stage.GetAttributeAtPath(path) color_model_items = self._color_model.get_item_children() if color_attr: color = color_attr.Get() for i in range(len(color)): component = self._color_model.get_item_value_model(color_model_items[i]) component.set_value(color[i]) def _on_path_changed(self, model): if Sdf.Path.IsValidPathString(model.as_string): attr_path = Sdf.Path(model.as_string) color_attr = self._stage.GetAttributeAtPath(attr_path) if color_attr: self._change_info_path_subscription = omni.usd.get_watcher().subscribe_to_change_info_path( attr_path, self._on_mtl_attr_changed ) def _on_color_changed(self, model): values = [] for item in self._color_model.get_item_children(): component = self._color_model.get_item_value_model(item) values.append(component.as_float) if Sdf.Path.IsValidPathString(self._path_model.as_string): attr_path = Sdf.Path(self._path_model.as_string) color_attr = self._stage.GetAttributeAtPath(attr_path) if color_attr: color_attr.Set(Gf.Vec3f(*values[0:3])) def destroy(self) -> None: self._change_info_path_subscription = None self._color_changed_subs = None self._path_changed_sub = None return super().destroy() class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2022_09_09] Dev Office Hours Extension (2022-09-09) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2022_09_09] Dev Office Hours Extension (2022-09-09) shutdown") if self._window: self._window.destroy() self._window = None
3,584
Python
39.738636
117
0.588728
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_09/scripts/undo_group.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.commands import omni.kit.undo # Requires Ctrl+Z twice to undo omni.kit.commands.execute('CreateMeshPrimWithDefaultXform', prim_type='Cube') omni.kit.commands.execute('CreateMeshPrimWithDefaultXform', prim_type='Cube') # Grouped into one undo with omni.kit.undo.group(): omni.kit.commands.execute('CreateMeshPrimWithDefaultXform', prim_type='Cube') omni.kit.commands.execute('CreateMeshPrimWithDefaultXform', prim_type='Cube')
506
Python
27.166665
63
0.76087
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_09/scripts/skip_undo_history.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.commands import omni.kit.primitive.mesh as mesh_cmds # Creates history omni.kit.commands.execute('CreateMeshPrimWithDefaultXform', prim_type='Cube') # Doesn't create history mesh_cmds.CreateMeshPrimWithDefaultXformCommand("Cube").do()
293
Python
23.499998
60
0.798635
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_09/docs/README.md
# Developer Office Hour - 09/09/2022 This is the sample code from the Developer Office Hour held on 09/09/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - How do I connect a ColorWidget to the base color of a material at a specific path? - How do I create an undo group? - How do I avoid adding a command to the undo history?
420
Markdown
45.777773
114
0.769048
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_08_18/maticodes/doh_2023_08_18/extension.py
# SPDX-License-Identifier: Apache-2.0 import asyncio from pathlib import Path import carb import omni.ext import omni.ui as ui import omni.usd test_stage_path = Path(__file__).parent.parent.parent / "data" / "test_stage.usd" 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(test_stage_path) # Synch option # omni.usd.get_context().open_stage(str(test_stage_path)) # Async Option # asyncio.ensure_future(self.open_stage()) # Async with Callback omni.usd.get_context().open_stage_with_callback(str(test_stage_path), self.on_stage_open_finished) ui.Button("Click Me", clicked_fn=clicked) async def open_stage(self): (result, error) = await omni.usd.get_context().open_stage_async(str(test_stage_path)) #Now that we've waited for the scene to open, we should be able to get the stage stage = omni.usd.get_context().get_stage() print (f"opened stage {stage} with result {result}") def on_stage_open_finished(self, result: bool, path: str): stage = omni.usd.get_context().get_stage() print (f"opened stage {stage} with result {result}") class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2023_08_18] Dev Office Hours Extension (2023-08-18) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2023_08_18] Dev Office Hours Extension (2023-08-18) shutdown") if self._window: self._window.destroy() self._window = None
2,025
Python
33.931034
118
0.599506
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_08_18/docs/README.md
# Developer Office Hour - 08/18/2023 This is the sample code from the Developer Office Hour held on 08/18/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - 02:16 - How do I programmatically open a Stage in Kit?
304
Markdown
42.571422
114
0.773026
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_26/maticodes/doh_2022_08_26/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2022_08_26] Dev Office Hours Extension (2022-08-26) startup") def on_shutdown(self): carb.log_info("[maticodes.doh_2022_08_26] Dev Office Hours Extension (2022-08-26) shutdown")
366
Python
27.230767
100
0.699454
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_26/maticodes/doh_2022_08_26/math.py
# SPDX-License-Identifier: Apache-2.0 def add(a, b): return a + b
71
Python
16.999996
37
0.633803
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_26/scripts/get_world_pos.py
# SPDX-License-Identifier: Apache-2.0 import omni.usd from pxr import Usd, Gf stage = omni.usd.get_context().get_stage() prim = stage.GetPrimAtPath("/World/Xform/Cube") matrix:Gf.Matrix4d = omni.usd.get_world_transform_matrix(prim, time_code=Usd.TimeCode.Default()) translation = matrix.ExtractTranslation() print(translation)
328
Python
31.899997
96
0.771341
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_26/scripts/mouse_cursor_shape.py
# SPDX-License-Identifier: Apache-2.0 #################################### # MUST ENABLE omni.kit.window.cursor #################################### import carb import omni.kit.window.cursor cursor = omni.kit.window.cursor.get_main_window_cursor() # OPTIONS: # carb.windowing.CursorStandardShape.ARROW # carb.windowing.CursorStandardShape.IBEAM # carb.windowing.CursorStandardShape.VERTICAL_RESIZE # carb.windowing.CursorStandardShape.HORIZONTAL_RESIZE # carb.windowing.CursorStandardShape.HAND # carb.windowing.CursorStandardShape.CROSSHAIR cursor.override_cursor_shape(carb.windowing.CursorStandardShape.CROSSHAIR) # clear back to arrow cursor.clear_overridden_cursor_shape()
681
Python
31.476189
74
0.73862
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_26/scripts/refresh_combobox.py
# SPDX-License-Identifier: Apache-2.0 import omni.ui as ui def next_num(n): while True: yield n n += 1 my_window = ui.Window("Example Window", width=300, height=300) item_changed_sub = None with my_window.frame: with ui.VStack(): combo = ui.ComboBox(0, "Option1", "Option2", "Option3") # I'm just using this to generate unique data nums = next_num(0) def clicked(): # clear the list items = combo.model.get_item_children() for item in items: combo.model.remove_item(item) # generate a new list for x in range(5): combo.model.append_child_item(None, ui.SimpleIntModel(next(nums))) ui.Button("Regenerate Combo", clicked_fn=clicked)
803
Python
27.714285
82
0.572852
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_26/scripts/focus_prim.py
# SPDX-License-Identifier: Apache-2.0 ####################################### # MUST ENABLE omni.kit.viewport.utility ####################################### from omni.kit.viewport.utility import get_active_viewport, frame_viewport_selection import omni.usd # Select what you want to focus on selection = omni.usd.get_selection() selection.set_selected_prim_paths(["/World/Cube"], True) # focus on selection active_viewport = get_active_viewport() if active_viewport: frame_viewport_selection(active_viewport)
517
Python
29.470587
83
0.65764
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_26/scripts/corner_rounding.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(): ui.Rectangle(style={ "background_color": ui.color(1.0, 0.0, 0.0), "border_radius":20.0 }) ui.Rectangle(style={ "background_color": ui.color(0.0, 1.0, 0.0), "border_radius":20.0, "corner_flag": ui.CornerFlag.BOTTOM }) ui.Rectangle(style={ "background_color": ui.color(0.0, 0.0, 1.0), "border_radius":20.0, "corner_flag": ui.CornerFlag.TOP }) ui.Rectangle(style={ "background_color": ui.color(1.0, 0.0, 1.0), "border_radius":20.0, "corner_flag": ui.CornerFlag.TOP_RIGHT })
834
Python
31.115383
62
0.526379
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_26/docs/README.md
# Developer Office Hour - 08/26/2022 This is the sample code from the Developer Office Hour held on 08/26/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - How do I execute arbitrary code from VSCode in Omniverse? - How do I create omni.ui.Rectangle with only top or bottom rounded corners? - How do I update a list of items in a ui.ComboBox without rebuilding the widget? - How do I change the shape of the mouse cursor? - How do I get the world position of a prim? - What are the conventions for naming extensions? - How do I add a custom window in the Window menu? - How do I share Python code between extensions?
710
Markdown
49.785711
114
0.770423
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_05_26/scripts/get_references.py
# SPDX-License-Identifier: Apache-2.0 import omni.usd stage = omni.usd.get_context().get_stage() prim = stage.GetPrimAtPath("/World/Xform") refs = prim.GetMetadata("references").ApplyOperations([]) for ref in refs: print(ref.primPath) print(ref.assetPath)
260
Python
22.727271
57
0.742308
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_05_26/docs/README.md
# Developer Office Hour - 05/26/2023 This is the sample code from the Developer Office Hour held on 05/26/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - 02:29 - How do I get an Omniverse app to pick up a new environment variable?
326
Markdown
45.714279
114
0.773006
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_07/scripts/current_frame_number.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.timeline itimeline = omni.timeline.get_timeline_interface() current_seconds = itimeline.get_current_time() fps = itimeline.get_time_codes_per_seconds() current_frame = current_seconds * fps print(f"Current Frame: {current_frame}")
294
Python
28.499997
50
0.77551
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_07/scripts/get_local_transform.py
# SPDX-License-Identifier: Apache-2.0 from pxr import Gf, UsdGeom, Usd import omni.usd def decompose_matrix(mat: Gf.Matrix4d): reversed_ident_mtx = reversed(Gf.Matrix3d()) translate = mat.ExtractTranslation() scale = Gf.Vec3d(*(v.GetLength() for v in mat.ExtractRotationMatrix())) #must remove scaling from mtx before calculating rotations mat.Orthonormalize() #without reversed this seems to return angles in ZYX order rotate = Gf.Vec3d(*reversed(mat.ExtractRotation().Decompose(*reversed_ident_mtx))) return translate, rotate, scale stage = omni.usd.get_context().get_stage() prim = stage.GetPrimAtPath("/World/Cube") xform = UsdGeom.Xformable(prim) local_transformation: Gf.Matrix4d = xform.GetLocalTransformation() print(decompose_matrix(local_transformation)) def get_local_rot(prim: Usd.Prim): return prim.GetAttribute("xformOp:rotateXYZ").Get() print(get_local_rot(prim))
922
Python
31.964285
86
0.744035
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_07/scripts/sceneui_behavior.py
# SPDX-License-Identifier: Apache-2.0 from omni.kit.viewport.utility import get_active_viewport_window import omni.ui as ui from omni.kit.scripting import BehaviorScript from omni.ui import scene as sc from omni.ui import color as cl class NewScript(BehaviorScript): def on_init(self): print(f"{__class__.__name__}.on_init()->{self.prim_path}") self.viewport_window = get_active_viewport_window() self.frame = self.viewport_window.get_frame("Super Duper Cool!") def on_destroy(self): print(f"{__class__.__name__}.on_destroy()->{self.prim_path}") def test(self): print("Hello") def on_play(self): print(f"{__class__.__name__}.on_play()->{self.prim_path}") with self.frame: # Create a default SceneView (it has a default camera-model) self._scene_view = sc.SceneView() # Add the manipulator into the SceneView's scene with self._scene_view.scene: sc.Rectangle(5, 5, thickness=2, wireframe=False, color=cl.red) # Register the SceneView with the Viewport to get projection and view updates self.viewport_window.viewport_api.add_scene_view(self._scene_view) def on_pause(self): print(f"{__class__.__name__}.on_pause()->{self.prim_path}") def on_stop(self): print(f"{__class__.__name__}.on_stop()->{self.prim_path}") if self._scene_view: # Empty the SceneView of any elements it may have self._scene_view.scene.clear() # Be a good citizen, and un-register the SceneView from Viewport updates if self.viewport_window: self.viewport_window.viewport_api.remove_scene_view(self._scene_view) # Remove our references to these objects self._scene_view = None self.frame.destroy() def on_update(self, current_time: float, delta_time: float): # print(f"{__class__.__name__}.on_update(current_time={current_time}, delta_time={delta_time})->{self.prim_path}") pass
2,069
Python
36.636363
122
0.618173
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_04_07/docs/README.md
# Developer Office Hour - 04/07/2023 This is the sample code from the Developer Office Hour held on 04/07/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - Where can I find extension API documentation? - How do I get the current frame number?
336
Markdown
41.124995
114
0.779762
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_05_05/scripts/omnilive.py
# SPDX-License-Identifier: Apache-2.0 from omni.kit.usd.layers import get_live_syncing import omni.client import asyncio UNIQUE_SESSION_NAME = "my_unique_session" # Get the interface live_syncing = get_live_syncing() # Create a session live_session = live_syncing.create_live_session(UNIQUE_SESSION_NAME) # Simulate joining a session for session in live_syncing.get_all_live_sessions(): if session.name == UNIQUE_SESSION_NAME: live_syncing.join_live_session(session) break # Merge changes into base layer and disconnect from live session loop = asyncio.get_event_loop() loop.create_task(live_syncing.merge_and_stop_live_session_async(layer_identifier=session.base_layer_identifier)) # Disconnect from live session without merging. When you reconnect, changes will still be in your live session. live_syncing.stop_live_session(session.base_layer_identifier) # Delete the session once you're all done. You can add a callback for the second arg to know if completed. omni.client.delete_with_callback(session.url, lambda: None)
1,051
Python
35.275861
112
0.7745
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_05_05/scripts/change_renderer.py
# SPDX-License-Identifier: Apache-2.0 # RTX Path Tracing import omni.kit.actions.core action_registry = omni.kit.actions.core.get_action_registry() action = action_registry.get_action("omni.kit.viewport.actions", "set_renderer_rtx_pathtracing") action.execute() # RTX Real-Time import omni.kit.actions.core action_registry = omni.kit.actions.core.get_action_registry() action = action_registry.get_action("omni.kit.viewport.actions", "set_renderer_rtx_realtime") action.execute() # Storm import omni.kit.actions.core action_registry = omni.kit.actions.core.get_action_registry() action = action_registry.get_action("omni.kit.viewport.actions", "set_renderer_pxr_storm") action.execute() # Iray import omni.kit.actions.core action_registry = omni.kit.actions.core.get_action_registry() action = action_registry.get_action("omni.kit.viewport.actions", "set_renderer_iray") action.execute()
891
Python
34.679999
96
0.776655
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_05_05/scripts/change_variants.py
# SPDX-License-Identifier: Apache-2.0 from pxr import Usd, UsdGeom import omni.usd stage = omni.usd.get_context().get_stage() world_prim = stage.GetPrimAtPath("/World") vset = world_prim.GetVariantSets().AddVariantSet('shapes') vset.AddVariant('cube') vset.AddVariant('sphere') vset.AddVariant('cone') vset.SetVariantSelection('cube') with vset.GetVariantEditContext(): UsdGeom.Cube.Define(stage, "/World/Cube") vset.SetVariantSelection('sphere') with vset.GetVariantEditContext(): UsdGeom.Sphere.Define(stage, "/World/Sphere") vset.SetVariantSelection('cone') with vset.GetVariantEditContext(): UsdGeom.Cone.Define(stage, "/World/Cone") stage = omni.usd.get_context().get_stage() world_prim = stage.GetPrimAtPath("/World") vsets = world_prim.GetVariantSets() vset = vsets.GetVariantSet("shapes") vset.SetVariantSelection("cone")
848
Python
27.299999
58
0.755896
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_05_05/docs/README.md
# Developer Office Hour - 05/05/2023 This is the sample code from the Developer Office Hour held on 05/05/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - 02:05 - How can I programmatically create and join an OmniLive session? - 14:17 - How can I programmatically change the renderer to RTX Real-Time, RTX Path Tracing, Iray, or Storm?
430
Markdown
52.874993
114
0.774419
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_12_09/scripts/screenshot_viewport.py
# SPDX-License-Identifier: Apache-2.0 from omni.kit.viewport.utility import get_active_viewport, capture_viewport_to_file vp_api = get_active_viewport() capture_viewport_to_file(vp_api, r"C:\temp\screenshot.png")
214
Python
34.833328
83
0.775701
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_12_09/scripts/collect_asset.py
# SPDX-License-Identifier: Apache-2.0 import asyncio from omni.kit.tool.collect.collector import Collector async def collect_async(input_usd, output_dir, usd_only, flat_collection, mtl_only, prog_cb, finish_cb): """Collect input_usd related assets to output_dir. Args: input_usd (str): The usd stage to be collected. output_dir (str): The target dir to collect the usd stage to. usd_only (bool): Collects usd files only or not. It will ignore all asset types. flat_collection (bool): Collects stage without keeping the original dir structure. mtl_only (bool): Collects material and textures only or not. It will ignore all other asset types. prog_cb: Progress callback function finish_cb: Finish callback function """ collector = Collector(input_usd, output_dir, usd_only, flat_collection, mtl_only) await collector.collect(prog_cb, finish_cb) def finished(): print("Finished!") asyncio.ensure_future(collect_async(r"C:\temp\bookcase.usd", r"C:\temp\test_collect", False, False, False, None, finished))
1,095
Python
42.839998
106
0.70411
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_12_09/docs/README.md
# Developer Office Hour - 12/09/2022 This is the sample code from the Developer Office Hour held on 12/09/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - How do I Collect Asset using Python to share a full Omniverse project? - How do I capture a screenshot of the viewport? - How do I change the visibility of a prim using Action Graph?
432
Markdown
47.111106
114
0.777778
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_03_31/scripts/viewport_ui.py
# SPDX-License-Identifier: Apache-2.0 from omni.kit.scripting import BehaviorScript from omni.kit.viewport.utility import get_active_viewport_window import omni.ui as ui class ViewportUi(BehaviorScript): def on_init(self): # print(f"{__class__.__name__}.on_init()->{self.prim_path}") self.frame = None def on_destroy(self): print(f"{__class__.__name__}.on_destroy()->{self.prim_path}") if self.frame is not None: self.frame.destroy() self.frame = None def test(self): print("Hello World!") def on_play(self): print(f"{__class__.__name__}.on_play()->{self.prim_path}") self.viewport_window = get_active_viewport_window() self.frame = self.viewport_window.get_frame("Really cool id") with self.frame: with ui.Placer(offset_x=10, offset_y=50): with ui.HStack(): ui.Button("Test", width=50, height=50, clicked_fn=self.test) def on_pause(self): print(f"{__class__.__name__}.on_pause()->{self.prim_path}") def on_stop(self): print(f"{__class__.__name__}.on_stop()->{self.prim_path}") if self.frame is not None: self.frame.destroy() self.frame = None def on_update(self, current_time: float, delta_time: float): # print(f"{__class__.__name__}.on_update(current_time={current_time}, delta_time={delta_time})->{self.prim_path}") pass
1,474
Python
33.302325
122
0.580054
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_03_31/docs/README.md
# Developer Office Hour - 03/31/2023 This is the sample code from the Developer Office Hour held on 03/31/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - How do I add UI widgets to the viewport in a BehaviorScript (Python Scripting Component)? - How do I add extension dependencies to my custom extension?
400
Markdown
56.285706
114
0.7875
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_12_16/scripts/script_node.py
# SPDX-License-Identifier: Apache-2.0 # This script is executed the first time the script node computes, or the next time it computes after this script # is modified or the 'Reset' button is pressed. # The following callback functions may be defined in this script: # setup(db): Called immediately after this script is executed # compute(db): Called every time the node computes (should always be defined) # cleanup(db): Called when the node is deleted or the reset button is pressed (if setup(db) was called before) # Defining setup(db) and cleanup(db) is optional, but if compute(db) is not defined then this script node will run # in legacy mode, where the entire script is executed on every compute and the callback functions above are ignored. # Available variables: # db: og.Database The node interface, attributes are db.inputs.data, db.outputs.data. # Use db.log_error, db.log_warning to report problems. # Note that this is available outside of the callbacks only to support legacy mode. # og: The OmniGraph module # Import statements, function/class definitions, and global variables may be placed outside of the callbacks. # Variables may also be added to the db.internal_state state object. # Example code snippet: import math UNITS = "cm" def calculate_circumfrence(radius): return 2 * math.pi * radius def setup(db): state = db.internal_state state.radius = 1 def compute(db): state = db.internal_state circumfrence = calculate_circumfrence(state.radius) print(f"{circumfrence} {UNITS}") print(f"My Input: {db.inputs.my_input}") db.outputs.foo = False state.radius += 1 # To see more examples, click on the Code Snippets button below.
1,756
Python
35.604166
116
0.723804
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_12_16/scripts/file_import.py
# SPDX-License-Identifier: Apache-2.0 # https://docs.omniverse.nvidia.com/kit/docs/omni.kit.window.file_importer/latest/Overview.html from omni.kit.window.file_importer import get_file_importer from typing import List file_importer = get_file_importer() def import_handler(filename: str, dirname: str, selections: List[str] = []): # NOTE: Get user inputs from self._import_options, if needed. print(f"> Import '{filename}' from '{dirname}' or selected files '{selections}'") file_importer.show_window( title="Import File", import_handler=import_handler )
577
Python
29.421051
95
0.731369
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_12_16/scripts/file_exporter.py
# SPDX-License-Identifier: Apache-2.0 # https://docs.omniverse.nvidia.com/kit/docs/omni.kit.window.file_exporter/latest/index.html from omni.kit.window.file_exporter import get_file_exporter from typing import List file_exporter = get_file_exporter() def export_handler(filename: str, dirname: str, extension: str = "", selections: List[str] = []): # NOTE: Get user inputs from self._export_options, if needed. print(f"> Export As '{filename}{extension}' to '{dirname}' with additional selections '{selections}'") file_exporter.show_window( title="Export As ...", export_button_label="Save", export_handler=export_handler, )
649
Python
35.111109
106
0.721109
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_12_16/docs/README.md
# Developer Office Hour - 12/16/2022 This is the sample code from the Developer Office Hour held on 12/16/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - Where are the API docs for extensions? - How do I browse for a file for import? - How do I browse for a file for export? - How do I use the Script Node? (using compute function)
427
Markdown
41.799996
114
0.761124
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_09_08/scripts/sub_event.py
# SPDX-License-Identifier: Apache-2.0 # App/Subscribe to Update Events import carb.events import omni.kit.app update_stream = omni.kit.app.get_app().get_update_event_stream() def on_update(e: carb.events.IEvent): print(f"Update: {e.payload['dt']}") sub = update_stream.create_subscription_to_pop(on_update, name="My Subscription Name") # Remember to cleanup your subscription when you're done with them (e.g. during shutdown) # sub = None
448
Python
28.933331
89
0.736607
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_09_08/scripts/trigger_every_N.py
# App/Subscribe to Update Events import carb.events import omni.kit.app import omni.timeline update_stream = omni.kit.app.get_app().get_update_event_stream() every_N = 5 # seconds elapsed = 0 update_sub = None def on_update(e: carb.events.IEvent): global elapsed elapsed += e.payload["dt"] if elapsed >= every_N: print(f"{every_N} seconds have passed. Fire!") elapsed = 0 # print(f"Update: {elapsed}") def on_play(e: carb.events.IEvent): global update_sub update_sub = update_stream.create_subscription_to_pop(on_update, name="My Subscription Name") def on_stop(e: carb.events.IEvent): global update_sub update_sub = None itimeline: omni.timeline.ITimeline = omni.timeline.get_timeline_interface() play_sub = itimeline.get_timeline_event_stream().create_subscription_to_pop_by_type(omni.timeline.TimelineEventType.PLAY, on_play) stop_sub = itimeline.get_timeline_event_stream().create_subscription_to_pop_by_type(omni.timeline.TimelineEventType.STOP, on_stop) # Remember to unsub by setting variables to None. update_sub = None play_sub = None stop_sub = None
1,117
Python
29.216215
130
0.724261
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_09_08/docs/README.md
# Developer Office Hour - 09/08/2023 This is the sample code from the Developer Office Hour held on 09/08/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - 2:22 - How do I listen for or subscribe to an event in Omniverse Kit? - 15:14 - How do I run a function every N seconds during playback? - 44:00 - How do I link to a DLL with an extension?
438
Markdown
47.777772
114
0.753425
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_21/docs/README.md
# Developer Office Hour - 10/21/2022 This is the sample code from the Developer Office Hour held on 10/21/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions 1. Where are Omniverse logs located? 2. Where is the data directory for an Omniverse app? 3. What is link_app.bat? 4. How do I get intellisense working in VS Code?
410
Markdown
44.666662
114
0.77561
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_30/scripts/curve_widths.py
# SPDX-License-Identifier: Apache-2.0 import omni.usd from pxr import UsdGeom stage = omni.usd.get_context().get_stage() prim = stage.GetPrimAtPath("/World/BasisCurves") prim.GetAttribute("widths").Set([5, 10,5, 10,5, 10,5, 10,5, 10,5, 10,5]) curves: UsdGeom.BasisCurves = UsdGeom.BasisCurves(prim) print(curves.GetWidthsInterpolation())
339
Python
32.999997
72
0.746313
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_30/scripts/omnigraph.py
""" https://docs.omniverse.nvidia.com/py/kit/source/extensions/omni.graph/docs/index.html https://docs.omniverse.nvidia.com/py/kit/source/extensions/omni.graph/docs/controller.html#howto-omnigraph-controller """ import omni.graph.core as og controller: og.Controller = og.Controller() keys = og.Controller.Keys # Create an Action Graph # SPDX-License-Identifier: Apache-2.0 graph = controller.create_graph({ "graph_path": "/World/CameraAim", "evaluator_name": "execution" # This makes it Action Graph }) # Create some nodes _, nodes, _, _ = controller.edit(graph, {keys.CREATE_NODES: ("OnTick", "omni.graph.action.OnTick")}) on_tick = nodes[0] _, nodes, _, _ = controller.edit(graph, {keys.CREATE_NODES: ("SetCameraTarget", "omni.graph.ui.SetCameraTarget")}) set_cam_target = nodes[0] # Edit an attribute # /World/CameraAim/OnTick.inputs:onlyPlayback controller.edit(graph, {keys.SET_VALUES: (on_tick.get_attribute("inputs:onlyPlayback"), False)}) # Connect two attributes controller.connect(on_tick.get_attribute("outputs:tick"), set_cam_target.get_attribute("inputs:execIn"))
1,092
Python
35.433332
117
0.738095
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_30/scripts/vp2.py
# SPDX-License-Identifier: Apache-2.0 # DON'T DO THIS ANYMORE import omni.kit.viewport_legacy viewport_interface = omni.kit.viewport_legacy.acquire_viewport_interface() vp_win = viewport_interface.get_viewport_window() print(vp_win) # DO THIS import omni.kit.viewport.utility as vp_util vp_win = vp_util.get_active_viewport_window() print(vp_win)
350
Python
24.071427
74
0.771429
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_30/docs/README.md
# Developer Office Hour - 09/30/2022 This is the sample code from the Developer Office Hour held on 09/30/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - Why is the legacy viewport API not working anymore? - How do I create an OmniGraph using Python scripting?
357
Markdown
38.777773
114
0.781513
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_11_04/maticodes/doh_2022_11_04/extension.py
# SPDX-License-Identifier: Apache-2.0 from pathlib import Path import carb import numpy as np import omni.ext import omni.kit.app import omni.ui as ui from PIL import Image class MyWindow(ui.Window): def __init__(self, ext_path, title: str = None, **kwargs): super().__init__(title, **kwargs) data_dir = Path(ext_path) / "data" files = list(data_dir.glob("*")) self.images = [] for f in files: with Image.open(f) as img: np_data = np.asarray(img).data data = img.getdata() self.images.append((np_data, data, img.size)) self.provider = ui.ByteImageProvider() if hasattr(self.provider, "set_data_array"): self.provider.set_data_array(self.images[0][0], self.images[0][2]) else: self.provider.set_bytes_data(self.images[0][1], self.images[0][2]) self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.ImageWithProvider(self.provider, width=100, height=100) def clicked(): img = self.images.pop() self.images.insert(0, img) if hasattr(self.provider, "set_data_array"): self.provider.set_data_array(img[0], img[2]) else: self.provider.set_bytes_data(img[1], img[2]) ui.Button("Click Me", clicked_fn=clicked) class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2022_11_04] Dev Office Hours Extension (2022-11-04) startup") manager = omni.kit.app.get_app().get_extension_manager() ext_path = manager.get_extension_path(ext_id) self._window = MyWindow(ext_path, "MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2022_11_04] Dev Office Hours Extension (2022-11-04) shutdown") if self._window: self._window.destroy() self._window = None
2,154
Python
33.206349
100
0.566852
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_11_04/scripts/progress_bar.py
# SPDX-License-Identifier: Apache-2.0 import omni.ui as ui style = { "color": ui.color.red, "background_color": ui.color.blue, "secondary_color": ui.color.white, } class CustomProgressValueModel(ui.AbstractValueModel): """An example of custom float model that can be used for progress bar""" def __init__(self, value: float): super().__init__() self._value = value def set_value(self, value): """Reimplemented set""" try: value = float(value) except ValueError: value = None if value != self._value: # Tell the widget that the model is changed self._value = value self._value_changed() def get_value_as_float(self): return self._value def get_value_as_string(self): return f"{self._value*100:.0f}%" my_window = ui.Window("Example Window", width=300, height=300) with my_window.frame: with ui.VStack(): model = CustomProgressValueModel(0.0) pb = ui.ProgressBar(model, style=style, height=0) # pb = ui.ProgressBar(style=style, height=0) def clicked(): print("clicked") value = pb.model.as_float pb.model.set_value(value + 0.1) ui.Button("Plus One", clicked_fn=clicked)
1,320
Python
23.018181
76
0.585606
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_11_04/scripts/loop.py
# SPDX-License-Identifier: Apache-2.0 my_list = [1,2,3] s = set([1,2,3]) d = {"one": 1, "two": 2} t = (1,2,3) # range, enumerate, filter, map, zip # https://docs.python.org/3.7/library/functions.html # Topics to research: Iterable, iterator, generator from pxr import Vt, Gf for i, x in enumerate(my_list): print(i, x) for x in Gf.Vec3f([1,2,3]): print(x) my_usd_arr = Vt.BoolArray([False, True, False]) print(type(my_usd_arr)) for x in my_usd_arr: print(x) for i, x in Vt.BoolArray([False, True, False]): print(i, x) class PowTwo: num = 1 def __iter__(self): return self def __next__(self): self.num = self.num * 2 if self.num > 32: raise StopIteration() return self.num pow2 = PowTwo() # for x in pow2: # print(x) print(next(pow2)) print(next(pow2)) print(next(pow2)) print(next(pow2)) print(next(pow2)) print(next(pow2)) print(next(pow2))
933
Python
17.68
52
0.60343
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_11_04/docs/README.md
# Developer Office Hour - 11/04/2022 This is the sample code from the Developer Office Hour held on 11/04/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - How can I display dynamic images within a frame? - What can I use a for loop with? - How do I create a progress bar?
367
Markdown
35.799996
114
0.762943
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_05_12/scripts/my_script.py
# SPDX-License-Identifier: Apache-2.0 import omni.ui as ui
59
Python
18.999994
37
0.762712
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_05_12/docs/README.md
# Developer Office Hour - 05/12/2023 This is the sample code from the Developer Office Hour held on 05/12/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - 02:30 - How do you add two windows from one extension?
304
Markdown
42.571422
114
0.773026
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_20/scripts/check_omni_file_exists.py
# SPDX-License-Identifier: Apache-2.0 import omni.client result, list_entry = omni.client.stat("omniverse://localhost/Users/test/helloworld_py.usd") if result == omni.client.Result.OK: # Do things print(list_entry) # When a file doesn't exist, the result is omni.client.Result.ERROR_NOT_FOUND result, list_entry = omni.client.stat("omniverse://localhost/Users/test/fake.usd") print(result, list_entry)
412
Python
33.416664
91
0.745146
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_20/scripts/duplicate_prim.py
# SPDX-License-Identifier: Apache-2.0 # paths_to import omni.kit.commands result = omni.kit.commands.execute('CopyPrims', paths_from=['/World/Cube'], paths_to=["/World/MyCopiedCube"], duplicate_layers=False, combine_layers=False, flatten_references=False) print(result)
282
Python
17.866665
47
0.734043
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_20/scripts/selection_changed_event.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.usd usd_ctx = omni.usd.get_context() def on_selection_changed(event: carb.events.IEvent): print("Selection Changed") # https://docs.omniverse.nvidia.com/prod_kit/prod_kit/python-snippets/selection/get-current-selected-prims.html selection = usd_ctx.get_selection().get_selected_prim_paths() print(f"New selection: {selection}") sel_sub = usd_ctx.get_stage_event_stream().create_subscription_to_pop_by_type(omni.usd.StageEventType.SELECTION_CHANGED, on_selection_changed) # Don't forget to unsubscribe when you're done with it or when your extension shuts down. sel_sub.unsubscribe()
667
Python
34.157893
142
0.757121
mati-nvidia/developer-office-hours/exts/maticodes.doh_2023_01_20/docs/README.md
# Developer Office Hour - 01/20/2023 This is the sample code from the Developer Office Hour held on 01/20/2023, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - 3:57 - How do I check if a file exists using the Omni Client Library? - 6:51 - How do I duplicate a prim? - 13:53 - Is there an event for when a user's prim selection changes?
425
Markdown
46.333328
114
0.752941
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_02/scripts/what_is_sc.py
# SPDX-License-Identifier: Apache-2.0 from omni.ui import scene as sc
70
Python
22.666659
37
0.771429
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_02/scripts/get_local.py
# SPDX-License-Identifier: Apache-2.0 import omni.usd from pxr import Usd, Gf stage = omni.usd.get_context().get_stage() prim = stage.GetPrimAtPath("/World/Cube_01") scale, rotate, rot_order, translate = omni.usd.get_local_transform_SRT(prim, time=Usd.TimeCode.Default()) print(scale, rotate, rot_order, translate) # Gf.Vec3d # (Double, Double, Double) # Gf.Matrix4d # (Double, Double, Double, Double) # (Double, Double, Double, Double) # (Double, Double, Double, Double) # (Double, Double, Double, Double) matrix:Gf.Matrix4d = omni.usd.get_local_transform_matrix(prim, time_code=Usd.TimeCode.Default()) print(matrix)
622
Python
28.666665
105
0.731511
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_02/scripts/define_ui_colors.py
# SPDX-License-Identifier: Apache-2.0 import omni.ui as ui from omni.ui import color as cl my_window = ui.Window("Example Window", width=300, height=300) with my_window.frame: with ui.VStack(): ui.Label("AABBGGRR", style={"color": 0xFF00FFFF}) # STAY AWAY FROM ui.Label("Float RGB", style={"color": cl(1.0, 1.0, 0.0)}) ui.Label("Float RGBA", style={"color": cl(1.0, 1.0, 0.0, 0.5)}) ui.Label("Int RGB", style={"color": cl(255, 255, 0)}) ui.Label("Int RGBA", style={"color": cl(255, 255, 0, 128)}) ui.Label("Oops RGB", style={"color": cl(1, 1, 0)}) ui.Label("Web Hex RGB", style={"color": cl("#FFFF00")}) ui.Label("Web Hex rgb", style={"color": cl("#ffff00")}) ui.Label("Web Hex RGBA", style={"color": cl("#FFFF0088")}) ui.Label("Float RGB White", style={"color": cl(1.0, 1.0, 1.0)}) ui.Label("Float RGB 50%", style={"color": cl(0.5, 0.5, 0.5)}) ui.Label("Float Greyscale White", style={"color": cl(1.0)}) ui.Label("Float Greyscale 50%", style={"color": cl(0.5)}) ui.Label("Int Greyscale White", style={"color": cl(255)}) ui.Label("Int Greyscale 50%", style={"color": cl(128)}) ui.Label("Web Color Name", style={"color": cl.yellow})
1,305
Python
39.812499
74
0.555556
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_02/scripts/add_menu.py
# SPDX-License-Identifier: Apache-2.0 import omni.kit.ui menu_path = "File/Foo" menu_path2 = "File/Foo/Bar" def on_menu_click(menu_path, toggled): print(menu_path) print(toggled) menu = omni.kit.ui.get_editor_menu().add_item(menu_path, on_menu_click) menu = omni.kit.ui.get_editor_menu().add_item(menu_path2, on_menu_click, True) omni.kit.ui.get_editor_menu().remove_item(menu) import omni.kit.menu.utils from omni.kit.menu.utils import MenuItemDescription menu_item = MenuItemDescription( name="Hello World!", glyph="save.svg", onclick_fn=lambda: print("Hello World!"), # hotkey=( # carb.input.KEYBOARD_MODIFIER_FLAG_CONTROL | carb.input.KEYBOARD_MODIFIER_FLAG_ALT, # carb.input.KeyboardInput.S, #), ) menus = [menu_item] omni.kit.menu.utils.add_menu_items([menu_item], "File") omni.kit.menu.utils.remove_menu_items([menu_item], "File", rebuild_menus=True) # omni.kit.ui.get_editor_menu().convert_to_new_menu
963
Python
25.054053
91
0.699896
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_02/scripts/what_is_cl.py
# SPDX-License-Identifier: Apache-2.0 import omni.ui as ui from omni.ui import color as cl # import omni.ui.color as color my_window = ui.Window("Example Window", width=300, height=300) with my_window.frame: with ui.VStack(): ui.Label("Hello World!", style={"color": cl(0.0, 1.0, 0.0)})
303
Python
22.384614
68
0.673267
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_09_02/docs/README.md
# Developer Office Hour - 09/02/2022 This is the sample code from the Developer Office Hour held on 09/02/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - What's the difference between a shape and a mesh? - How do I import cl? - How do I import sc? - How do I define UI colors? - How do I add an item to a menu?
405
Markdown
39.599996
194
0.748148
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_11_18/maticodes/doh_2022_11_18/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext from omni.kit.viewport.utility import get_active_viewport_window import omni.ui as ui class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): carb.log_info("[maticodes.doh_2022_11_18] Dev Office Hours Extension (2022-11-18) startup") self.custom_frame = None viewport_window = get_active_viewport_window() if viewport_window is not None: self.custom_frame: ui.Frame = viewport_window.get_frame(ext_id) with self.custom_frame: with ui.VStack(): ui.Spacer() with ui.HStack(height=0): ui.Spacer() ui.Button("Hello", width=0, height=0) def on_shutdown(self): carb.log_info("[maticodes.doh_2022_11_18] Dev Office Hours Extension (2022-11-18) shutdown") self.custom_frame.destroy() self.custom_frame = None
990
Python
32.033332
100
0.59596
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_11_18/scripts/placer_model.py
# SPDX-License-Identifier: Apache-2.0 import omni.ui as ui my_window = ui.Window("Example Window", width=300, height=300) model = ui.SimpleFloatModel() sub = None with my_window.frame: with ui.VStack(): ui.FloatSlider(model=model) def body_moved(body, model): if body.offset_x.value > 100: body.offset_x.value = 100 elif body.offset_x.value < 0: body.offset_x.value = 0 model.set_value(body.offset_x.value / 100.0) body = ui.Placer(draggable=True, drag_axis=ui.Axis.X, offset_x=0) with body: rect = ui.Rectangle(width=25, height=25, style={"background_color": ui.color.red}) body.set_offset_x_changed_fn(lambda _, b=body, m=model: body_moved(b, m)) def slider_moved(model, body): body.offset_x.value = model.as_float * 100 sub = model.subscribe_value_changed_fn(lambda m=model, b=body: slider_moved(m, b))
996
Python
34.607142
94
0.589357
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_11_18/docs/README.md
# Developer Office Hour - 11/18/2022 This is the sample code from the Developer Office Hour held on 11/18/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - How do I add widgets on top of the viewport? (ViewportWindow.get_frame) - How do I use value model with ui.Placer? - How do I see all of the code from the UI documentation examples?
431
Markdown
46.999995
114
0.770302
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_07/scripts/usd_update_stream.py
# SPDX-License-Identifier: Apache-2.0 import omni.usd from pxr import UsdGeom, Gf stage = omni.usd.get_context().get_stage() cube = stage.GetPrimAtPath("/World/Cube") 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) world_transform = omni.usd.get_world_transform_matrix(prim) translation: Gf.Vec3d = world_transform.ExtractTranslation() rotation: Gf.Rotation = world_transform.ExtractRotation() scale: Gf.Vec3d = Gf.Vec3d(*(v.GetLength() for v in world_transform.ExtractRotationMatrix())) print(translation, rotation, scale) cube_move_sub = omni.usd.get_watcher().subscribe_to_change_info_path(cube.GetPath(), print_pos)
813
Python
37.761903
97
0.719557
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_07/scripts/create_viewport.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.kit.viewport.utility as vp_utils from omni.kit.widget.viewport.api import ViewportAPI vp_window = vp_utils.create_viewport_window("My Viewport") vp_window.viewport_api.fill_frame = True vp_api: ViewportAPI = vp_window.viewport_api carb.settings.get_settings().set('/rtx/rendermode', "PathTracing") vp_api.set_hd_engine("rtx")
392
Python
27.071427
66
0.770408
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_10_07/docs/README.md
# Developer Office Hour - 10/07/2022 This is the sample code from the Developer Office Hour held on 10/07/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - How do I create another viewport? - How do I use the Script Node?
315
Markdown
38.499995
114
0.771429
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_12_02/maticodes/doh_2022_12_02/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): with ui.HStack(height=0): ui.Label("My Label") MyCoolComponent() def clicked(): carb.log_info("Button Clicked!") ui.Button("Click Me", clicked_fn=clicked) class MyCoolComponent: def __init__(self): with ui.VStack(): ui.Label("Moar labels- asdfasdfasdf") ui.Label("Even moar labels") with ui.HStack(): ui.Button("Ok") ui.Button("Cancel") class MyExtension(omni.ext.IExt): def on_startup(self, ext_id): """_summary_ Args: ext_id (_type_): _description_ """ carb.log_info("[maticodes.doh_2022_12_02] Dev Office Hours Extension (2022-12-02) startup") self._window = MyWindow("MyWindow", width=300, height=300) def on_shutdown(self): carb.log_info("[maticodes.doh_2022_12_02] Dev Office Hours Extension (2022-12-02) shutdown") if self._window: self._window.destroy() self._window = None
1,442
Python
28.448979
100
0.549237
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_12_02/scripts/spawn_objects.py
# SPDX-License-Identifier: Apache-2.0 import carb.events import omni.kit.app import omni.kit.commands import logging time_since_last_create = 0 update_stream = omni.kit.app.get_app().get_update_event_stream() def on_update(e: carb.events.IEvent): global time_since_last_create carb.log_info(f"Update: {e.payload['dt']}") time_since_last_create += e.payload['dt'] carb.log_info(f"time since: {time_since_last_create}") if time_since_last_create > 2: carb.log_info("Creating cube") omni.kit.commands.execute('CreateMeshPrimWithDefaultXform', prim_type='Cube') time_since_last_create = 0 sub = update_stream.create_subscription_to_pop(on_update, name="My Subscription Name") sub = None
745
Python
27.692307
86
0.69396
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_12_02/docs/README.md
# Developer Office Hour - 12/02/2022 This is the sample code from the Developer Office Hour held on 12/02/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - How do I uninstall an extension? - How do I export USDZ? - Where is the extension I was working on? - How do I create complex UI without so much indented Python code?
416
Markdown
40.699996
114
0.769231
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_12/maticodes/doh_2022_08_12/extension.py
# SPDX-License-Identifier: Apache-2.0 import carb import omni.ext from omni.kit.viewport.utility import get_active_viewport_window import omni.ui as ui from .viewport_scene import ViewportScene from .object_info_model import ObjectInfoModel class MyWindow(ui.Window): def __init__(self, title: str = None, delegate=None, **kwargs): super().__init__(title, **kwargs) self._viewport_scene = None self.obj_info_model = kwargs["obj_info_model"] self.frame.set_build_fn(self._build_window) def _build_window(self): with ui.ScrollingFrame(): with ui.VStack(height=0): ui.Label("My Label 2") ui.StringField() ui.StringField(password_mode=True) def clicked(): self.obj_info_model.populate() ui.Button("Reload Object Info", clicked_fn=clicked) def destroy(self) -> None: 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): # Get the active Viewport (which at startup is the default Viewport) viewport_window = get_active_viewport_window() # Issue an error if there is no Viewport if not viewport_window: carb.log_error(f"No Viewport Window to add {ext_id} scene to") return # Build out the scene model = ObjectInfoModel() self._viewport_scene = ViewportScene(viewport_window, ext_id, model) self._window = MyWindow("MyWindow", obj_info_model=model, width=300, height=300) def on_shutdown(self): if self._window: self._window.destroy() self._window = None if self._viewport_scene: self._viewport_scene.destroy() self._viewport_scene = None
1,997
Python
31.754098
119
0.618928
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_12/scripts/viewport_popup_notification.py
# SPDX-License-Identifier: Apache-2.0 # https://docs.omniverse.nvidia.com/py/kit/source/extensions/omni.kit.notification_manager/docs/index.html?highlight=omni%20kit%20notification_manager# import carb def clicked_ok(): carb.log_info("User clicked ok") def clicked_cancel(): carb.log_info("User clicked cancel") import omni.kit.notification_manager as nm ok_button = nm.NotificationButtonInfo("OK", on_complete=clicked_ok) cancel_button = nm.NotificationButtonInfo("CANCEL", on_complete=clicked_cancel) notification_info = nm.post_notification( "Notification Example", hide_after_timeout=False, duration=0, status=nm.NotificationStatus.WARNING, button_infos=[ok_button, cancel_button], )
723
Python
27.959999
151
0.755187
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_12/scripts/create_many_prims.py
# SPDX-License-Identifier: Apache-2.0 from pxr import UsdGeom import omni.kit.commands import omni.usd stage = omni.usd.get_context().get_stage() cube_paths = [] for i in range(10): cube_path = omni.usd.get_stage_next_free_path(stage, "/World/Cube", prepend_default_prim=False) cube_paths.append(cube_path) omni.kit.commands.execute("CreatePrim", prim_type="Cube", prim_path=cube_path) # UsdGeom.Cube.Define(stage, cube_path)
445
Python
28.733331
99
0.719101
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_12/scripts/refer_to_child_prim.py
# SPDX-License-Identifier: Apache-2.0 # https://docs.omniverse.nvidia.com/prod_usd/prod_usd/quick-start/hierarchy.html import omni.usd stage = omni.usd.get_context().get_stage() starting_prim = stage.GetPrimAtPath("/World/New") for shape in starting_prim.GetChildren(): print(shape) for shape_child in shape.GetChildren(): print(shape_child) for prim in stage.Traverse(): print(prim)
408
Python
24.562498
80
0.720588
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_12/scripts/create_group_anywhere.py
# SPDX-License-Identifier: Apache-2.0 from pxr import Sdf import omni.kit.commands import omni.usd stage = omni.usd.get_context().get_stage() children = [] for i in range(3): child = omni.usd.get_stage_next_free_path(stage, "/World/Cube", prepend_default_prim=False) children.append(child) omni.kit.commands.execute("CreatePrim", prim_type="Cube", prim_path=child) group_path = Sdf.Path("/World/New/Hello") omni.kit.commands.execute("CreatePrimWithDefaultXformCommand", prim_type="Scope", prim_path=str(group_path)) for child in children: prim = stage.GetPrimAtPath(child) name = prim.GetName() omni.kit.commands.execute("MovePrim", path_from=child, path_to=group_path.AppendPath(name))
715
Python
33.095237
108
0.731469
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_12/scripts/does_prim_exist.py
# SPDX-License-Identifier: Apache-2.0 from pxr import Usd, UsdGeom import omni.usd stage = omni.usd.get_context().get_stage() prim = stage.GetPrimAtPath("/World/New/Hello") print(prim) print(prim.IsValid()) prim = stage.GetPrimAtPath("/World/New/Fake") print(prim) print(prim.IsValid())
290
Python
19.785713
46
0.737931
mati-nvidia/developer-office-hours/exts/maticodes.doh_2022_08_12/docs/README.md
# Developer Office Hour - 08/12/2022 This is the sample code from the Developer Office Hour held on 08/12/2022, Mati answered some developer questions from the NVIDIA Omniverse forums regarding Kit, Omniverse Code, Python, and USD. ## Questions - How do I create many prims at available prim paths? - How do I create a group at a specific prim path? - Is there a way to check if a prim exists? - How do I refer to the child of a prim without giving the prim path? - How can I create a notification popup in the viewport with a log message? - How do I show labels in the viewport for multiple prims? ...
605
Markdown
45.615381
114
0.758678
omniverse-code/kit/gsl/README.packman.md
* Package: gsl * Version: 3.1.0.1 * From: ssh://[email protected]:12051/omniverse/externals/gsl.git * Branch: master * Commit: 5e0543eb9d231a0d3ccd7f5789aa51d1c896f6ae * Time: Fri Nov 06 14:03:26 2020 * Computername: KPICOTT-LT * Packman: 5.13.2
257
Markdown
27.666664
76
0.750973
omniverse-code/kit/gsl/appveyor.yml
shallow_clone: true platform: - x86 - x64 configuration: - Debug - Release image: - Visual Studio 2017 - Visual Studio 2019 environment: NINJA_TAG: v1.8.2 NINJA_SHA512: 9B9CE248240665FCD6404B989F3B3C27ED9682838225E6DC9B67B551774F251E4FF8A207504F941E7C811E7A8BE1945E7BCB94472A335EF15E23A0200A32E6D5 NINJA_PATH: C:\Tools\ninja\ninja-%NINJA_TAG% VCVAR2017: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat' VCVAR2019: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat' matrix: - GSL_CXX_STANDARD: 14 USE_TOOLSET: MSVC USE_GENERATOR: MSBuild - GSL_CXX_STANDARD: 17 USE_TOOLSET: MSVC USE_GENERATOR: MSBuild - GSL_CXX_STANDARD: 14 USE_TOOLSET: LLVM USE_GENERATOR: Ninja - GSL_CXX_STANDARD: 17 USE_TOOLSET: LLVM USE_GENERATOR: Ninja cache: - C:\cmake-3.14.4-win32-x86 - C:\Tools\ninja install: - ps: | if (![IO.File]::Exists("$env:NINJA_PATH\ninja.exe")) { Start-FileDownload ` "https://github.com/ninja-build/ninja/releases/download/$env:NINJA_TAG/ninja-win.zip" $hash = (Get-FileHash ninja-win.zip -Algorithm SHA512).Hash if ($env:NINJA_SHA512 -eq $hash) { 7z e -y -bso0 ninja-win.zip -o"$env:NINJA_PATH" } else { Write-Warning "Ninja download hash changed!"; Write-Output "$hash" } } if ([IO.File]::Exists("$env:NINJA_PATH\ninja.exe")) { $env:PATH = "$env:NINJA_PATH;$env:PATH" } else { Write-Warning "Failed to find ninja.exe in expected location." } if ($env:USE_TOOLSET -ne "LLVM") { if (![IO.File]::Exists("C:\cmake-3.14.0-win32-x86\bin\cmake.exe")) { Start-FileDownload 'https://cmake.org/files/v3.14/cmake-3.14.4-win32-x86.zip' 7z x -y -bso0 cmake-3.14.4-win32-x86.zip -oC:\ } $env:PATH="C:\cmake-3.14.4-win32-x86\bin;$env:PATH" } before_build: - ps: | if ("$env:USE_GENERATOR" -eq "Ninja") { $GeneratorFlags = '-k 10' $Architecture = $env:PLATFORM if ("$env:APPVEYOR_BUILD_WORKER_IMAGE" -eq "Visual Studio 2017") { $env:VCVARSALL = "`"$env:VCVAR2017`" $Architecture" } else { $env:VCVARSALL = "`"$env:VCVAR2019`" $Architecture" } $env:CMakeGenFlags = "-G Ninja -DGSL_CXX_STANDARD=$env:GSL_CXX_STANDARD" } else { $GeneratorFlags = '/m /v:minimal' if ("$env:APPVEYOR_BUILD_WORKER_IMAGE" -eq "Visual Studio 2017") { $Generator = 'Visual Studio 15 2017' } else { $Generator = 'Visual Studio 16 2019' } if ("$env:PLATFORM" -eq "x86") { $Architecture = "Win32" } else { $Architecture = "x64" } if ("$env:USE_TOOLSET" -eq "LLVM") { $env:CMakeGenFlags = "-G `"$Generator`" -A $Architecture -T llvm -DGSL_CXX_STANDARD=$env:GSL_CXX_STANDARD" } else { $env:CMakeGenFlags = "-G `"$Generator`" -A $Architecture -DGSL_CXX_STANDARD=$env:GSL_CXX_STANDARD" } } if ("$env:USE_TOOLSET" -eq "LLVM") { $env:CC = "clang-cl" $env:CXX = "clang-cl" if ("$env:PLATFORM" -eq "x86") { $env:CFLAGS = "-m32"; $env:CXXFLAGS = "-m32"; } else { $env:CFLAGS = "-m64"; $env:CXXFLAGS = "-m64"; } } $env:CMakeBuildFlags = "--config $env:CONFIGURATION -- $GeneratorFlags" - mkdir build - cd build - if %USE_GENERATOR%==Ninja (call %VCVARSALL%) - echo %CMakeGenFlags% - cmake .. %CMakeGenFlags% build_script: - echo %CMakeBuildFlags% - cmake --build . %CMakeBuildFlags% test_script: - ctest -j2 deploy: off
3,759
YAML
31.695652
144
0.592445
omniverse-code/kit/gsl/README.md
# GSL: Guidelines Support Library [![Build Status](https://travis-ci.org/Microsoft/GSL.svg?branch=master)](https://travis-ci.org/Microsoft/GSL) [![Build status](https://ci.appveyor.com/api/projects/status/github/Microsoft/GSL?svg=true)](https://ci.appveyor.com/project/neilmacintosh/GSL) The Guidelines Support Library (GSL) contains functions and types that are suggested for use by the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines) maintained by the [Standard C++ Foundation](https://isocpp.org). This repo contains Microsoft's implementation of GSL. The library includes types like `span<T>`, `string_span`, `owner<>` and others. The entire implementation is provided inline in the headers under the [gsl](./include/gsl) directory. The implementation generally assumes a platform that implements C++14 support. While some types have been broken out into their own headers (e.g. [gsl/span](./include/gsl/span)), it is simplest to just include [gsl/gsl](./include/gsl/gsl) and gain access to the entire library. > NOTE: We encourage contributions that improve or refine any of the types in this library as well as ports to other platforms. Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for more information about contributing. # Project Code of Conduct This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments. # Usage of Third Party Libraries This project makes use of the [Google Test](https://github.com/google/googletest) testing library. Please see the [ThirdPartyNotices.txt](./ThirdPartyNotices.txt) file for details regarding the licensing of Google Test. # Quick Start ## Supported Compilers The GSL officially supports the current and previous major release of MSVC, GCC, Clang, and XCode's Apple-Clang. See our latest test results for the most up-to-date list of supported configurations. Compiler |Toolset Versions Currently Tested| Build Status :------- |:--|------------: XCode |11.4 & 10.3 | [![Status](https://travis-ci.org/Microsoft/GSL.svg?branch=master)](https://travis-ci.org/Microsoft/GSL) GCC |9 & 8| [![Status](https://travis-ci.org/Microsoft/GSL.svg?branch=master)](https://travis-ci.org/Microsoft/GSL) Clang |11 & 10| [![Status](https://travis-ci.org/Microsoft/GSL.svg?branch=master)](https://travis-ci.org/Microsoft/GSL) Visual Studio with MSVC | VS2017 (15.9) & VS2019 (16.4) | [![Status](https://ci.appveyor.com/api/projects/status/github/Microsoft/GSL?svg=true)](https://ci.appveyor.com/project/neilmacintosh/GSL) Visual Studio with LLVM | VS2017 (Clang 9) & VS2019 (Clang 10) | [![Status](https://ci.appveyor.com/api/projects/status/github/Microsoft/GSL?svg=true)](https://ci.appveyor.com/project/neilmacintosh/GSL) Note: For `gsl::byte` to work correctly with Clang and GCC you might have to use the ` -fno-strict-aliasing` compiler option. --- If you successfully port GSL to another platform, we would love to hear from you! - Submit an issue specifying the platform and target. - Consider contributing your changes by filing a pull request with any necessary changes. - If at all possible, add a CI/CD step and add the button to the table below! Target | CI/CD Status :------- | -----------: iOS | ![CI](https://github.com/microsoft/GSL/workflows/CI/badge.svg) Android | ![CI](https://github.com/microsoft/GSL/workflows/CI/badge.svg) Note: These CI/CD steps are run with each pull request, however failures in them are non-blocking. ## Building the tests To build the tests, you will require the following: * [CMake](http://cmake.org), version 3.1.3 (3.2.3 for AppleClang) or later to be installed and in your PATH. These steps assume the source code of this repository has been cloned into a directory named `c:\GSL`. 1. Create a directory to contain the build outputs for a particular architecture (we name it c:\GSL\build-x86 in this example). cd GSL md build-x86 cd build-x86 2. Configure CMake to use the compiler of your choice (you can see a list by running `cmake --help`). cmake -G "Visual Studio 15 2017" c:\GSL 3. Build the test suite (in this case, in the Debug configuration, Release is another good choice). cmake --build . --config Debug 4. Run the test suite. ctest -C Debug All tests should pass - indicating your platform is fully supported and you are ready to use the GSL types! ## Building GSL - Using vcpkg You can download and install GSL using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager: git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install vcpkg install ms-gsl The GSL port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository. ## Using the libraries As the types are entirely implemented inline in headers, there are no linking requirements. You can copy the [gsl](./include/gsl) directory into your source tree so it is available to your compiler, then include the appropriate headers in your program. Alternatively set your compiler's *include path* flag to point to the GSL development folder (`c:\GSL\include` in the example above) or installation folder (after running the install). Eg. MSVC++ /I c:\GSL\include GCC/clang -I$HOME/dev/GSL/include Include the library using: #include <gsl/gsl> ## Usage in CMake The library provides a Config file for CMake, once installed it can be found via find_package(Microsoft.GSL CONFIG) Which, when successful, will add library target called `Microsoft.GSL::GSL` which you can use via the usual `target_link_libraries` mechanism. ## Debugging visualization support For Visual Studio users, the file [GSL.natvis](./GSL.natvis) in the root directory of the repository can be added to your project if you would like more helpful visualization of GSL types in the Visual Studio debugger than would be offered by default.
6,291
Markdown
50.154471
332
0.750437
omniverse-code/kit/gsl/PACKAGE-LICENSES/gsl-LICENSE.md
Copyright (c) 2015 Microsoft Corporation. All rights reserved. This code is licensed under the MIT License (MIT). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1,156
Markdown
51.590907
81
0.792388
omniverse-code/kit/exts/omni.kit.material.library/docs/index.rst
omni.kit.material.library ########################### Material Library .. toctree:: :maxdepth: 1 CHANGELOG Python API Reference ********************* .. automodule:: omni.kit.material.library :platform: Windows-x86_64, Linux-x86_64 :members: :undoc-members: :imported-members: :exclude-members: chain :noindex: omni.usd._impl.utils.PrimCaching
383
reStructuredText
14.359999
46
0.597911
omniverse-code/kit/exts/omni.kit.window.imageviewer/config/extension.toml
[package] version = "1.0.6" category = "Internal" feature = true title = "Image Viewer" description="Adds context menu in the Content Browser that allows to view images." authors = ["NVIDIA"] changelog = "docs/CHANGELOG.md" preview_image = "data/preview.png" icon = "data/icon.png" readme = "docs/README.md" [dependencies] "omni.ui" = {} "omni.kit.widget.imageview" = {} "omni.kit.window.content_browser" = { optional=true } "omni.kit.test" = {} "omni.usd.libs" = {} [[python.module]] name = "omni.kit.window.imageviewer" # Additional python module with tests, to make them discoverable by test system. [[python.module]] name = "omni.kit.window.imageviewer.tests" [[test]] args = ["--/app/window/dpiScaleOverride=1.0", "--/app/window/scaleToMonitor=false"] dependencies = [ "omni.kit.mainwindow", "omni.kit.renderer.capture", ] pythonTests.unreliable = [ "*test_general" # OM-49017 ]
902
TOML
23.405405
83
0.695122
omniverse-code/kit/exts/omni.kit.window.imageviewer/omni/kit/window/imageviewer/imageviewer.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # import omni.kit.widget.imageview as imageview import omni.ui as ui from .singleton import singleton @singleton class ViewerWindows: """This object keeps all the Image Viewper windows""" def __init__(self): self.__windows = {} def open_window(self, filepath: str) -> ui.Window: """Open ImageViewer window with the image file opened in it""" if filepath in self.__windows: window = self.__windows[filepath] window.visible = True else: window = ImageViewer(filepath) # When window is closed, remove it from the list window.set_visibility_changed_fn(lambda _, f=filepath: self.close(f)) self.__windows[filepath] = window return window def close(self, filepath): """Close and remove spacific window""" del self.__windows[filepath] def close_all(self): """Close and remove all windows""" self.__windows = {} class ImageViewer(ui.Window): """The window with Image Viewer""" def __init__(self, filename: str, **kwargs): if "width" not in kwargs: kwargs["width"] = 640 if "height" not in kwargs: kwargs["height"] = 480 super().__init__(filename, **kwargs) self.frame.set_style({"Window": {"background_color": 0xFF000000, "border_width": 0}}) self.frame.set_build_fn(self.__build_window) self.__filename = filename def __build_window(self): """Called to build the widgets of the window""" # For now it's only one single widget imageview.ImageView(self.__filename, smooth_zoom=True, style={"ImageView": {"background_color": 0xFF000000}}) def destroy(self): pass
2,181
Python
33.093749
117
0.644658
omniverse-code/kit/exts/omni.kit.window.imageviewer/omni/kit/window/imageviewer/imageviewer_utils.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # import omni.kit.app def is_extension_loaded(extansion_name: str) -> bool: """ Returns True if the extension with the given name is loaded. """ def is_ext(ext_id: str, extension_name: str) -> bool: id_name = omni.ext.get_extension_name(ext_id) return id_name == extension_name app = omni.kit.app.get_app_interface() ext_manager = app.get_extension_manager() extensions = ext_manager.get_extensions() loaded = next((ext for ext in extensions if is_ext(ext["id"], extansion_name) and ext["enabled"]), None) return bool(loaded)
1,015
Python
35.285713
108
0.721182
omniverse-code/kit/exts/omni.kit.window.imageviewer/omni/kit/window/imageviewer/content_menu.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # from .imageviewer import ViewerWindows from .imageviewer_utils import is_extension_loaded def content_available(): """ Returns True if the extension "omni.kit.window.content_browser" is loaded. """ return is_extension_loaded("omni.kit.window.content_browser") class ContentMenu: """ When this object is alive, Content Browser has the additional context menu with the items that allow to view image files. """ def __init__(self, version: int = 2): if version != 2: raise RuntimeError("Only version 2 is supported") content_window = self._get_content_window() if content_window: view_menu_name = "Show Image" self.__view_menu_subscription = content_window.add_file_open_handler( view_menu_name, lambda file_path: self._on_show_triggered(view_menu_name, file_path), self._is_show_visible, ) else: self.__view_menu_subscription = None def _get_content_window(self): try: import omni.kit.window.content_browser as content except ImportError: return None return content.get_content_window() def _is_show_visible(self, content_url): """True if we can show the menu item View Image""" # List of available formats: carb/source/plugins/carb.imaging/Imaging.cpp return any( content_url.endswith(f".{ext}") for ext in ["bmp", "dds", "exr", "gif", "hdr", "jpeg", "jpg", "png", "psd", "svg", "tga"] ) def _on_show_triggered(self, menu, value): """Start watching for the layer and run the editor""" ViewerWindows().open_window(value) def destroy(self): """Stop all watchers and remove the menu from the content browser""" if self.__view_menu_subscription: content_window = self._get_content_window() if content_window: content_window.delete_file_open_handler(self.__view_menu_subscription) self.__view_menu_subscription = None ViewerWindows().close_all()
2,572
Python
36.289855
101
0.640747
omniverse-code/kit/exts/omni.kit.window.imageviewer/omni/kit/window/imageviewer/imageviewer_extension.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # import omni.ext from .content_menu import content_available from .content_menu import ContentMenu class ImageViewerExtension(omni.ext.IExt): def __init__(self): super().__init__() self.__imageviewer = None self.__extensions_subscription = None # noqa: PLW0238 self.__content_menu = None def on_startup(self, ext_id): # Setup a callback when any extension is loaded/unloaded app = omni.kit.app.get_app_interface() ext_manager = app.get_extension_manager() self.__extensions_subscription = ( # noqa: PLW0238 ext_manager.get_change_event_stream().create_subscription_to_pop( self._on_event, name="omni.kit.window.imageviewer" ) ) self.__content_menu = None self._on_event(None) def _on_event(self, event): """Called when any extension is loaded/unloaded""" if self.__content_menu: if not content_available(): self.__content_menu.destroy() self.__content_menu = None else: if content_available(): self.__content_menu = ContentMenu() def on_shutdown(self): if self.__imageviewer: self.__imageviewer.destroy() self.__imageviewer = None self.__extensions_subscription = None # noqa: PLW0238 if self.__content_menu: self.__content_menu.destroy() self.__content_menu = None
1,922
Python
33.963636
77
0.632154
omniverse-code/kit/exts/omni.kit.window.imageviewer/omni/kit/window/imageviewer/singleton.py
# Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # def singleton(class_): """A singleton decorator""" instances = {} def getinstance(*args, **kwargs): if class_ not in instances: instances[class_] = class_(*args, **kwargs) return instances[class_] return getinstance
697
Python
32.238094
76
0.725968
omniverse-code/kit/exts/omni.kit.window.imageviewer/omni/kit/window/imageviewer/tests/imageviewer_test.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and related documentation without an express # license agreement from NVIDIA CORPORATION is strictly prohibited. # from pathlib import Path from omni.ui.tests.test_base import OmniUiTest import omni.kit import omni.ui as ui from ..imageviewer import ViewerWindows class TestImageViewer(OmniUiTest): # Before running each test async def setUp(self): await super().setUp() extension_path = omni.kit.app.get_app().get_extension_manager().get_extension_path_by_module(__name__) self._golden_img_dir = Path(extension_path).joinpath("data").joinpath("tests").absolute() # After running each test async def tearDown(self): self._golden_img_dir = None await super().tearDown() async def test_general(self): window = await self.create_test_window() # noqa: PLW0612, F841 await omni.kit.app.get_app().next_update_async() viewer = ViewerWindows().open_window(f"{self._golden_img_dir.joinpath('lenna.png')}") viewer.flags = ui.WINDOW_FLAGS_NO_SCROLLBAR | ui.WINDOW_FLAGS_NO_TITLE_BAR | ui.WINDOW_FLAGS_NO_RESIZE viewer.position_x = 0 viewer.position_y = 0 viewer.width = 256 viewer.height = 256 # One frame to show the window and another to build the frame # And a dozen frames more to let the asset load for _ in range(20): await omni.kit.app.get_app().next_update_async() await self.finalize_test(golden_img_dir=self._golden_img_dir)
1,817
Python
36.10204
110
0.693451
omniverse-code/kit/exts/omni.kit.window.imageviewer/docs/CHANGELOG.md
# Changelog The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [1.0.6] - 2022-06-17 ### Changed - Properly linted ## [1.0.5] - 2021-09-20 ### Changed - Fixed unittest path to golden image. ## [1.0.4] - 2021-08-18 ### Changed - Fixed console_browser leak ## [1.0.3] - 2020-12-08 ### Added - Description, preview image and icon ### Changed - Fixed crash on exit ## [1.0.2] - 2020-11-25 ### Changed - Pasting an image URL into the content window's browser bar or double clicking opens the file. ## [1.0.1] - 2020-11-12 ### Changed - Fixed exception in Create ## [1.0.0] - 2020-07-19 ### Added - Adds context menu in the Content Browser
674
Markdown
18.852941
95
0.655786
omniverse-code/kit/exts/omni.kit.window.imageviewer/docs/README.md
# Image Viewer [omni.kit.window.imageviewer] It's The extension that can display stored graphical images in a new window. It can handle various graphics file formats.
168
Markdown
32.799993
76
0.797619
omniverse-code/kit/exts/omni.kit.window.audiorecorder/config/extension.toml
[package] title = "Kit Audio Recorder Window" category = "Audio" version = "1.0.1" description = "A simple audio recorder window" detailedDescription = """This adds a window for recording audio to file from an audio capture device. """ preview_image = "data/preview.png" authors = ["NVIDIA"] keywords = ["audio", "capture", "recording"] [dependencies] "omni.kit.audiodeviceenum" = {} "omni.audiorecorder" = {} "omni.ui" = {} "omni.kit.window.content_browser" = { optional=true } "omni.kit.window.filepicker" = {} "omni.kit.pip_archive" = {} "omni.usd" = {} "omni.kit.menu.utils" = {} [python.pipapi] requirements = ["numpy"] [[python.module]] name = "omni.kit.window.audiorecorder" [[test]] args = [ "--/renderer/enabled=pxr", "--/renderer/active=pxr", "--/renderer/multiGpu/enabled=false", "--/renderer/multiGpu/autoEnable=false", # Disable mGPU with PXR due to OM-51026, OM-53611 "--/renderer/multiGpu/maxGpuCount=1", "--/app/asyncRendering=false", "--/app/window/dpiScaleOverride=1.0", "--/app/window/scaleToMonitor=false", "--no-window", # Use the null device backend. # We need this to ensure the captured data is consistent. # We could use the capture test patterns mode, but there's no way to # synchronize the image capture with the audio capture right now, so we'll # have to just capture silence. "--/audio/deviceBackend=null", # needed for the UI test stuff "--/app/menu/legacy_mode=false", ] dependencies = [ "omni.hydra.pxr", "omni.kit.mainwindow", "omni.kit.ui_test", "carb.audio", ] stdoutFailPatterns.exclude = [ "*" # I don't want these but OmniUiTest forces me to use them ]
1,690
TOML
25.841269
94
0.666864