Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Omniverse kits #385

Merged
merged 9 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
*.so
*.o
*.cache
*.whl
.pytest_cache/
*/__pycache__

Expand Down
5 changes: 4 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ repos:
-r,
-x, "venv/*, tests/*"
]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
hooks:
- id: mypy
# Exclude only works here, not in config files
exclude: "tests/|doc/"
exclude: "tests/|doc/|src/ansys/pyensight/core/exts/|exts/"


- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
Expand All @@ -46,4 +48,5 @@ repos:
- id: check-yaml
- id: trailing-whitespace
- id: check-added-large-files
exclude: "src/ansys/pyensight/core/exts/[^\/]+/data/|exts/[^\/]+/data/"
- id: check-case-conflict
Binary file added doc/source/_static/omniverse_extension.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
117 changes: 70 additions & 47 deletions doc/source/user_guide/omniverse_info.rst
Original file line number Diff line number Diff line change
@@ -1,74 +1,97 @@
.. _omniverse_info:

BETA: Omniverse Interface
=========================
PyEnSight/ANSYS Omniverse Interface
===================================

This release of PyEnSight includes a technical preview of an interface
to export the surfaces in the current EnSight scene to an Omniverse
server. This functionality is was developed against the "203" (2023.x)
version of Omniverse. Other versions may or may not work. The interface
supports EnSight 2023 R2 or later.
This release of PyEnSight includes an interface to export the surfaces
in the current EnSight scene to an Omniverse server. This functionality
is was developed against the "203" (2023.x) version of Omniverse. Other
versions may or may not work. The interface supports EnSight 2023 R2
or later.

Python Interpreter Configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

To use this functionality, an installation of Omniverse is required
and the PyEnSight module must be used from within an Omniverse
Python interpreter. In most cases, the script editor in the USD
Composer application. To install PyEnSight into the Composer Python
interpreter the following script can be run in the embedded script
editor (``Windows->Script Editor`` menu):

.. code-block::

import omni.kit.pipapi
omni.kit.pipapi.install("ansys-pyensight-core")


It is also possible to install the module using the command line.
To do this, one needs to find the installation location of the target
tool. Looking at the settings for "Create":
The API is available through a PyEnSight session instance, from EnSight
Python directly as (ensight.utils.omniverse for 2025 R1 and later) and
from within Omniverse applications via the ansys.geometry.service and
ansys.geometry.serviceui kit extensions.

.. image:: /_static/omniverse_create_location.png
The Python API is defined here: :class:`Omniverse<ansys.pyensight.core.utils.omniverse.Omniverse>`.

the install path can be found in the Omniverse GUI and the following
may be run:

.. code-block:: shell
Omniverse System Configuration
------------------------------

cd C:\Users\sampleuser\AppData\Local\ov\pkg\create-2023.2.5
kit\python.bat -m pip install ansys-pyensight-core
To use this functionality, a local installation of Omniverse is required.
Install Omniverse along with one application like "Create" or "View" on
your local system.


to install pyensight.

Basic Example
^^^^^^^^^^^^^
PyEnSight and EnSight Python API
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The following can be run from inside the USD Composer script panel following
the previous install. It can also be executed by the ``kit\python.bat``
interpreter, same as the one used during the configuration step.
It assumes there is a local Nucleus server running that can be accessed
via the URI: ``omniverse://localhost/Users/water``.
The ``omniverse`` pyensight module will look for and leverage locally installed
Omniverse to provide its APIs. If you are using the
`ansys-pyensight-core <https://pypi.org/project/ansys-pyensight-core/>`_ module
in your own python, one can just use the API like this:

.. code-block:: python

from ansys.pyensight.core import LocalLauncher
s = LocalLauncher(batch=False).start()
s.load_example("waterbreak.ens")
# Start a new connection between EnSight and Omniverse
uri = "omniverse://localhost/Users/water"
s.ensight.utils.omniverse.create_connection(uri)
# Do some more work...
# Push a scene update
s.ensight.utils.omniverse.update()


From inside an EnSight session, the API is similar:

.. code-block:: python

After running the script, scene will appear in the Nucleus tree view as ``User/water``.
The file ``dsg_scene.usd`` can be loaded into Composer. The
# Start a DSG server in EnSight first
(_, grpc_port, security) = ensight.objs.core.grpc_server(port=0, start=True)
# Start a new connection between the EnSight DSG server and Omniverse
options = {"host": "127.0.0.1", "port": str(grpc_port)}
if security:
options["security"] = security
uri = "omniverse://localhost/Users/water"
ensight.utils.omniverse.create_connection(uri, options=options)
# Do some more work...
# Push a scene update
ensight.utils.omniverse.update()


After running the script, the scene will appear in the Nucleus tree view as
``User/water``. The file ``dsg_scene.usd`` can be loaded into Composer. The
``s.ensight.utils.omniverse.update()`` command can be used to update the
USD data in Omniverse, reflecting any recent changes in the EnSight scene.


Within an Omniverse Application
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

To install the service (and the pyensight module) into an Omniverse
application, one can install is via the third party extensions dialog.
Select the ``Extensions`` option from the ``Window`` menu. Select
third party extensions and filter by ``ANSYS``. Enabling the extension
will install it, along with the ansys.pyensight.core module.

.. image:: /_static/omniverse_extension.png

At this point, the same pyensight script can be used to connect to
an EnSight session or the GUI panel can be used to connect to a
copy of EnSight that was launched with the ``-grpc_server {port}``
option specified.


.. note::

The ``batch=False`` option cause the EnSight GUI to be displayed
together with the Omniverse Composer GUI. Also, care must be taken
to close the EnSight session before exiting Composer or is it possible
to leave the EnSight instance running.
The ``batch=False`` option used in the examples causes the EnSight
GUI to be displayed together with the Omniverse Composer GUI.

Also, care must be taken to close the EnSight session before
exiting an Omniverse application hosting a pyensight session or is
it possible to leave the EnSight instance running.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .extension import *
Loading
Loading