ansys-mechanical-core 0.11.4__py3-none-any.whl → 0.11.6__py3-none-any.whl

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.
@@ -254,6 +254,10 @@ class App:
254
254
  pip install ansys-mechanical-core[viz]
255
255
  """
256
256
  _plotter = self.plotter()
257
+
258
+ if _plotter is None:
259
+ return
260
+
257
261
  return _plotter.show()
258
262
 
259
263
  @property
@@ -72,6 +72,8 @@ def _get_nodes_and_coords(node: "Ansys.Mechanical.Scenegraph.Node"):
72
72
  def to_plotter(app: "ansys.mechanical.core.embedding.App"):
73
73
  """Convert the app's geometry to an ``ansys.tools.visualization_interface.Plotter`` instance."""
74
74
  plotter = Plotter()
75
+
76
+ # TODO - use get_scene from utils instead of looping over bodies directly here.
75
77
  for body in app.DataModel.GetObjectsByType(
76
78
  Ansys.Mechanical.DataModel.Enums.DataModelObjectCategory.Body
77
79
  ):
@@ -24,15 +24,9 @@
24
24
 
25
25
  import typing
26
26
 
27
- import clr
28
27
  from pxr import Gf, Usd, UsdGeom
29
28
 
30
- clr.AddReference("Ansys.Mechanical.DataModel")
31
- clr.AddReference("Ansys.ACT.Interfaces")
32
-
33
- import Ansys # isort: skip
34
-
35
- from .utils import bgr_to_rgb_tuple, get_nodes_and_coords
29
+ from .utils import bgr_to_rgb_tuple, get_nodes_and_coords, get_scene
36
30
 
37
31
 
38
32
  def _transform_to_rotation_translation(
@@ -94,6 +88,13 @@ def _convert_transform_node(
94
88
 
95
89
  Currently only supports transforms that contain a single tri tessellation node.
96
90
  """
91
+ import clr
92
+
93
+ clr.AddReference("Ansys.Mechanical.DataModel")
94
+ clr.AddReference("Ansys.ACT.Interfaces")
95
+
96
+ import Ansys # isort: skip
97
+
97
98
  child_node = node.Child
98
99
  if isinstance(child_node, Ansys.Mechanical.Scenegraph.TriTessellationNode):
99
100
  prim = _create_prim_with_transform(stage, path, node)
@@ -101,19 +102,42 @@ def _convert_transform_node(
101
102
  _convert_tri_tessellation_node(child_node, stage, child_path, rgb)
102
103
 
103
104
 
104
- def to_usd_stage(app: "ansys.mechanical.core.embedding.App", name: str) -> None:
105
- """Convert mechanical scene to usd stage."""
106
- stage = Usd.Stage.CreateNew(name)
105
+ def _convert_attribute_node(
106
+ node: "Ansys.Mechanical.Scenegraph.AttributeNode",
107
+ stage: Usd.Stage,
108
+ path: str,
109
+ ) -> None:
110
+ """Add a Usd Prim of the child node with the given attributes node.
107
111
 
112
+ Currently only supports color attributes.
113
+ """
114
+ import clr
115
+
116
+ clr.AddReference("Ansys.Mechanical.DataModel")
117
+ clr.AddReference("Ansys.ACT.Interfaces")
118
+
119
+ import Ansys # isort: skip
120
+
121
+ child_node = node.Child
122
+ color = node.Property(Ansys.Mechanical.Scenegraph.ScenegraphIntAttributes.Color)
123
+ _convert_transform_node(child_node, stage, path, bgr_to_rgb_tuple(color))
124
+
125
+
126
+ def load_into_usd_stage(scene: "Ansys.Mechanical.Scenegraph.GroupNode", stage: Usd.Stage) -> None:
127
+ """Load mechanical scene into usd stage `stage`."""
108
128
  root_prim = UsdGeom.Xform.Define(stage, "/root")
109
129
 
110
- category = Ansys.Mechanical.DataModel.Enums.DataModelObjectCategory.Body
111
- bodies = app.DataModel.GetObjectsByType(category)
112
- for body in bodies:
113
- scenegraph_node = Ansys.ACT.Mechanical.Tools.ScenegraphHelpers.GetScenegraph(body)
114
- body_path = root_prim.GetPath().AppendPath(f"body{body.ObjectId}")
115
- _convert_transform_node(scenegraph_node, stage, body_path, bgr_to_rgb_tuple(body.Color))
130
+ for child in scene.Children:
131
+ child: "Ansys.Mechanical.Scenegraph.AttributeNode" = child
132
+ child_path = root_prim.GetPath().AppendPath(child.Tag)
133
+ _convert_attribute_node(child, stage, child_path)
116
134
 
135
+
136
+ def to_usd_stage(app: "ansys.mechanical.core.embedding.App", name: str) -> Usd.Stage:
137
+ """Convert mechanical scene to new usd stage and return it."""
138
+ stage = Usd.Stage.CreateNew(name)
139
+ scene = get_scene(app)
140
+ load_into_usd_stage(scene, stage)
117
141
  return stage
118
142
 
119
143
 
@@ -59,3 +59,32 @@ def get_nodes_and_coords(tri_tessellation: "Ansys.Mechanical.Scenegraph.TriTesse
59
59
  )
60
60
  np_indices = _reshape_3cols(np.array(tri_tessellation.Indices, dtype=np.int32), "indices")
61
61
  return np_coordinates, np_indices
62
+
63
+
64
+ def get_scene(
65
+ app: "ansys.mechanical.core.embedding.App",
66
+ ) -> "Ansys.Mechanical.Scenegraph.GroupNode":
67
+ """Get the scene of the model."""
68
+ import clr
69
+
70
+ clr.AddReference("Ansys.Mechanical.DataModel")
71
+ clr.AddReference("Ansys.Mechanical.Scenegraph")
72
+ clr.AddReference("Ansys.ACT.Interfaces")
73
+
74
+ import Ansys # isort: skip
75
+
76
+ category = Ansys.Mechanical.DataModel.Enums.DataModelObjectCategory.Body
77
+ group_node = Ansys.Mechanical.Scenegraph.Builders.GroupNodeBuilder()
78
+ for body in app.DataModel.GetObjectsByType(category):
79
+ scenegraph_node = Ansys.ACT.Mechanical.Tools.ScenegraphHelpers.GetScenegraph(body)
80
+ # wrap the body node in an attribute node using the body color
81
+ attribute_node_builder = Ansys.Mechanical.Scenegraph.Builders.AttributeNodeBuilder()
82
+ attribute_node = (
83
+ attribute_node_builder.Tag(f"body{body.ObjectId}")
84
+ .Child(scenegraph_node)
85
+ # set the color, body.Color is a BGR uint bitfield
86
+ .Property(Ansys.Mechanical.Scenegraph.ScenegraphIntAttributes.Color, body.Color)
87
+ .Build()
88
+ )
89
+ group_node.AddChild(attribute_node)
90
+ return group_node.Build()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ansys-mechanical-core
3
- Version: 0.11.4
3
+ Version: 0.11.6
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,18 +27,18 @@ 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.7 ; extra == "doc"
31
- Requires-Dist: ansys-sphinx-theme[autoapi]==0.16.6 ; extra == "doc"
32
- Requires-Dist: grpcio==1.65.4 ; extra == "doc"
30
+ Requires-Dist: sphinx==8.0.2 ; extra == "doc"
31
+ Requires-Dist: ansys-sphinx-theme[autoapi]==1.0.7 ; extra == "doc"
32
+ Requires-Dist: grpcio==1.66.0 ; extra == "doc"
33
33
  Requires-Dist: imageio-ffmpeg==0.5.1 ; extra == "doc"
34
- Requires-Dist: imageio==2.34.2 ; extra == "doc"
34
+ Requires-Dist: imageio==2.35.1 ; extra == "doc"
35
35
  Requires-Dist: jupyter_sphinx==0.5.3 ; extra == "doc"
36
36
  Requires-Dist: jupyterlab>=3.2.8 ; extra == "doc"
37
- Requires-Dist: matplotlib==3.9.1 ; extra == "doc"
38
- Requires-Dist: numpy==2.0.1 ; extra == "doc"
39
- Requires-Dist: numpydoc==1.7.0 ; extra == "doc"
37
+ Requires-Dist: matplotlib==3.9.2 ; extra == "doc"
38
+ Requires-Dist: numpy==2.1.0 ; extra == "doc"
39
+ Requires-Dist: numpydoc==1.8.0 ; extra == "doc"
40
40
  Requires-Dist: pandas==2.2.2 ; extra == "doc"
41
- Requires-Dist: panel==1.4.4 ; extra == "doc"
41
+ Requires-Dist: panel==1.4.5 ; extra == "doc"
42
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"
@@ -47,9 +47,9 @@ Requires-Dist: pyvista>=0.39.1 ; extra == "doc"
47
47
  Requires-Dist: sphinx-autobuild==2024.4.16 ; extra == "doc"
48
48
  Requires-Dist: sphinx-autodoc-typehints==2.2.3 ; extra == "doc"
49
49
  Requires-Dist: sphinx-copybutton==0.5.2 ; extra == "doc"
50
- Requires-Dist: sphinx_design==0.6.0 ; extra == "doc"
51
- Requires-Dist: sphinx-gallery==0.17.0 ; extra == "doc"
52
- Requires-Dist: sphinx-notfound-page==1.0.2 ; extra == "doc"
50
+ Requires-Dist: sphinx_design==0.6.1 ; extra == "doc"
51
+ Requires-Dist: sphinx-gallery==0.17.1 ; extra == "doc"
52
+ Requires-Dist: sphinx-notfound-page==1.0.4 ; extra == "doc"
53
53
  Requires-Dist: sphinxcontrib-websupport==2.0.0 ; extra == "doc"
54
54
  Requires-Dist: sphinxemoji==0.3.1 ; extra == "doc"
55
55
  Requires-Dist: pytest==8.3.2 ; extra == "tests"
@@ -66,8 +66,9 @@ Provides-Extra: doc
66
66
  Provides-Extra: tests
67
67
  Provides-Extra: viz
68
68
 
69
- .. image:: https://raw.githubusercontent.com/ansys/pymechanical/main/doc/source/_static/logo/pymechanical-logo-light.png
69
+ .. image:: https://raw.githubusercontent.com/ansys/pymechanical/main/doc/source/_static/logo/pymechanical-logo.png
70
70
  :alt: PyMechanical logo
71
+ :width: 580px
71
72
 
72
73
 
73
74
  |pyansys| |pypi| |python| |GH-CI| |codecov| |MIT| |black|
@@ -117,7 +118,7 @@ Mechanical within Python's ecosystem. It includes the ability to:
117
118
  Install the package
118
119
  -------------------
119
120
 
120
- Install PyMechanical using `pip` with::
121
+ Install PyMechanical using ``pip`` with::
121
122
 
122
123
  pip install ansys-mechanical-core
123
124
 
@@ -10,7 +10,7 @@ ansys/mechanical/core/pool.py,sha256=HzU64Ew5QgoKeoZkywdmS_lmuGSCwe-PvucI5y1Hqa0
10
10
  ansys/mechanical/core/run.py,sha256=ScB-Ne8KkLuA0EQtquUa8JKFsA8Ert8nUUtxHTlQR4A,9814
11
11
  ansys/mechanical/core/embedding/__init__.py,sha256=y0yp3dnBW2oj9Jh_L_qfZstAbpON974EMmpV9w3kT3g,1356
12
12
  ansys/mechanical/core/embedding/addins.py,sha256=yRG8CT1f1MgQj0y_mP3ISePVp7t9erw0o5Sbn1tFNkc,2370
13
- ansys/mechanical/core/embedding/app.py,sha256=KFYs4MEvxrzCP6IRBPeeZyGtVzVVochVfqWT5bS1eWI,16145
13
+ ansys/mechanical/core/embedding/app.py,sha256=hnP-eAFFekfHPuHxHc7wJraDa1DO7s2J65dWtKzRJ9U,16195
14
14
  ansys/mechanical/core/embedding/app_libraries.py,sha256=RiTO23AzjssAylIH2DaTa6mcJmxhfrlHW-yYvHpIkt0,2923
15
15
  ansys/mechanical/core/embedding/appdata.py,sha256=krcmcgHhraHIlORFr43QvUXlAiXg231g_2iOIxkW_aQ,4223
16
16
  ansys/mechanical/core/embedding/background.py,sha256=ICm87gO6CDA4Ot_6Yf3-8YPNUEa3PHWieOECXeUfZmM,3650
@@ -30,13 +30,13 @@ ansys/mechanical/core/embedding/logger/linux_api.py,sha256=VrsO9F4NwHFWYJJE6F7bi
30
30
  ansys/mechanical/core/embedding/logger/sinks.py,sha256=FYmV2iWt-7KuGw40E5WcNm4AnDsWqw6aQKSMKlivYoo,1392
31
31
  ansys/mechanical/core/embedding/logger/windows_api.py,sha256=OCJ-SJEY7EjigZiW6H5qufQ39N_mL7sXeoivOVl9FHc,5248
32
32
  ansys/mechanical/core/embedding/viz/__init__.py,sha256=xgpBdf3yfEq3sn0bNewLwtje-SCH6vVWEmHfCdh6078,1206
33
- ansys/mechanical/core/embedding/viz/embedding_plotter.py,sha256=JgitPNYanqUImqT1gEtaUIDGmPk99mhuoi0ZTAkuoQ8,3604
34
- ansys/mechanical/core/embedding/viz/usd_converter.py,sha256=5fjbUq9-nNtKBF5e7Z3Yxgs7jzmTUayWcRANrsIHM-A,4657
35
- ansys/mechanical/core/embedding/viz/utils.py,sha256=pIROh87BI_OxJtkM8To9KYulpygdQ6I3g1f1BJQ-SBE,2441
33
+ ansys/mechanical/core/embedding/viz/embedding_plotter.py,sha256=ausbFhezwmLCGhu61JZJDM_uxwpRRuM-XWw9mk4i0GQ,3689
34
+ ansys/mechanical/core/embedding/viz/usd_converter.py,sha256=feDq2KrZhYL-RR1miECQL-y0VNDhnZQ9Wke5UOkYmp4,5329
35
+ ansys/mechanical/core/embedding/viz/utils.py,sha256=NWc18HLshIpO7wgZpwfduKG5wReaYtVtJPChOosKXLU,3638
36
36
  ansys/mechanical/core/examples/__init__.py,sha256=A1iS8nknTU1ylafHZpYC9LQJ0sY83x8m1cDXsgvFOBo,1267
37
37
  ansys/mechanical/core/examples/downloads.py,sha256=lJ2SrX9Qs0t2FSmMwUBB4UgSpk6Qb2-coY1PLlzPzHU,4144
38
- ansys_mechanical_core-0.11.4.dist-info/entry_points.txt,sha256=wRXPv0eRXSmodweJHjF_Y3x5wmeSmjWcY3Bo6B4tAiM,66
39
- ansys_mechanical_core-0.11.4.dist-info/LICENSE,sha256=gBJ2GQ6oDJwAWxcxmjx_0uXc-N0P4sHhA7BXsdPTfco,1098
40
- ansys_mechanical_core-0.11.4.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
41
- ansys_mechanical_core-0.11.4.dist-info/METADATA,sha256=9LG4h1VMmOL6W9xeLI8eZ4CzeP-7oqbM6lJSlrskS5Q,9771
42
- ansys_mechanical_core-0.11.4.dist-info/RECORD,,
38
+ ansys_mechanical_core-0.11.6.dist-info/entry_points.txt,sha256=wRXPv0eRXSmodweJHjF_Y3x5wmeSmjWcY3Bo6B4tAiM,66
39
+ ansys_mechanical_core-0.11.6.dist-info/LICENSE,sha256=gBJ2GQ6oDJwAWxcxmjx_0uXc-N0P4sHhA7BXsdPTfco,1098
40
+ ansys_mechanical_core-0.11.6.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
41
+ ansys_mechanical_core-0.11.6.dist-info/METADATA,sha256=lhSKf_O6fNcwxZ-WushtsxuXTLExAud-2OLKm04q-L0,9783
42
+ ansys_mechanical_core-0.11.6.dist-info/RECORD,,