Skip to content

Commit

Permalink
Feat/add ov time scale (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
randallfrank authored and mariostieriansys committed Jul 17, 2024
1 parent 7fa2cee commit ac9e33c
Show file tree
Hide file tree
Showing 13 changed files with 134 additions and 24 deletions.
Binary file added doc/source/_static/omniverse_tool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
113 changes: 102 additions & 11 deletions doc/source/user_guide/omniverse_info.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ Omniverse System Configuration
------------------------------

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.
Please `install Omniverse <https://docs.omniverse.nvidia.com/install-guide/>`_ along
with one application like "Create" or "View" on your local system before
attempting to use this interface.


PyEnSight and EnSight Python API
Expand All @@ -46,6 +47,16 @@ in your own python, one can just use the API like this:
s.ensight.utils.omniverse.update()
.. note::

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.


From inside an EnSight session, the API is similar:

.. code-block:: python
Expand All @@ -65,12 +76,22 @@ From inside an EnSight session, the API is similar:
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
``ensight.utils.omniverse.update()`` command can be used to update the
USD data in Omniverse, reflecting any recent changes in the EnSight scene.

Starting with 2025 R1, one can also access Omniverse via an EnSight
user-defined tool:

Within an Omniverse Application
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. image:: /_static/omniverse_tool.png

This tool will only be available if EnSight detects an installed copy
of Omniverse. Clicking on "Connect to Omniverse" executes something
similar to the previous Python snippet and the button will change to
a mode where it just executes ``ensight.utils.omniverse.update()``.


PyEnSight/Omniverse kit from 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.
Expand All @@ -80,18 +101,88 @@ 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
At this point, the same pyensight script run in the Omniverse
``Script Editor`` panel 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.

The ``ansys.geometry.serviceui`` kit includes a GUI similar to the
EnSight 2025 R1 user-defined tool. It allows one to select a
target URI in Omniverse and the details of a gRPC connection
to a running EnSight. For example, if one launches EnSight with
``ensight.bat -grpc_server 2345``, then the uri: ``grpc://127.0.0.1:2345``
can to used to request a locally running EnSight to push the current
scene to Omniverse.

.. note::

The ``batch=False`` option used in the examples causes the EnSight
GUI to be displayed together with the Omniverse Composer GUI.
If the ``ansys.geometry.service`` and ``ansys.geometry.serviceui``
do not show up in the Community extensions list in Omniverse, then
it can be added to the ``Extension Search Paths`` list as:
``git://github.com/ansys/pyensight.git?branch=main&dir=exts``.

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.

Developers: Running a "dev" build from the Command Line
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Omniverse kits can be run as command line tools and
the ``ansys.geometry.service`` is designed to support this mode
of operation as well. For this to work, one needs a copy of the
pyensight wheel and the name of a ``kit`` executable. The pyensight wheel
can be built by checking out the repo and building it. One can
find the location of a kit via the ``Omniverse Launcher`` application
using the ``Settings`` option:

.. image:: /_static/omniverse_create_location.png

Consider an example where the create app has been installed and the
file ``C:\Users\me\AppData\Local\ov\pkg\create-2023.2.5\kit.bat``
exists. A copy of the pyensight repo is located and built here:
``D:\repos\pyensight``. With these conditions, one can run the extension
from the command line like this:

.. code-block:: bat
cd "C:\Users\me\AppData\Local\ov\pkg\create-2023.2.5"
.\kit.bat --ext-folder "D:\repos\pyensight\exts" --enable ansys.geometry.service --/exts/ansys.geometry.service/help=1
Will generate the following output in the logs:

.. code-block::
ANSYS Omniverse Geometry Service: ansys.geometry.service-0.8.5
--/exts/ansys.geometry.service/help=1
Display this help.
--/exts/ansys.geometry.service/run=1
Run the server.
--/exts/ansys.geometry.service/omniUrl=URL
Omniverse pathname. (default: omniverse://localhost/Users/test)
--/exts/ansys.geometry.service/dsgUrl=URL
Dynamic Scene Graph connection URL. (default: grpc://127.0.0.1:5234)
--/exts/ansys.geometry.service/securityCode=TOKEN
Dynamic Scene Graph security token. (default: )
--/exts/ansys.geometry.service/temporal=0|1
If non-zero, include all timeseteps in the scene. (default: False)
--/exts/ansys.geometry.service/vrmode=0|1
If non-zero, do not include a camera in the scene. (default: False)
--/exts/ansys.geometry.service/normalizeGeometry=0|1
If non-zero, remap the geometry to the domain [-1,-1,-1]-[1,1,1]. (default: False)
Documenting the various kit command line options. Using the ``run=1`` option will launch the server from
from the command line. This version of the service will be run using the version of the pyensight wheel
installed in the specified ``--ext-folder``. When run as above, the service will use the
latest release of the ansys.pyensight.core wheel. If a local build is located here:
``D:\repos\pyensight\dist\ansys_pyensight_core-0.9.0.dev0-py3-none-any.whl`` it can be
used in the above kit by installing it into the Omniverse kit Python:


.. code-block:: bat
.\kit\python.bat -m pip install D:\repos\pyensight\dist\ansys_pyensight_core-0.9.0.dev0-py3-none-any.whl
This version will be used instead of the older version in the PyPi repository.

Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def launch_server(self) -> None:
cmd.extend(["--ext-folder", kit_dir])
cmd.extend(["--enable", "ansys.geometry.service"])
if self.security_token:
cmd.append(f"--/exts/ansys.geometry.service/securityCode={self.security_token}")
cmd.append(f'--/exts/ansys.geometry.service/securityCode="{self.security_token}"')
if self.temporal:
cmd.append("--/exts/ansys.geometry.service/temporal=1")
if self.vrmode:
Expand Down
2 changes: 1 addition & 1 deletion exts/ansys.geometry.service/config/extension.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
# Semantic Versioning is used: https://semver.org/
version = "0.8.6"
version = "0.8.7"

# Lists people or organizations that are considered the "authors" of the package.
authors = ["ANSYS"]
Expand Down
5 changes: 4 additions & 1 deletion exts/ansys.geometry.service/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


## [0.9.0] - 2024-06-28
## [0.8.7] - 2024-07-12
- Support for time varying data and temporal scaling

## [0.8.4] - 2024-06-28
- Initial kit version of ANSYS Geometry Service Server

2 changes: 1 addition & 1 deletion exts/ansys.geometry.serviceui/config/extension.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
# Semantic Versioning is used: https://semver.org/
version = "0.8.6"
version = "0.8.7"

# Lists people or organizations that are considered the "authors" of the package.
authors = ["ANSYS"]
Expand Down
7 changes: 5 additions & 2 deletions exts/ansys.geometry.serviceui/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


## [0.9.0] - 2024-06-28
- Initial kit version of ANSYS Geometry Service GUI
## [0.8.7] - 2024-07-12
- Support for time varying data and temporal scaling

## [0.8.4] - 2024-06-28
- Initial kit version of ANSYS Geometry Service Server

Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ def launch_server(self) -> None:
cmd.extend(["--ext-folder", kit_dir])
cmd.extend(["--enable", "ansys.geometry.service"])
if self.security_token:
cmd.append(f"--/exts/ansys.geometry.service/securityCode={self.security_token}")
cmd.append(f'--/exts/ansys.geometry.service/securityCode="{self.security_token}"')
if self.temporal:
cmd.append("--/exts/ansys.geometry.service/temporal=1")
if self.vrmode:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
# Semantic Versioning is used: https://semver.org/
version = "0.8.6"
version = "0.8.7"

# Lists people or organizations that are considered the "authors" of the package.
authors = ["ANSYS"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


## [0.9.0] - 2024-06-28
## [0.8.7] - 2024-07-12
- Support for time varying data and temporal scaling

## [0.8.4] - 2024-06-28
- Initial kit version of ANSYS Geometry Service Server

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
# Semantic Versioning is used: https://semver.org/
version = "0.8.6"
version = "0.8.7"

# Lists people or organizations that are considered the "authors" of the package.
authors = ["ANSYS"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


## [0.9.0] - 2024-06-28
- Initial kit version of ANSYS Geometry Service GUI
## [0.8.7] - 2024-07-12
- Support for time varying data and temporal scaling

## [0.8.4] - 2024-06-28
- Initial kit version of ANSYS Geometry Service Server

9 changes: 8 additions & 1 deletion src/ansys/pyensight/core/utils/omniverse.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def create_connection(
temporal: bool = False,
live: bool = True,
debug_filename: str = "",
time_scale: float = 1.0,
options: dict = {},
) -> None:
"""Ensure that an EnSight dsg -> omniverse server is running
Expand Down Expand Up @@ -200,9 +201,13 @@ def create_connection(
If True, one can call 'update()' to send updated geometry to Omniverse.
If False, the Omniverse connection will push a single update and then
disconnect. Defaults to True.
time_scale : float
Multiply all EnSight time values by this factor before exporting to Omniverse.
The default is 1.0.
debug_filename : str
If the name of a file is provided, it will be used to save logging information on
the connection between EnSight and Omniverse.
the connection between EnSight and Omniverse. This option is no longer supported,
but the API remains for backwards compatibility.
options : dict
Allows for a fallback for the grpc host/port and the security token.
"""
Expand Down Expand Up @@ -237,6 +242,8 @@ def create_connection(
cmd.append("--/exts/ansys.geometry.service/vrmode=1")
if normalize_geometry:
cmd.append("--/exts/ansys.geometry.service/normalizeGeometry=1")
if time_scale != 1.0:
cmd.append(f"--/exts/ansys.geometry.service/timeScale={time_scale}")
cmd.append(f"--/exts/ansys.geometry.service/omniUrl={omniverse_path}")
cmd.append(f"--/exts/ansys.geometry.service/dsgUrl={dsg_uri}")
cmd.append("--/exts/ansys.geometry.service/run=1")
Expand Down

0 comments on commit ac9e33c

Please sign in to comment.