Viewport disable_selection not working as expected

When I try to call omni.kit.viewport.utility.disable_selection in a custom kit app, regardless of whether I set disable_click to True or False, it seems to disable click on the viewport.

I was able to replicate this in the current USD Composer with a fresh extension based on the extension template. The contents of the on_startup function are pasted in below:

    self._window = ui.Window("My Window", width=300, height=300)
    with self._window.frame:
        with ui.VStack():
            label = ui.Label("")

            def on_click():
                self._disable_selection = disable_selection(get_active_viewport(), False)

            def on_reset():
                self._disable_selection = None


            with ui.HStack():
                ui.Button("Disable Selection", clicked_fn=on_click)
                ui.Button("Reset", clicked_fn=on_reset)

So are you trying to Enable or Disable people being able to select objects in the viewport ? Please tell me exactly what you require. You may be using the wrong command.

I want to disable selection while keeping other mouse interactions.

In this instance you code is not correct. The reset option code path never sets the select back to True, it just wipes out the class attribute where you set the value to False.

In theory when garbage collection happens the fact that the object was deleted should cause the selection to reset, but garbage collection in Python isn’t deterministic. You should try making your own on_reset() fn explicitly set the value to True.

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