How to close a Viewport programmatically


Isaac Sim Version: 2022.1.0

I am developing a standalone app and I created a viewport windows as follows

viewpoint_interface = omni.kit.viewport_legacy.get_viewport_interface()
viewport_instance = viewpoint_interface.create_instance()
viewport_window = viewpoint_interface.get_viewport_window(viewport_instance)

I would like to close the viewport window (it should disappear in the Isaac Sim GUI) within the Python script. May I know the correct way to close it gracefully while the app is still running?

Things I tried:

del viewport_instance (no effect)
del viewport_window (no effect)

→ This throws the error [] AttributeError: ‘dict’ object has no attribute ‘remove’
.local/share/ov/pkg/isaac_sim-2022.1.0/kit/extscore/omni.syntheticdata/omni/syntheticdata/scripts/ _on_update
within the ViewportLegacy class

I also tried to import the ViewportLegacy in the file above and try to use the close close_viewports but I could not find the correct way to import it

Any help would be appreciated thanks!

1 Like

Hi @tengfoong.lam

As far as I know, and searching inside available code, you can use show_hide_window for that purpose.
It doesn’t really close the viewport, I know…

1 Like

Thanks for the reply.

Your suggestion kind of solves my problem because running too many visible viewports causes my system to run out of memory (Vulkan shader) so turning off the visibility means I do not have this problem anymore

However, this is probably not as long term solution as you hinted since
shows that the number of instances increases which is a bit worrying

Destroying viewports is not possible with the legacy viewport API.
Future releases of isaac sim will be switching to viewport 2, which should provide more control over this.

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