import omni.kit.commands
from omni.kit.property.tagging import AddTagCommand, RemoveTagCommand, UpdateTagCommand
# Common asset path for all operations
asset_path = "omniverse://localhost/Projects/MyAsset.usd"
# ----- Adding Tags -----
tag_to_add = "appearance.Car"
# Method 1: Execute the add command through the command system
omni.kit.commands.execute("AddTag", asset_path=asset_path, tag=tag_to_add)
# Method 2: Create and execute the add command directly with excluded tag option
add_cmd = AddTagCommand(asset_path=asset_path, tag=tag_to_add, excluded="appearance.Truck")
add_cmd.do()
# ----- Removing Tags -----
tag_to_remove = "appearance.Car"
# Remove a tag using the command system
omni.kit.commands.execute("RemoveTag", asset_path=asset_path, tag=tag_to_remove)
# ----- Updating Tags -----
old_tag = "appearance.Sedan"
new_tag = "appearance.SUV"
# Update a tag using direct command instantiation
update_cmd = UpdateTagCommand(asset_path=asset_path, old_tag=old_tag, new_tag=new_tag)
update_cmd.do()