### Linking Omniverse App (Windows) Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/README.md This script creates a folder link named `app` to the Omniverse Kit app installed from the Omniverse Launcher, improving the developer experience. It automatically selects the recommended app if multiple are installed, or allows specifying an app or path explicitly. ```bash > link_app.bat ``` -------------------------------- ### PointInstancer Setup in command.py Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/exts/omni.example.ui_scatter_tool/Tutorial/Scatter_Tool_Guide.md This code sets up the PointInstancer by defining it on the USD stage, creating a prototypes relationship, adding targets for each prim name, and setting the positions and proto indices attributes. ```python def do(self): stage = self._get_stage() # Set up PointInstancer instancer = UsdGeom.PointInstancer.Define(stage, Sdf.Path(self._path_to)) attr = instancer.CreatePrototypesRel() for name in self._prim_names: attr.AddTarget(Sdf.Path(name)) instancer.CreatePositionsAttr().Set(self._positions) instancer.CreateProtoIndicesAttr().Set(self._proto_indices) ``` -------------------------------- ### Linking Omniverse App with Specific Path (Windows) Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/README.md This command creates a link to an Omniverse application at a specific path using the link_app.bat script. This is useful when the application is not in the default installation location or when targeting a specific version. ```bash > link_app.bat --path "C:/Users/bob/AppData/Local/ov/pkg/create-2022.1.3" ``` -------------------------------- ### Implementing Scatter Logic in Python Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/exts/omni.example.ui_scatter_tool/Tutorial/Scatter_Tool_Guide.md This code defines the `_on_scatter` function, which is called when the "Scatter" button is clicked. It retrieves the selected prim names, gets the scatter properties from the UI models, and calls the `duplicate_prims` function to perform the scattering. The function handles cases where no prims are selected and passes the scatter properties (count, distance, randomization, seed) to the `duplicate_prims` function. ```python def _on_scatter(self): """Called when the user presses the "Scatter" button""" prim_names = [i.strip() for i in self._source_prim_model.as_string.split(",")] if not prim_names: prim_names = get_selection() if not prim_names: pass transforms = scatter( count=[m.as_int for m in self._scatter_count_models], distance=[m.as_float for m in self._scatter_distance_models], randomization=[m.as_float for m in self._scatter_random_models], id_count=len(prim_names), seed=self._scatter_seed_model.as_int, ) duplicate_prims( transforms=transforms, prim_names=prim_names, target_path=self._scatter_prim_model.as_string, mode=self._scatter_type_model.get_current_item().as_string, ) ``` -------------------------------- ### Cloning the Scatter Project Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/exts/omni.example.ui_scatter_tool/Tutorial/Scatter_Tool_Guide.md This bash command clones the `tutorial-start` branch of the `kit-extension-sample-scatter` GitHub repository. This repository contains the assets used in the tutorial. ```bash git clone -b tutorial-start https://github.com/NVIDIA-Omniverse/kit-extension-sample-scatter.git ``` -------------------------------- ### ScatterCreatePointInstancerCommand Initialization Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/exts/omni.example.ui_scatter_tool/Tutorial/Scatter_Tool_Guide.md This code initializes the ScatterCreatePointInstancerCommand class, setting the path, transforming the input transforms list, and extracting positions and proto indices. It also copies the prim names. ```python def __init__( self, path_to: str, transforms: List[Tuple[Gf.Matrix4d, int]], prim_names: List[str], stage: Optional[Usd.Stage] = None, context_name: Optional[str] = None, ): omni.usd.commands.stage_helper.UsdStageHelper.__init__(self, stage, context_name) self._path_to = path_to # We have it like [(tr, id), (tr, id), ...] # It will be transformaed to [[tr, tr, ...], [id, id, ...]] unzipped = list(zip(*transforms)) self._positions = [m.ExtractTranslation() for m in unzipped[0]] self._proto_indices = unzipped[1] self._prim_names = prim_names.copy() ``` -------------------------------- ### ScatterCreatePointInstancerCommand Arguments Documentation Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/exts/omni.example.ui_scatter_tool/Tutorial/Scatter_Tool_Guide.md This docstring describes the arguments for the ScatterCreatePointInstancerCommand class, including path_to (the path for the new prims), transforms (pairs containing transform matrices and IDs), and prim_names (prims to duplicate). ```python """ Create PointInstancer undoable **Command**. ### Arguments: `path_to: str` The path for the new prims `transforms: List` Pairs containing transform matrices and ids to apply to new objects `prim_names: List[str]` Prims to duplicate """ ``` -------------------------------- ### Linking Omniverse App with Specific App (Windows) Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/README.md This command creates a link to a specific Omniverse application (e.g., 'code') using the link_app.bat script. This allows developers to target a particular version or type of Omniverse application for development and testing. ```bash > link_app.bat --app code ``` -------------------------------- ### Building Main UI with Scrolling Frame in Python Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/exts/omni.example.ui_scatter_tool/Tutorial/Scatter_Tool_Guide.md This code defines the `_build_fn` function, which constructs the main UI for the Scatter extension. It uses `ui.ScrollingFrame` to allow scrolling if the content exceeds the window size. The function calls other UI building functions (`_build_source`, `_build_scatter`, `_build_axis`) to create the individual UI elements and arranges them vertically using `ui.VStack`. Finally, it adds a "Scatter" button that triggers the scattering process. ```python def _build_fn(self): """ The method that is called to build all the UI once the window is visible. """ # Frame with ui.ScrollingFrame(): # Column with ui.VStack(height=0): # Build it self._build_source() self._build_scatter() self._build_axis(0, "X Axis") self._build_axis(1, "Y Axis") self._build_axis(2, "Z Axis") # The Go button ui.Button("Scatter", clicked_fn=self._on_scatter) ``` -------------------------------- ### Point Generation and Matrix Creation in scatter.py Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/exts/omni.example.ui_scatter_tool/Tutorial/Scatter_Tool_Guide.md This code initializes the random number generator and loops through the specified counts to generate sets of points. It creates a matrix with position randomization for each axis using the provided distance and randomization values. ```python # Initialize the random number generator. random.seed(seed) for i in range(count[0]): x = (i - 0.5 * (count[0] - 1)) * distance[0] for j in range(count[1]): y = (j - 0.5 * (count[1] - 1)) * distance[1] for k in range(count[2]): z = (k - 0.5 * (count[2] - 1)) * distance[2] # Create a matrix with position randomization result = Gf.Matrix4d(1) result.SetTranslate( Gf.Vec3d( x + random.random() * randomization[0], y + random.random() * randomization[1], z + random.random() * randomization[2], ) ) id = int(random.random() * id_count) yield (result, id) ``` -------------------------------- ### Laying Out the Frame with VStack and HStack in Python Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/exts/omni.example.ui_scatter_tool/Tutorial/Scatter_Tool_Guide.md This Python code snippet demonstrates how to use `VStack` and `HStack` to create a column and row layout within the `CollapsableFrame`. `VStack` creates a vertical stack container, while `HStack` creates a horizontal stack container. ```python def _build_source(self): """Build the widgets of the "Source" group""" # Create frame with ui.CollapsableFrame("Source", name="group"): # Create column with ui.VStack(height=0, spacing=SPACING): # Create row with ui.HStack(): ``` -------------------------------- ### Creating a Collapsable Frame in Python Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/exts/omni.example.ui_scatter_tool/Tutorial/Scatter_Tool_Guide.md This Python code snippet creates a `CollapsableFrame` within the `_build_source()` function. The `CollapsableFrame` is a UI widget that allows hiding or showing its content, providing a way to organize the scatter tool's UI. ```python def _build_source(self): """Build the widgets of the "Source" group""" # Create frame with ui.CollapsableFrame("Source", name="group"): ``` -------------------------------- ### Scatter Function Arguments Documentation Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/exts/omni.example.ui_scatter_tool/Tutorial/Scatter_Tool_Guide.md This docstring describes the arguments for the scatter function, including count (number of matrices per axis), distance (distance between objects per axis), randomization (random distance per axis), id_count (count of different IDs), and seed (random seed). ```python """ Returns generator with pairs containing transform matrices and ids to arrange multiple objects. ### Arguments: `count: List[int]` Number of matrices to generage per axis `distance: List[float]` The distance between objects per axis `randomization: List[float]` Random distance per axis `id_count: int` Count of differrent id `seed: int` If seed is omitted or None, the current system time is used. If seed is an int, it is used directly. """ ``` -------------------------------- ### Scatter Function Definition in scatter.py Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/exts/omni.example.ui_scatter_tool/Tutorial/Scatter_Tool_Guide.md This code defines the scatter function with parameters for count, distance, randomization, id_count, and seed. It generates transform matrices and IDs to arrange multiple objects based on these parameters. ```python def scatter( count: List[int], distance: List[float], randomization: List[float], id_count: int = 1, seed: Optional[int] = None ): ... ``` -------------------------------- ### Undo Function Definition in command.py Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/exts/omni.example.ui_scatter_tool/Tutorial/Scatter_Tool_Guide.md This code defines the undo function, which is called when the user undoes the scatter operation. It restores the prior state by deleting the PointInstancer using the DeletePrimsCommand. ```python def undo(self): delete_cmd = omni.usd.commands.DeletePrimsCommand([self._path_to]) delete_cmd.do() ``` -------------------------------- ### Building Axis UI with Collapsable Frame in Python Source: https://github.com/nvidia-omniverse/kit-extension-sample-scatter/blob/main/exts/omni.example.ui_scatter_tool/Tutorial/Scatter_Tool_Guide.md This code defines the `_build_axis` function, which creates a UI element for controlling scattering along a specific axis (X, Y, or Z). It uses `ui.CollapsableFrame` to group the axis controls and includes `ui.IntDrag` and `ui.FloatDrag` widgets for adjusting object count, distance, and randomization. The function takes the axis ID and name as input and uses models to store the widget values. ```python def _build_axis(self, axis_id, axis_name): """Build the widgets of the "X" or "Y" or "Z" group""" with ui.CollapsableFrame(axis_name, name="group"): # Column with ui.VStack(height=0, spacing=SPACING): # Row with ui.HStack(): ui.Label("Object Count", name="attribute_name", width=self.label_width) ui.IntDrag(model=self._scatter_count_models[axis_id], min=1, max=100) # Row with ui.HStack(): ui.Label("Distance", name="attribute_name", width=self.label_width) ui.FloatDrag(self._scatter_distance_models[axis_id], min=0, max=10000) # Row with ui.HStack(): ui.Label("Random", name="attribute_name", width=self.label_width) ui.FloatDrag(self._scatter_random_models[axis_id], min=0, max=10000) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.