Viewport Next's set_enabled_picking

In the legacy viewport, the code below can be used to disable object picking (selecting elements in stage).
What’s the equivalent when using Viewport Next?

import omni.ui as ui
import omni.kit.viewport.utility as vut

win = vut.get_active_viewport_window()
win.legacy_window.set_enabled_picking(False)

Thanks!

Hi @jordio. You could do this which works the same for both viewports.

import omni.usd

ctx = omni.usd.get_context()
# Makes everything unpickable by specifying the stage's PseudoRoot.
# More flexible too because you can make specific prim paths unpickable.
ctx.set_pickable("/", False)

I’ve reached out to the devs to see if they have any other guidance.

Devs said that we don’t have a replacement for that API yet in Viewport Next, but that what I shared with you is an good approach for now.

Thanks @mati-nvidia, this does disable the picking of stage elements.
Unfortunately however, this doesn’t disable the selection rectangle when one drags the mouse - which set_enabled_picking() does.

I think it would be important to have some standard way of managing the modality of tools. For example, an extension that provides a new tool to appear in the toolbar, should have a way to coordinate access to the viewport, so that picking and selection from Kit’s Select or Transform tools does not collide with whatever the tool is doing, (when selected).
This can somewhat be done with monitoring carb.settings and using set_enabled_picking() and is_manipulating_camera(), but a coordinated way with the toolbar could help a lot…

Anyway, thanks!

Hi Jorge. One more option the developers have for you for now. You can try to disable events downstream from within you Frame:

    def attach_scene_view(self):
        self._viewport = get_active_viewport_window()
        if not self._viewport:
            return
        with self._viewport.get_frame(<unique_frame_id>):
            self._clip_vstack = omni.ui.VStack(content_clipping=0)
            with self._clip_vstack:
                ...

    def _enable_pick(self, enable):
        if(enable):
            self._clip_vstack.content_clipping = 0
        else:
            self._clip_vstack.content_clipping = 1

This is a great way to completely disable the viewport while still accepting the tracked frame events. Unfortunately it also completely disables camera navigation which might be a bit too much. (but can be useful for localized editing)

I guess that legacy viewport’s set_enabled_picking() is the way to go for now.

Thanks @mati-nvidia!

Ah, darn. The team is definitely working on a better way to manage the various manipulators for VP Next and your feedback was well-received. I was just hoping to find a workaround for you in the meantime.

Your help is much appreciated @mati-nvidia!

VP Next will probably one day have support for this functionality. Until then, the current viewport works fine…

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