Get_default_viewport_window() doesn't work in Isaac Sim 2022.2

I have set up a simulation in Isaac Sim 2022.1.1 where I want to read out camera images. For this I have written a Python class, where first the default viewport window is read out and then the corresponding camera is activated.

#load default viewport:
self.vp_window = omni.kit.viewport_legacy.get_default_viewport_window()

#initialize the syntheticDataHelper:
#initialize the synthetic data helper class --> realsense back

self.vp_window.set_active_camera(self.cameraBackPrimPath)
self.sd_helper_Cam_Back.initialize_async(["rgb", "depth", "depthLinear"], self.vp_window)

#initialize the synthetic data helper class --> realsense front

self.vp_window.set_active_camera(self.cameraFrontPrimPath)
self.sd_helper_Cam_Front.initialize_async(["rgb", "depth", "depthLinear"], self.vp_window)

#initialize the synthetic data helper class --> realsense top


self.vp_window.set_active_camera(self.cameraTopPrimPath)
self.sd_helper_Cam_Top.initialize_async(["rgb", "depth", "depthLinear"], self.vp_window)

In Isaac Sim 2022.1.1 the code works without problems. Now I wanted to switch to the latest version (Isaac Sim 2022.2.0), but the function does not work anymore:

But the function “omni.kit.viewport_legacy.get_default_viewport_window()” returns NoneType and not an IViewportWindow object as in Isaac 2022.1.1.

<omni.kit.viewport_legacy._viewport_legacy.IViewportWindow object at 0x7f5a14c87c30>

Can anyone help me with this problem???

You can try this code:

viewport_handle = omni.kit.viewport_legacy.get_viewport_interface()
viewport_handle.get_viewport_window().set_active_camera(str(camera_path))

I tried the code snippets, but when I call:

viewport_handle.get_viewport_window().set_active_camera(str(camera_path))

the error occured: “NoneType” object has no attribute “set_active_camera”

Hi there,

this probably happens because you are using the legacy viewport, try the following instead:

from omni.kit.viewport.utility import get_active_viewport

viewport = get_active_viewport()

viewport.set_active_camera(path)
1 Like

Hi there,

Perfect, it works.

Many thanks for your help!

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