omni.flux.custom_tags.core
SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
- class omni.flux.custom_tags.core.CustomTagsCore(context_name: str = '')
Bases:
object
- add_tag_to_prim(prim_path: pxr.Sdf.Path | str, tag_path: pxr.Sdf.Path | str)
Assign a tag to a given prim
This will add the prim to the tag’s USD Collection
- Parameters
prim_path – The prim to assign the tag to
tag_path – The Prim Path of the tag to assign
- create_tag(tag_name: str, use_undo_group: bool = True)
Create a new tag in the current stage.
This method will also create the /CustomTags prim if it doesn’t exist,
- Parameters
tag_name – The name of the tag (USD Collection) to create
use_undo_group – Whether an undo group should be used or not. If the method if already part of an undo group, this should be set to False.
- delete_tags(tag_paths: list[pxr.Sdf.Path | str], use_undo_group: bool = True)
Delete some tags available in the current stage
- Parameters
tag_paths – A list of Prim Paths to the tags (USD Collection) to delete
use_undo_group – Whether an undo group should be used or not. If the method if already part of an undo group, this should be set to False.
- destroy()
- get_all_tags() → list[pxr.Sdf.Path]
Get all available tags in the current stage
- Returns
A list of Prim Paths for the existing Tags (USD Collections)
- get_prim_tags(prim: pxr.Usd.Prim) → list[pxr.Sdf.Path]
Get all the tags assigned to a given prim
- Parameters
prim – The prim to get tags for
- Returns
A list of Prim Paths for the tags (USD Collections) assigned to the prim
- static get_tag_name(tag_path: pxr.Sdf.Path) → str | None
Get the tag name from the Prim Path
- Parameters
tag_path – The prim path to the tag (USD Collection)
- Returns
The tag name if one is found, None otherwise
- get_tag_prims(tag_path: pxr.Sdf.Path) → list[pxr.Sdf.Path]
Get all the prims assigned to a given tag
- Parameters
tag_path – The prim path to the tag (USD Collection)
- Returns
A list of prim paths for the prims assigned to the tag
- get_unique_tag_path(new_tag_name: str, current_tag_path: Optional[pxr.Sdf.Path] = None, existing_tag_paths: Optional[list[pxr.Sdf.Path]] = None) → pxr.Sdf.Path
Get a unique tag path based on a tag name.
Can also be used to get a renamed tag’s path.
Will ensure that the returned path is unused if the existing_tag_paths argument is provided.
- Parameters
new_tag_name – The new tag’s desired name
current_tag_path – The full Prim Path to the tag to be renamed
existing_tag_paths – The list of existing tags to compare against when incrementing the new tag’s name
- Returns
A unique Prim Path for the new tag
- static increment_tag_name(new_tag_name: str, existing_tag_names: list[str]) → str
Increment the tag name to a unique name if required, otherwise return the same tag name.
Incremented tag names will have the format: tag_name_01 where _01 is the incremented suffix.
- Parameters
new_tag_name – The desired tag name for the new collection
existing_tag_names – A list of existing tag names
- Returns
A unique tag name
- prim_has_tag(prim: pxr.Usd.Prim, tag_path: pxr.Sdf.Path) → bool
A utility function to check if a prim was assigned a given tag
- Parameters
prim – The prim to evaluate
tag_path – The Prim Path to the tag to evaluate
- Returns
True if the prim is assigned the given tag, False otherwise
- remove_tag_from_prim(prim_path: pxr.Sdf.Path | str, tag_path: pxr.Sdf.Path | str)
Unassign a tag from a given prim
This will remove the prim from the tag’s USD Collection
- Parameters
prim_path – The prim to unassign the tag from
tag_path – The Prim Path of the tag to unassign
- rename_tag(tag_path: pxr.Sdf.Path | str, new_tag_name: str)
Rename an existing tag (USD Collection)
- Parameters
tag_path – The existing tag’s Prim Path
new_tag_name – The new name that should be given to the existing tag