Change gizmo from move to rotate directly in code

Is there a way to change the “selection” from move to rotate and the other way using omnvierse code API?

Here is some sample code for enabling different tools:

import omni.kit.window.toolbar
from omni.kit.window.toolbar.builtin_tools.transform_button_group import TransformButtonGroup
import carb

toolbar = omni.kit.window.toolbar.get_instance()
settings  = carb.settings.get_settings()

## Selection Mode ##
# Prim Mode = True, Model Mode = False
button = toolbar.get_widget("select_mode")
button.model.set_value(False)

## Selection Tool ##
button = toolbar.get_widget("select_op")
button.model.set_value(True)

## Move Tool ##
button = toolbar.get_widget("move_op")
button.model.set_value(True)
# Changing the setting for whether to move in local or global mode.
settings.set(TransformButtonGroup.TRANSFORM_MOVE_MODE_SETTING, "local")
settings.set(TransformButtonGroup.TRANSFORM_MOVE_MODE_SETTING, "global")

## Rotate Tool ##
button = toolbar.get_widget("rotate_op")
button.model.set_value(True)
# Changing the setting for whether to rotate in local or global mode.
settings.set(TransformButtonGroup.TRANSFORM_ROTATE_MODE_SETTING, "local")
settings.set(TransformButtonGroup.TRANSFORM_ROTATE_MODE_SETTING, "global")

## Scale Tool ##
button = toolbar.get_widget("scale_op")
button.model.set_value(True)

## Snapping Mode ##
# Snapping Enabled = True, Snapping Disabled = False
button = toolbar.get_widget("snap")
button.model.set_value(True)

You could also use the keyboard hotkeys to change tools programmatically.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.