ansys-mechanical-core 0.11.2__tar.gz → 0.11.4__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.
Files changed (41) hide show
  1. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/PKG-INFO +13 -12
  2. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/README.rst +2 -1
  3. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/pyproject.toml +28 -14
  4. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/app.py +22 -20
  5. ansys_mechanical_core-0.11.4/src/ansys/mechanical/core/embedding/background.py +106 -0
  6. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/resolver.py +1 -4
  7. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/shims.py +8 -7
  8. ansys_mechanical_core-0.11.2/src/ansys/mechanical/core/embedding/viz/pyvista_plotter.py → ansys_mechanical_core-0.11.4/src/ansys/mechanical/core/embedding/viz/embedding_plotter.py +5 -10
  9. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/mechanical.py +3 -3
  10. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/pool.py +3 -3
  11. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/LICENSE +0 -0
  12. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/__init__.py +0 -0
  13. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/_version.py +0 -0
  14. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/__init__.py +0 -0
  15. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/addins.py +0 -0
  16. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/app_libraries.py +0 -0
  17. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/appdata.py +0 -0
  18. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/enum_importer.py +0 -0
  19. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/imports.py +0 -0
  20. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/initializer.py +0 -0
  21. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/loader.py +0 -0
  22. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/logger/__init__.py +0 -0
  23. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/logger/environ.py +0 -0
  24. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/logger/linux_api.py +0 -0
  25. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/logger/sinks.py +0 -0
  26. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/logger/windows_api.py +0 -0
  27. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/poster.py +0 -0
  28. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/runtime.py +0 -0
  29. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/utils.py +0 -0
  30. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/viz/__init__.py +0 -0
  31. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/viz/usd_converter.py +0 -0
  32. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/viz/utils.py +0 -0
  33. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/embedding/warnings.py +0 -0
  34. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/errors.py +0 -0
  35. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/examples/__init__.py +0 -0
  36. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/examples/downloads.py +0 -0
  37. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/feature_flags.py +0 -0
  38. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/launcher.py +0 -0
  39. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/logging.py +0 -0
  40. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/misc.py +0 -0
  41. {ansys_mechanical_core-0.11.2 → ansys_mechanical_core-0.11.4}/src/ansys/mechanical/core/run.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ansys-mechanical-core
3
- Version: 0.11.2
3
+ Version: 0.11.4
4
4
  Summary: A python wrapper for Ansys Mechanical
5
5
  Keywords: pymechanical,mechanical,ansys,pyansys
6
6
  Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
@@ -27,36 +27,36 @@ Requires-Dist: clr-loader==0.2.6
27
27
  Requires-Dist: grpcio>=1.30.0
28
28
  Requires-Dist: protobuf>=3.12.2,<6
29
29
  Requires-Dist: tqdm>=4.45.0
30
- Requires-Dist: sphinx==7.4.4 ; extra == "doc"
30
+ Requires-Dist: sphinx==7.4.7 ; extra == "doc"
31
31
  Requires-Dist: ansys-sphinx-theme[autoapi]==0.16.6 ; extra == "doc"
32
- Requires-Dist: grpcio==1.64.1 ; extra == "doc"
32
+ Requires-Dist: grpcio==1.65.4 ; extra == "doc"
33
33
  Requires-Dist: imageio-ffmpeg==0.5.1 ; extra == "doc"
34
34
  Requires-Dist: imageio==2.34.2 ; extra == "doc"
35
35
  Requires-Dist: jupyter_sphinx==0.5.3 ; extra == "doc"
36
36
  Requires-Dist: jupyterlab>=3.2.8 ; extra == "doc"
37
37
  Requires-Dist: matplotlib==3.9.1 ; extra == "doc"
38
- Requires-Dist: numpy==2.0.0 ; extra == "doc"
38
+ Requires-Dist: numpy==2.0.1 ; extra == "doc"
39
39
  Requires-Dist: numpydoc==1.7.0 ; extra == "doc"
40
40
  Requires-Dist: pandas==2.2.2 ; extra == "doc"
41
41
  Requires-Dist: panel==1.4.4 ; extra == "doc"
42
- Requires-Dist: plotly==5.22.0 ; extra == "doc"
42
+ Requires-Dist: plotly==5.23.0 ; extra == "doc"
43
43
  Requires-Dist: pypandoc==1.13 ; extra == "doc"
44
44
  Requires-Dist: pytest-sphinx==0.6.3 ; extra == "doc"
45
45
  Requires-Dist: pythreejs==2.4.2 ; extra == "doc"
46
46
  Requires-Dist: pyvista>=0.39.1 ; extra == "doc"
47
47
  Requires-Dist: sphinx-autobuild==2024.4.16 ; extra == "doc"
48
- Requires-Dist: sphinx-autodoc-typehints==2.2.2 ; extra == "doc"
48
+ Requires-Dist: sphinx-autodoc-typehints==2.2.3 ; extra == "doc"
49
49
  Requires-Dist: sphinx-copybutton==0.5.2 ; extra == "doc"
50
50
  Requires-Dist: sphinx_design==0.6.0 ; extra == "doc"
51
- Requires-Dist: sphinx-gallery==0.16.0 ; extra == "doc"
51
+ Requires-Dist: sphinx-gallery==0.17.0 ; extra == "doc"
52
52
  Requires-Dist: sphinx-notfound-page==1.0.2 ; extra == "doc"
53
- Requires-Dist: sphinxcontrib-websupport==1.2.7 ; extra == "doc"
53
+ Requires-Dist: sphinxcontrib-websupport==2.0.0 ; extra == "doc"
54
54
  Requires-Dist: sphinxemoji==0.3.1 ; extra == "doc"
55
- Requires-Dist: pytest==8.2.2 ; extra == "tests"
55
+ Requires-Dist: pytest==8.3.2 ; extra == "tests"
56
56
  Requires-Dist: pytest-cov==5.0.0 ; extra == "tests"
57
57
  Requires-Dist: pytest-print==1.0.0 ; extra == "tests"
58
- Requires-Dist: pyvista>=0.39.1 ; extra == "viz"
59
- Requires-Dist: usd-core==24.3 ; extra == "viz"
58
+ Requires-Dist: ansys-tools-visualization-interface>=0.2.6 ; extra == "viz"
59
+ Requires-Dist: usd-core==24.8 ; extra == "viz"
60
60
  Project-URL: Changelog, https://mechanical.docs.pyansys.com/version/stable/changelog.html
61
61
  Project-URL: Documentation, https://mechanical.docs.pyansys.com
62
62
  Project-URL: Homepage, https://github.com/ansys/pymechanical
@@ -187,7 +187,8 @@ on Windows and Linux for version 2023 R2 and later. Here is an example:
187
187
  import ansys.mechanical.core as pymechanical
188
188
 
189
189
  app = pymechanical.App()
190
- project_dir = app.ExtAPI.DataModel.Project.ProjectDirectory
190
+ app.update_globals(globals())
191
+ project_dir = DataModel.Project.ProjectDirectory
191
192
 
192
193
  Documentation and issues
193
194
  ------------------------
@@ -119,7 +119,8 @@ on Windows and Linux for version 2023 R2 and later. Here is an example:
119
119
  import ansys.mechanical.core as pymechanical
120
120
 
121
121
  app = pymechanical.App()
122
- project_dir = app.ExtAPI.DataModel.Project.ProjectDirectory
122
+ app.update_globals(globals())
123
+ project_dir = DataModel.Project.ProjectDirectory
123
124
 
124
125
  Documentation and issues
125
126
  ------------------------
@@ -5,7 +5,7 @@ build-backend = "flit_core.buildapi"
5
5
  [project]
6
6
  # Check https://flit.readthedocs.io/en/latest/pyproject_toml.html for all available sections
7
7
  name = "ansys-mechanical-core"
8
- version = "0.11.2"
8
+ version = "0.11.4"
9
9
  description = "A python wrapper for Ansys Mechanical"
10
10
  readme = "README.rst"
11
11
  requires-python = ">=3.9,<4.0"
@@ -48,40 +48,40 @@ Changelog = "https://mechanical.docs.pyansys.com/version/stable/changelog.html"
48
48
 
49
49
  [project.optional-dependencies]
50
50
  tests = [
51
- "pytest==8.2.2",
51
+ "pytest==8.3.2",
52
52
  "pytest-cov==5.0.0",
53
53
  "pytest-print==1.0.0",
54
54
  ]
55
55
  doc = [
56
- "sphinx==7.4.4",
56
+ "sphinx==7.4.7",
57
57
  "ansys-sphinx-theme[autoapi]==0.16.6",
58
- "grpcio==1.64.1",
58
+ "grpcio==1.65.4",
59
59
  "imageio-ffmpeg==0.5.1",
60
60
  "imageio==2.34.2",
61
61
  "jupyter_sphinx==0.5.3",
62
62
  "jupyterlab>=3.2.8",
63
63
  "matplotlib==3.9.1",
64
- "numpy==2.0.0",
64
+ "numpy==2.0.1",
65
65
  "numpydoc==1.7.0",
66
66
  "pandas==2.2.2",
67
67
  "panel==1.4.4",
68
- "plotly==5.22.0",
68
+ "plotly==5.23.0",
69
69
  "pypandoc==1.13",
70
70
  "pytest-sphinx==0.6.3",
71
71
  "pythreejs==2.4.2",
72
72
  "pyvista>=0.39.1",
73
73
  "sphinx-autobuild==2024.4.16",
74
- "sphinx-autodoc-typehints==2.2.2",
74
+ "sphinx-autodoc-typehints==2.2.3",
75
75
  "sphinx-copybutton==0.5.2",
76
76
  "sphinx_design==0.6.0",
77
- "sphinx-gallery==0.16.0",
77
+ "sphinx-gallery==0.17.0",
78
78
  "sphinx-notfound-page==1.0.2",
79
- "sphinxcontrib-websupport==1.2.7",
79
+ "sphinxcontrib-websupport==2.0.0",
80
80
  "sphinxemoji==0.3.1",
81
81
  ]
82
82
  viz = [
83
- "pyvista>=0.39.1",
84
- "usd-core==24.3",
83
+ "ansys-tools-visualization-interface>=0.2.6",
84
+ "usd-core==24.8",
85
85
  ]
86
86
 
87
87
  [project.scripts]
@@ -139,6 +139,7 @@ markers = [
139
139
  "remote_session_connect: tests that connect to Mechanical and work with gRPC server inside it",
140
140
  "minimum_version(num): tests that run if ansys-version is greater than or equal to the minimum version provided",
141
141
  "windows_only: tests that run if the testing platform is on Windows",
142
+ "linux_only: tests that run if the testing platform is on Linux",
142
143
  "cli: tests for the Command Line Interface",
143
144
  ]
144
145
  xfail_strict = true
@@ -152,7 +153,6 @@ package = "ansys.mechanical.core"
152
153
  directory = "doc/changelog.d"
153
154
  filename = "doc/source/changelog.rst"
154
155
  start_string = ".. towncrier release notes start\n"
155
- underlines = ["", "", ""]
156
156
  template = "doc/changelog.d/changelog_template.jinja"
157
157
  title_format = "`{version} <https://github.com/ansys/pymechanical/releases/tag/v{version}>`_ - {project_date}"
158
158
  issue_format = "`#{issue} <https://github.com/ansys/pymechanical/pull/{issue}>`_"
@@ -207,7 +207,7 @@ legacy_tox_ini = """
207
207
  [tox]
208
208
  description = Default tox environments list
209
209
  envlist =
210
- style,{py38,py39,py310,py311}{,-coverage},doc
210
+ style,{py39,py310,py311,py312}{,-coverage},doc
211
211
  passenv = AWP_ROOT
212
212
  skip_missing_interpreters = true
213
213
  isolated_build = true
@@ -254,4 +254,18 @@ passenv = *
254
254
  extras = doc
255
255
  commands =
256
256
  sphinx-build -d "{toxworkdir}/doc_doctree" doc/source "{toxinidir}/doc/_build/html" --color -vW -bhtml
257
- """
257
+ """
258
+ [[tool.towncrier.type]]
259
+ directory = "documentation"
260
+ name = "Documentation"
261
+ showcontent = true
262
+
263
+ [[tool.towncrier.type]]
264
+ directory = "maintenance"
265
+ name = "Maintenance"
266
+ showcontent = true
267
+
268
+ [[tool.towncrier.type]]
269
+ directory = "test"
270
+ name = "Test"
271
+ showcontent = true
@@ -34,13 +34,13 @@ from ansys.mechanical.core.embedding.poster import Poster
34
34
  from ansys.mechanical.core.embedding.warnings import connect_warnings, disconnect_warnings
35
35
 
36
36
  try:
37
- import pyvista # noqa: F401
37
+ import ansys.tools.visualization_interface # noqa: F401
38
38
 
39
- HAS_PYVISTA = True
39
+ HAS_ANSYS_VIZ = True
40
40
  """Whether or not PyVista exists."""
41
41
  except:
42
42
 
43
- HAS_PYVISTA = False
43
+ HAS_ANSYS_VIZ = False
44
44
 
45
45
 
46
46
  def _get_default_addin_configuration() -> AddinConfiguration:
@@ -229,13 +229,9 @@ class App:
229
229
  rets = None
230
230
  return self.script_engine.ExecuteCode(script, SCRIPT_SCOPE, light_mode, args, rets)
231
231
 
232
- def plot(self) -> None:
233
- """Visualize the model in 3d.
234
-
235
- Requires installation using the viz option. E.g.
236
- pip install ansys-mechanical-core[viz]
237
- """
238
- if not HAS_PYVISTA:
232
+ def plotter(self) -> None:
233
+ """Return ``ansys.tools.visualization_interface.Plotter`` object."""
234
+ if not HAS_ANSYS_VIZ:
239
235
  warnings.warn(
240
236
  "Installation of viz option required! Use pip install ansys-mechanical-core[viz]"
241
237
  )
@@ -245,9 +241,20 @@ class App:
245
241
  warnings.warn("Plotting is only supported with version 2024R2 and later!")
246
242
  return
247
243
 
248
- from ansys.mechanical.core.embedding.viz.pyvista_plotter import plot_model
244
+ # TODO Check if anything loaded inside app or else show warning and return
245
+
246
+ from ansys.mechanical.core.embedding.viz.embedding_plotter import to_plotter
247
+
248
+ return to_plotter(self)
249
249
 
250
- plot_model(self)
250
+ def plot(self) -> None:
251
+ """Visualize the model in 3d.
252
+
253
+ Requires installation using the viz option. E.g.
254
+ pip install ansys-mechanical-core[viz]
255
+ """
256
+ _plotter = self.plotter()
257
+ return _plotter.show()
251
258
 
252
259
  @property
253
260
  def poster(self) -> Poster:
@@ -328,8 +335,7 @@ class App:
328
335
  try:
329
336
  # This will throw an error when using pythonnet because
330
337
  # EventSource isn't defined on the IApplication interface
331
- self.ExtAPI.Application.EventSource.OnAfterNew += self._on_after_new
332
- self.ExtAPI.Application.EventSource.OnAfterDatabaseLoad += self._on_after_open
338
+ self.ExtAPI.Application.EventSource.OnWorkbenchReady += self._on_workbench_ready
333
339
  self._subscribed = True
334
340
  except:
335
341
  self._subscribed = False
@@ -338,13 +344,9 @@ class App:
338
344
  if not self._subscribed:
339
345
  return
340
346
  self._subscribed = False
341
- self.ExtAPI.Application.EventSource.OnAfterNew -= self._on_after_new
342
- self.ExtAPI.Application.EventSource.OnAfterDatabaseLoad -= self._on_after_open
343
-
344
- def _on_after_open(self, sender, args) -> None:
345
- self._update_all_globals()
347
+ self.ExtAPI.Application.EventSource.OnWorkbenchReady -= self._on_workbench_ready
346
348
 
347
- def _on_after_new(self, sender, args) -> None:
349
+ def _on_workbench_ready(self, sender, args) -> None:
348
350
  self._update_all_globals()
349
351
 
350
352
  def update_globals(
@@ -0,0 +1,106 @@
1
+ # Copyright (C) 2022 - 2024 ANSYS, Inc. and/or its affiliates.
2
+ # SPDX-License-Identifier: MIT
3
+ #
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in all
13
+ # copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ # SOFTWARE.
22
+
23
+ """Class for running Mechanical on a background thread."""
24
+
25
+ import atexit
26
+ import threading
27
+ import time
28
+ import typing
29
+
30
+ import ansys.mechanical.core as mech
31
+ from ansys.mechanical.core.embedding.poster import Poster
32
+ import ansys.mechanical.core.embedding.utils as utils
33
+
34
+
35
+ def _exit(background_app: "BackgroundApp"):
36
+ """Stop the thread serving the Background App."""
37
+ background_app.stop()
38
+ atexit.unregister(_exit)
39
+
40
+
41
+ class BackgroundApp:
42
+ """Background App."""
43
+
44
+ __app: mech.App = None
45
+ __app_thread: threading.Thread = None
46
+ __stopped: bool = False
47
+ __stop_signaled: bool = False
48
+ __poster: Poster = None
49
+
50
+ def __init__(self, **kwargs):
51
+ """Construct an instance of BackgroundApp."""
52
+ if BackgroundApp.__app_thread == None:
53
+ BackgroundApp.__app_thread = threading.Thread(
54
+ target=self._start_app, kwargs=kwargs, daemon=True
55
+ )
56
+ BackgroundApp.__app_thread.start()
57
+
58
+ while BackgroundApp.__poster is None:
59
+ time.sleep(0.05)
60
+ continue
61
+ else:
62
+ assert (
63
+ not BackgroundApp.__stopped
64
+ ), "Cannot initialize a BackgroundApp once it has been stopped!"
65
+
66
+ def new():
67
+ BackgroundApp.__app.new()
68
+
69
+ self.post(new)
70
+
71
+ atexit.register(_exit, self)
72
+
73
+ @property
74
+ def app(self) -> mech.App:
75
+ """Get the App instance of the background thread.
76
+
77
+ It is not meant to be used aside from passing to methods using `post`.
78
+ """
79
+ return BackgroundApp.__app
80
+
81
+ def post(self, callable: typing.Callable):
82
+ """Post callable method to the background app thread."""
83
+ assert not BackgroundApp.__stopped, "Cannot use background app after stopping it."
84
+ return BackgroundApp.__poster.post(callable)
85
+
86
+ def stop(self) -> None:
87
+ """Stop the background app thread."""
88
+ if BackgroundApp.__stopped:
89
+ return
90
+ BackgroundApp.__stop_signaled = True
91
+ while True:
92
+ time.sleep(0.05)
93
+ if BackgroundApp.__stopped:
94
+ break
95
+
96
+ def _start_app(self, **kwargs) -> None:
97
+ BackgroundApp.__app = mech.App(**kwargs)
98
+ BackgroundApp.__poster = BackgroundApp.__app.poster
99
+ while True:
100
+ if BackgroundApp.__stop_signaled:
101
+ break
102
+ try:
103
+ utils.sleep(40)
104
+ except:
105
+ pass
106
+ BackgroundApp.__stopped = True
@@ -37,8 +37,5 @@ def resolve(version):
37
37
  import Ansys # isort: skip
38
38
 
39
39
  assembly_resolver = Ansys.Mechanical.Embedding.AssemblyResolver
40
- if version == 231: # pragma: no cover
41
- resolve_handler = assembly_resolver.WindowsResolveEventHandler
42
- else:
43
- resolve_handler = assembly_resolver.MechanicalResolveEventHandler
40
+ resolve_handler = assembly_resolver.MechanicalResolveEventHandler
44
41
  System.AppDomain.CurrentDomain.AssemblyResolve += resolve_handler
@@ -25,16 +25,17 @@
25
25
  These shims are used when APIs are released in newer versions of Mechanical,
26
26
  but workarounds exist in an older release
27
27
  """
28
+ import warnings
28
29
 
29
30
 
30
31
  def import_materials(
31
32
  app: "ansys.mechanical.core.embedding.Application", material_file: str
32
33
  ) -> None:
33
34
  """Import material from matml file."""
34
- if app._version >= 232:
35
- materials = app.DataModel.Project.Model.Materials
36
- materials.Import(material_file)
37
- else: # pragma: no cover
38
- material_file = material_file.replace("\\", "\\\\")
39
- script = 'DS.Tree.Projects.Item(1).LoadEngrDataLibraryFromFile("' + material_file + '");'
40
- app.ExtAPI.Application.ScriptByName("jscript").ExecuteCommand(script)
35
+ warnings.warn(
36
+ "Use of this function is deprecated. Use Model.Materials.Import() directly.",
37
+ DeprecationWarning,
38
+ stacklevel=2,
39
+ )
40
+ materials = app.DataModel.Project.Model.Materials
41
+ materials.Import(material_file)
@@ -29,6 +29,7 @@ clr.AddReference("Ansys.ACT.Interfaces")
29
29
 
30
30
  import Ansys # isort: skip
31
31
 
32
+ from ansys.tools.visualization_interface import Plotter
32
33
  import numpy as np
33
34
  import pyvista as pv
34
35
 
@@ -68,9 +69,9 @@ def _get_nodes_and_coords(node: "Ansys.Mechanical.Scenegraph.Node"):
68
69
  return None, None
69
70
 
70
71
 
71
- def to_pyvista_plotter(app: "ansys.mechanical.core.embedding.App"):
72
- """Convert the app's geometry to a pyvista plotter instance."""
73
- plotter = pv.Plotter()
72
+ def to_plotter(app: "ansys.mechanical.core.embedding.App"):
73
+ """Convert the app's geometry to an ``ansys.tools.visualization_interface.Plotter`` instance."""
74
+ plotter = Plotter()
74
75
  for body in app.DataModel.GetObjectsByType(
75
76
  Ansys.Mechanical.DataModel.Enums.DataModelObjectCategory.Body
76
77
  ):
@@ -81,11 +82,5 @@ def to_pyvista_plotter(app: "ansys.mechanical.core.embedding.App"):
81
82
  pv_transform = _transform_to_pyvista(scenegraph_node.Transform)
82
83
  polydata = pv.PolyData(np_coordinates, np_indices).transform(pv_transform)
83
84
  color = pv.Color(bgr_to_rgb_tuple(body.Color))
84
- plotter.add_mesh(polydata, color=color, smooth_shading=True)
85
+ plotter.plot(polydata, color=color, smooth_shading=True)
85
86
  return plotter
86
-
87
-
88
- def plot_model(app: "ansys.mechanical.core.embedding.App"):
89
- """Plot the model."""
90
- plotter = to_pyvista_plotter(app)
91
- plotter.show()
@@ -246,7 +246,7 @@ def check_valid_mechanical():
246
246
  if mechanical_path == None:
247
247
  return False
248
248
  mechanical_version = atp.version_from_path("mechanical", mechanical_path)
249
- return not (mechanical_version < 231 and os.name != "posix")
249
+ return not (mechanical_version < 232 and os.name != "posix")
250
250
 
251
251
 
252
252
  def change_default_mechanical_path(exe_loc):
@@ -1913,8 +1913,8 @@ def launch_grpc(
1913
1913
 
1914
1914
  """
1915
1915
  # verify version
1916
- if atp.version_from_path("mechanical", exec_file) < 231:
1917
- raise VersionError("The Mechanical gRPC interface requires Mechanical 2023 R1 or later.")
1916
+ if atp.version_from_path("mechanical", exec_file) < 232:
1917
+ raise VersionError("The Mechanical gRPC interface requires Mechanical 2023 R2 or later.")
1918
1918
 
1919
1919
  # get the next available port
1920
1920
  local_ports = pymechanical.LOCAL_PORTS
@@ -170,7 +170,7 @@ class LocalMechanicalPool:
170
170
  self._spawn_kwargs = kwargs
171
171
  self._remote = False
172
172
 
173
- # verify that mechanical is 2023R1 or newer
173
+ # verify that mechanical is 2023R2 or newer
174
174
  exec_file = None
175
175
  if "exec_file" in kwargs:
176
176
  exec_file = kwargs["exec_file"]
@@ -191,8 +191,8 @@ class LocalMechanicalPool:
191
191
  )
192
192
 
193
193
  if not self._remote: # pragma: no cover
194
- if version_from_path("mechanical", exec_file) < 231:
195
- raise VersionError("A local Mechanical pool requires Mechanical 2023 R1 or later.")
194
+ if version_from_path("mechanical", exec_file) < 232:
195
+ raise VersionError("A local Mechanical pool requires Mechanical 2023 R2 or later.")
196
196
 
197
197
  ports = None
198
198