ansys-pyensight-core 0.6.2__tar.gz → 0.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ansys-pyensight-core might be problematic. Click here for more details.
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/PKG-INFO +7 -7
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/README.rst +1 -1
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/pyproject.toml +8 -8
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/dockerlauncher.py +2 -2
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/session.py +51 -10
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/utils/export.py +105 -2
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/utils/support.py +43 -6
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/LICENSE +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/__init__.py +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/deep_pixel_view.html +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/enscontext.py +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/enshell_grpc.py +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/ensight_grpc.py +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/ensobj.py +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/launch_ensight.py +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/launcher.py +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/listobj.py +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/locallauncher.py +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/py.typed +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/renderable.py +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/sgeo_poll.html +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/utils/__init__.py +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/utils/adr.py +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/utils/parts.py +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/utils/query.py +0 -0
- {ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/utils/views.py +0 -0
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ansys-pyensight-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.7.0
|
|
4
4
|
Summary: A python wrapper for Ansys EnSight
|
|
5
5
|
Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
|
|
6
6
|
Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>
|
|
7
|
-
Requires-Python: >=3.
|
|
7
|
+
Requires-Python: >=3.9,<4
|
|
8
8
|
Description-Content-Type: text/x-rst
|
|
9
9
|
Classifier: Development Status :: 4 - Beta
|
|
10
10
|
Classifier: Intended Audience :: Science/Research
|
|
11
11
|
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
12
12
|
Classifier: License :: OSI Approved :: MIT License
|
|
13
13
|
Classifier: Operating System :: OS Independent
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.9
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Requires-Dist: importlib-metadata>=4.0; python_version<='3.8'
|
|
19
19
|
Requires-Dist: ansys-api-pyensight==0.3.2
|
|
20
20
|
Requires-Dist: requests>=2.28.2
|
|
21
|
-
Requires-Dist:
|
|
21
|
+
Requires-Dist: docker>=6.1.0
|
|
22
22
|
Requires-Dist: urllib3<2
|
|
23
23
|
Requires-Dist: typing>=3.7.4.3
|
|
24
24
|
Requires-Dist: typing-extensions>=4.5.0
|
|
@@ -35,7 +35,7 @@ Requires-Dist: ansys-sphinx-theme==0.9.9 ; extra == "doc"
|
|
|
35
35
|
Requires-Dist: sphinx-copybutton==0.5.2 ; extra == "doc"
|
|
36
36
|
Requires-Dist: sphinx-gallery==0.13.0 ; extra == "doc"
|
|
37
37
|
Requires-Dist: sphinxcontrib-mermaid==0.9.2 ; extra == "doc"
|
|
38
|
-
Requires-Dist:
|
|
38
|
+
Requires-Dist: docker>=6.1.0 ; extra == "doc"
|
|
39
39
|
Requires-Dist: matplotlib==3.7.2 ; extra == "doc"
|
|
40
40
|
Requires-Dist: requests>=2.28.2 ; extra == "doc"
|
|
41
41
|
Requires-Dist: sphinxcontrib.jquery==4.1 ; extra == "doc"
|
|
@@ -47,7 +47,7 @@ Requires-Dist: dill>=0.3.5.1 ; extra == "tests"
|
|
|
47
47
|
Requires-Dist: pytest-mock==3.10.0 ; extra == "tests"
|
|
48
48
|
Requires-Dist: urllib3==1.26.10 ; extra == "tests"
|
|
49
49
|
Requires-Dist: requests>=2.28.2 ; extra == "tests"
|
|
50
|
-
Requires-Dist:
|
|
50
|
+
Requires-Dist: docker>=6.1.0 ; extra == "tests"
|
|
51
51
|
Project-URL: Changelog, https://github.com/ansys/pyensight/blob/main/CHANGELOG.rst
|
|
52
52
|
Project-URL: Documentation, https://ensight.docs.pyansys.com/
|
|
53
53
|
Project-URL: Homepage, https://github.com/ansys/pyensight
|
|
@@ -131,7 +131,7 @@ Installation
|
|
|
131
131
|
------------
|
|
132
132
|
To use PyEnSight, you must have a locally installed and licensed copy of
|
|
133
133
|
Ansys EnSight 2022 R2 or later. The ``ansys-pyensight-core`` package supports
|
|
134
|
-
Python 3.
|
|
134
|
+
Python 3.9 through Python 3.12 on Windows and Linux.
|
|
135
135
|
|
|
136
136
|
Two modes of installation are available:
|
|
137
137
|
|
|
@@ -72,7 +72,7 @@ Installation
|
|
|
72
72
|
------------
|
|
73
73
|
To use PyEnSight, you must have a locally installed and licensed copy of
|
|
74
74
|
Ansys EnSight 2022 R2 or later. The ``ansys-pyensight-core`` package supports
|
|
75
|
-
Python 3.
|
|
75
|
+
Python 3.9 through Python 3.12 on Windows and Linux.
|
|
76
76
|
|
|
77
77
|
Two modes of installation are available:
|
|
78
78
|
|
|
@@ -6,10 +6,10 @@ build-backend = "flit_core.buildapi"
|
|
|
6
6
|
|
|
7
7
|
[project]
|
|
8
8
|
name = "ansys-pyensight-core"
|
|
9
|
-
version = "0.
|
|
9
|
+
version = "0.7.0"
|
|
10
10
|
description = "A python wrapper for Ansys EnSight"
|
|
11
11
|
readme = "README.rst"
|
|
12
|
-
requires-python = ">=3.
|
|
12
|
+
requires-python = ">=3.9,<4"
|
|
13
13
|
license = {file = "LICENSE"}
|
|
14
14
|
authors = [{name = "ANSYS, Inc.", email = "pyansys.core@ansys.com"}]
|
|
15
15
|
maintainers = [{name = "ANSYS, Inc.", email = "pyansys.core@ansys.com"}]
|
|
@@ -19,17 +19,17 @@ classifiers = [
|
|
|
19
19
|
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
20
20
|
"License :: OSI Approved :: MIT License",
|
|
21
21
|
"Operating System :: OS Independent",
|
|
22
|
-
"Programming Language :: Python :: 3.8",
|
|
23
22
|
"Programming Language :: Python :: 3.9",
|
|
24
23
|
"Programming Language :: Python :: 3.10",
|
|
25
24
|
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
26
|
]
|
|
27
27
|
|
|
28
28
|
dependencies = [
|
|
29
29
|
"importlib-metadata>=4.0; python_version<='3.8'",
|
|
30
30
|
"ansys-api-pyensight==0.3.2",
|
|
31
31
|
"requests>=2.28.2",
|
|
32
|
-
"
|
|
32
|
+
"docker>=6.1.0",
|
|
33
33
|
"urllib3<2",
|
|
34
34
|
"typing>=3.7.4.3",
|
|
35
35
|
"typing-extensions>=4.5.0",
|
|
@@ -52,7 +52,7 @@ tests = [
|
|
|
52
52
|
"pytest-mock==3.10.0",
|
|
53
53
|
"urllib3==1.26.10",
|
|
54
54
|
"requests>=2.28.2",
|
|
55
|
-
"
|
|
55
|
+
"docker>=6.1.0",
|
|
56
56
|
]
|
|
57
57
|
doc = [
|
|
58
58
|
"Sphinx==7.0.1",
|
|
@@ -61,7 +61,7 @@ doc = [
|
|
|
61
61
|
"sphinx-copybutton==0.5.2",
|
|
62
62
|
"sphinx-gallery==0.13.0",
|
|
63
63
|
"sphinxcontrib-mermaid==0.9.2",
|
|
64
|
-
"
|
|
64
|
+
"docker>=6.1.0",
|
|
65
65
|
"matplotlib==3.7.2",
|
|
66
66
|
"requests>=2.28.2",
|
|
67
67
|
"sphinxcontrib.jquery==4.1",
|
|
@@ -113,7 +113,7 @@ minversion = "7.1"
|
|
|
113
113
|
testpaths = [
|
|
114
114
|
"tests",
|
|
115
115
|
]
|
|
116
|
-
addopts = "--setup-show --cov=ansys.pyensight.core --cov
|
|
116
|
+
addopts = "--setup-show --cov=ansys.pyensight.core --cov-report html:coverage-html --cov-report term --cov-config=.coveragerc --capture=tee-sys --tb=native -p no:warnings"
|
|
117
117
|
markers =[
|
|
118
118
|
"integration:Run integration tests",
|
|
119
119
|
"smoke:Run the smoke tests",
|
|
@@ -144,7 +144,7 @@ recursive = true
|
|
|
144
144
|
exclude = ["venv/*", "tests/*"]
|
|
145
145
|
|
|
146
146
|
[tool.mypy]
|
|
147
|
-
python_version = 3.
|
|
147
|
+
python_version = 3.9
|
|
148
148
|
strict = false
|
|
149
149
|
namespace_packages = true
|
|
150
150
|
explicit_package_bases = true
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/dockerlauncher.py
RENAMED
|
@@ -193,7 +193,7 @@ class DockerLauncher(Launcher):
|
|
|
193
193
|
|
|
194
194
|
self._docker_client = docker.from_env()
|
|
195
195
|
except ModuleNotFoundError:
|
|
196
|
-
raise RuntimeError("The
|
|
196
|
+
raise RuntimeError("The docker module must be installed for DockerLauncher")
|
|
197
197
|
except Exception:
|
|
198
198
|
raise RuntimeError("Cannot initialize Docker")
|
|
199
199
|
|
|
@@ -308,7 +308,7 @@ class DockerLauncher(Launcher):
|
|
|
308
308
|
try:
|
|
309
309
|
import docker
|
|
310
310
|
except ModuleNotFoundError: # pragma: no cover
|
|
311
|
-
raise RuntimeError("The
|
|
311
|
+
raise RuntimeError("The docker module must be installed for DockerLauncher")
|
|
312
312
|
except Exception: # pragma: no cover
|
|
313
313
|
raise RuntimeError("Cannot initialize Docker")
|
|
314
314
|
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/session.py
RENAMED
|
@@ -1113,6 +1113,55 @@ class Session:
|
|
|
1113
1113
|
if self.cmd(cmd) != 0:
|
|
1114
1114
|
raise RuntimeError("Unable to load the dataset.")
|
|
1115
1115
|
|
|
1116
|
+
def download_pyansys_example(
|
|
1117
|
+
self, filename: str, directory: Optional[str] = None, root: Optional[str] = None
|
|
1118
|
+
) -> str:
|
|
1119
|
+
"""Download an example dataset from the ansys/example-data repository.
|
|
1120
|
+
The dataset is downloaded local to the EnSight server location, so that it can
|
|
1121
|
+
be downloaded even if running from a container.
|
|
1122
|
+
|
|
1123
|
+
Parameters
|
|
1124
|
+
----------
|
|
1125
|
+
filename: str
|
|
1126
|
+
The filename to download
|
|
1127
|
+
directory: str
|
|
1128
|
+
The directory to download the filename from
|
|
1129
|
+
root: str
|
|
1130
|
+
If set, the download will happen from another location
|
|
1131
|
+
|
|
1132
|
+
Returns
|
|
1133
|
+
-------
|
|
1134
|
+
pathname: str
|
|
1135
|
+
The download location, local to the EnSight server directory
|
|
1136
|
+
|
|
1137
|
+
Examples
|
|
1138
|
+
--------
|
|
1139
|
+
>>> from ansys.pyensight.core import DockerLauncher
|
|
1140
|
+
>>> session = DockerLauncher().start(data_directory="D:\\")
|
|
1141
|
+
>>> cas_file = session.download_pyansys_example("mixing_elbow.cas.h5","pyfluent/mixing_elbow")
|
|
1142
|
+
>>> dat_file = session.download_pyansys_example("mixing_elbow.dat.h5","pyfluent/mixing_elbow")
|
|
1143
|
+
>>> session.load_data(cas_file, result_file=dat_file)
|
|
1144
|
+
>>> remote = session.show("remote")
|
|
1145
|
+
>>> remote.browser()
|
|
1146
|
+
"""
|
|
1147
|
+
base_uri = "https://github.com/ansys/example-data/raw/master"
|
|
1148
|
+
if root is not None:
|
|
1149
|
+
base_uri = root
|
|
1150
|
+
uri = f"{base_uri}/{filename}"
|
|
1151
|
+
if directory:
|
|
1152
|
+
uri = f"{base_uri}/{directory}/{filename}"
|
|
1153
|
+
pathname = f"{self.launcher.session_directory}/{filename}"
|
|
1154
|
+
script = "import requests\n"
|
|
1155
|
+
script += "import shutil\n"
|
|
1156
|
+
script += "import os\n"
|
|
1157
|
+
script += f'url = "{uri}"\n'
|
|
1158
|
+
script += f'outpath = r"""{pathname}"""\n'
|
|
1159
|
+
script += "with requests.get(url, stream=True) as r:\n"
|
|
1160
|
+
script += " with open(outpath, 'wb') as f:\n"
|
|
1161
|
+
script += " shutil.copyfileobj(r.raw, f)\n"
|
|
1162
|
+
self.cmd(script, do_eval=False)
|
|
1163
|
+
return pathname
|
|
1164
|
+
|
|
1116
1165
|
def load_example(
|
|
1117
1166
|
self, example_name: str, uncompress: bool = False, root: Optional[str] = None
|
|
1118
1167
|
) -> str:
|
|
@@ -1151,16 +1200,8 @@ class Session:
|
|
|
1151
1200
|
base_uri = "https://s3.amazonaws.com/www3.ensight.com/PyEnSight/ExampleData"
|
|
1152
1201
|
if root is not None:
|
|
1153
1202
|
base_uri = root
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
script = "import requests\n"
|
|
1157
|
-
script += "import shutil\n"
|
|
1158
|
-
script += "import os\n"
|
|
1159
|
-
script += f'url = "{uri}"\n'
|
|
1160
|
-
script += f'outpath = r"""{pathname}"""\n'
|
|
1161
|
-
script += "with requests.get(url, stream=True) as r:\n"
|
|
1162
|
-
script += " with open(outpath, 'wb') as f:\n"
|
|
1163
|
-
script += " shutil.copyfileobj(r.raw, f)\n"
|
|
1203
|
+
pathname = self.download_pyansys_example(example_name, root=base_uri)
|
|
1204
|
+
script = f'outpath = r"""{pathname}"""\n'
|
|
1164
1205
|
if uncompress:
|
|
1165
1206
|
# in this case, remove the extension and unzip the file
|
|
1166
1207
|
pathname_dir = os.path.splitext(pathname)[0]
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/utils/export.py
RENAMED
|
@@ -73,8 +73,6 @@ class Export:
|
|
|
73
73
|
) -> None:
|
|
74
74
|
"""Render an image of the current EnSight scene.
|
|
75
75
|
|
|
76
|
-
This method returns a PIL image object.
|
|
77
|
-
|
|
78
76
|
Parameters
|
|
79
77
|
----------
|
|
80
78
|
filename : str
|
|
@@ -464,3 +462,108 @@ class Export:
|
|
|
464
462
|
mp4_data = fp.read()
|
|
465
463
|
|
|
466
464
|
return mp4_data
|
|
465
|
+
|
|
466
|
+
GEOM_EXPORT_GLTF = "gltf2"
|
|
467
|
+
GEOM_EXPORT_AVZ = "avz"
|
|
468
|
+
GEOM_EXPORT_PLY = "ply"
|
|
469
|
+
GEOM_EXPORT_STL = "stl"
|
|
470
|
+
|
|
471
|
+
extension_map = {
|
|
472
|
+
GEOM_EXPORT_GLTF: ".glb",
|
|
473
|
+
GEOM_EXPORT_AVZ: ".avz",
|
|
474
|
+
GEOM_EXPORT_PLY: ".ply",
|
|
475
|
+
GEOM_EXPORT_STL: ".stl",
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
def _geometry_remote(
|
|
479
|
+
self, format: str, starting_timestep: int, frames: int, delta_timestep: int
|
|
480
|
+
) -> bytes:
|
|
481
|
+
"""EnSight-side implementation.
|
|
482
|
+
|
|
483
|
+
Parameters
|
|
484
|
+
----------
|
|
485
|
+
format : str
|
|
486
|
+
The format to export
|
|
487
|
+
starting_timestep: int
|
|
488
|
+
The first timestep to export. If None, defaults to the current timestep
|
|
489
|
+
frames: int
|
|
490
|
+
Number of timesteps to save. If None, defaults from the current timestep to the last
|
|
491
|
+
delta_timestep: int
|
|
492
|
+
The delta timestep to use when exporting
|
|
493
|
+
|
|
494
|
+
Returns
|
|
495
|
+
-------
|
|
496
|
+
bytes
|
|
497
|
+
Geometry export in bytes
|
|
498
|
+
"""
|
|
499
|
+
rawdata = None
|
|
500
|
+
extension = self.extension_map.get(format)
|
|
501
|
+
if not extension:
|
|
502
|
+
raise RuntimeError("The geometry export format provided is not supported.")
|
|
503
|
+
with tempfile.TemporaryDirectory() as tmpdirname:
|
|
504
|
+
self._ensight.part.select_all()
|
|
505
|
+
self._ensight.savegeom.format(format)
|
|
506
|
+
self._ensight.savegeom.begin_step(starting_timestep)
|
|
507
|
+
# frames is 1-indexed, so I need to decrease of 1
|
|
508
|
+
self._ensight.savegeom.end_step(starting_timestep + frames - 1)
|
|
509
|
+
self._ensight.savegeom.step_by(delta_timestep)
|
|
510
|
+
tmpfilename = os.path.join(tmpdirname, str(uuid.uuid1()))
|
|
511
|
+
self._ensight.savegeom.save_geometric_entities(tmpfilename)
|
|
512
|
+
with open(tmpfilename + extension, "rb") as tmpfile:
|
|
513
|
+
rawdata = tmpfile.read()
|
|
514
|
+
return rawdata
|
|
515
|
+
|
|
516
|
+
def geometry(
|
|
517
|
+
self,
|
|
518
|
+
filename: str,
|
|
519
|
+
format: str = GEOM_EXPORT_GLTF,
|
|
520
|
+
starting_timestep: Optional[int] = None,
|
|
521
|
+
frames: Optional[int] = 1,
|
|
522
|
+
delta_timestep: Optional[int] = None,
|
|
523
|
+
) -> None:
|
|
524
|
+
"""Export a geometry file.
|
|
525
|
+
|
|
526
|
+
Parameters
|
|
527
|
+
----------
|
|
528
|
+
filename: str
|
|
529
|
+
The location where to export the geometry
|
|
530
|
+
format : str
|
|
531
|
+
The format to export
|
|
532
|
+
starting_timestep: int
|
|
533
|
+
The first timestep to export. If None, defaults to the current timestep
|
|
534
|
+
frames: int
|
|
535
|
+
Number of timesteps to save. If None, defaults from the current timestep to the last
|
|
536
|
+
delta_timestep: int
|
|
537
|
+
The delta timestep to use when exporting
|
|
538
|
+
|
|
539
|
+
Examples
|
|
540
|
+
--------
|
|
541
|
+
>>> s = LocalLauncher().start()
|
|
542
|
+
>>> data = f"{s.cei_home}/ensight{s.cei_suffix}gui/demos/Crash Queries.ens"
|
|
543
|
+
>>> s.ensight.objs.ensxml_restore_file(data)
|
|
544
|
+
>>> s.ensight.utils.export.geometry("local_file.glb", format=s.ensight.utils.export.GEOM_EXPORT_GLTF)
|
|
545
|
+
"""
|
|
546
|
+
if not starting_timestep:
|
|
547
|
+
starting_timestep = int(self._ensight.objs.core.TIMESTEP)
|
|
548
|
+
if not frames or frames == -1:
|
|
549
|
+
# Timesteps are 0-indexed so frames need to be increased of 1
|
|
550
|
+
frames = int(self._ensight.objs.core.TIMESTEP_LIMITS[1]) + 1
|
|
551
|
+
if not delta_timestep:
|
|
552
|
+
delta_timestep = 1
|
|
553
|
+
self._remote_support_check()
|
|
554
|
+
raw_data = None
|
|
555
|
+
if isinstance(self._ensight, ModuleType):
|
|
556
|
+
raw_data = self._geometry_remote(
|
|
557
|
+
format,
|
|
558
|
+
starting_timestep=starting_timestep,
|
|
559
|
+
frames=frames,
|
|
560
|
+
delta_timestep=delta_timestep,
|
|
561
|
+
)
|
|
562
|
+
else:
|
|
563
|
+
cmd = f"ensight.utils.export._geometry_remote('{format}', {starting_timestep}, {frames}, {delta_timestep})"
|
|
564
|
+
raw_data = self._ensight._session.cmd(cmd)
|
|
565
|
+
if raw_data:
|
|
566
|
+
with open(filename, "wb") as fp:
|
|
567
|
+
fp.write(raw_data)
|
|
568
|
+
else:
|
|
569
|
+
raise IOError("Export was not successful")
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/utils/support.py
RENAMED
|
@@ -31,24 +31,46 @@ class Support:
|
|
|
31
31
|
def __init__(self, interface: Union["ensight_api.ensight", "ensight"]):
|
|
32
32
|
self._ensight = interface
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
def scoped_name(obj: Any) -> ContextManager:
|
|
34
|
+
def scoped_name(self, obj: Any, native_exceptions: bool = False) -> ContextManager:
|
|
36
35
|
"""Allow for the use of ``with`` to shorten APIs.
|
|
37
36
|
|
|
38
37
|
In the EnSight and PyEnsight APIs, the interfaces can become lengthy.
|
|
39
38
|
This class makes it possible to shorten APIs for modules, classes,
|
|
40
|
-
and namespaces.
|
|
39
|
+
and namespaces. The native_exceptions keyword can be used to enable
|
|
40
|
+
exceptions for EnSight native Python API. By default, an invalid
|
|
41
|
+
native API call like ``ensight.part.select_begin(-9999)`` will return
|
|
42
|
+
-1. If native_exceptions is True, a Python exception will be thrown.
|
|
43
|
+
The scope of this operational change parallels the scoped_name()
|
|
44
|
+
instance.
|
|
45
|
+
|
|
46
|
+
Parameters
|
|
47
|
+
----------
|
|
48
|
+
obj: Any
|
|
49
|
+
The object for which to generate a simplified namespace.
|
|
50
|
+
native_exceptions: bool
|
|
51
|
+
If True, then EnSight native Python API exceptions are enabled.
|
|
52
|
+
The default is False.
|
|
53
|
+
|
|
54
|
+
Returns
|
|
55
|
+
-------
|
|
56
|
+
The passed object wrapped in a context manager that can be used as a
|
|
57
|
+
simplified namespace.
|
|
41
58
|
|
|
42
59
|
Examples
|
|
43
60
|
--------
|
|
44
61
|
>>> sn = s.ensight.utils.support.scoped_name
|
|
45
62
|
>>> with sn(s.ensight.objs.core) as core, sn(s.ensight.objs.enums) as enums:
|
|
46
63
|
>>> print(core.PARTS.find(True, enums.VISIBLE))
|
|
64
|
+
|
|
47
65
|
>>> sn = ensight.utils.support.scoped_name
|
|
48
66
|
>>> with sn(ensight.objs.core) as core, sn(ensight.objs.enums) as enums:
|
|
49
67
|
>>> print(core.PARTS.find(True, enums.VISIBLE))
|
|
68
|
+
|
|
69
|
+
>>> sn = ensight.utils.support.scoped_name
|
|
70
|
+
>>> with sn(ensight.part, native_exceptions=True) as part:
|
|
71
|
+
>>> part.select_begin(-9999)
|
|
50
72
|
"""
|
|
51
|
-
return ScopedName(obj)
|
|
73
|
+
return ScopedName(self._ensight, obj, native_exceptions=native_exceptions)
|
|
52
74
|
|
|
53
75
|
|
|
54
76
|
class ScopedName:
|
|
@@ -59,11 +81,26 @@ class ScopedName:
|
|
|
59
81
|
and namespaces.
|
|
60
82
|
"""
|
|
61
83
|
|
|
62
|
-
def __init__(
|
|
84
|
+
def __init__(
|
|
85
|
+
self,
|
|
86
|
+
interface: Union["ensight_api.ensight", "ensight"],
|
|
87
|
+
obj: Any,
|
|
88
|
+
native_exceptions: bool = False,
|
|
89
|
+
):
|
|
63
90
|
self._obj = obj
|
|
91
|
+
self._ensight = interface
|
|
92
|
+
self._old_raise = None
|
|
93
|
+
if native_exceptions:
|
|
94
|
+
# if we are being asked to enable exceptions, record what to restore it to
|
|
95
|
+
self._old_raise = self._ensight.query("SENDMESG_RAISE")
|
|
64
96
|
|
|
65
97
|
def __enter__(self) -> Any:
|
|
98
|
+
if self._old_raise is not None:
|
|
99
|
+
# if a restore value is set, enable them
|
|
100
|
+
self._ensight.sendmesgoptions(exception=1)
|
|
66
101
|
return self._obj
|
|
67
102
|
|
|
68
103
|
def __exit__(self, exc_type, exc_value, exc_trace):
|
|
69
|
-
|
|
104
|
+
if self._old_raise is not None:
|
|
105
|
+
# if the restore value is set, restore it here
|
|
106
|
+
self._ensight.sendmesgoptions(exception=self._old_raise)
|
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/enscontext.py
RENAMED
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/enshell_grpc.py
RENAMED
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/ensight_grpc.py
RENAMED
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/ensobj.py
RENAMED
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/launch_ensight.py
RENAMED
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/launcher.py
RENAMED
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/listobj.py
RENAMED
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/locallauncher.py
RENAMED
|
File without changes
|
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/renderable.py
RENAMED
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/sgeo_poll.html
RENAMED
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/utils/__init__.py
RENAMED
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/utils/adr.py
RENAMED
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/utils/parts.py
RENAMED
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/utils/query.py
RENAMED
|
File without changes
|
{ansys_pyensight_core-0.6.2 → ansys_pyensight_core-0.7.0}/src/ansys/pyensight/core/utils/views.py
RENAMED
|
File without changes
|