-
Notifications
You must be signed in to change notification settings - Fork 140
Closed
Description
Importing PyMAPDL is broken. The following code crashes the terminal:
using PyCall
pymapdl = pyimport("ansys.mapdl.core")It seems this is due to the helper objects we create in plotting.py.
pymapdl/src/ansys/mapdl/core/plotting.py
Lines 74 to 147 in 22b85be
| TEMP = pv.Sphere(center=(0, 0, 0), radius=0.5) | |
| UX = pv.Arrow( | |
| start=(-1, 0, 0), | |
| direction=(1, 0, 0), | |
| tip_length=1, | |
| tip_radius=0.5, | |
| scale=1.0, | |
| ) | |
| UY = pv.Arrow( | |
| start=(0, -1, 0), | |
| direction=(0, 1, 0), | |
| tip_length=1, | |
| tip_radius=0.5, | |
| scale=1.0, | |
| ) | |
| UZ = pv.Arrow( | |
| start=(0, 0, -1), | |
| direction=(0, 0, 1), | |
| tip_length=1, | |
| tip_radius=0.5, | |
| scale=1.0, | |
| ) | |
| FX = pv.Arrow( | |
| start=(-1, 0, 0), | |
| direction=(1, 0, 0), | |
| tip_length=0.5, | |
| tip_radius=0.25, | |
| scale=1.0, | |
| ) | |
| FY = pv.Arrow( | |
| start=(0, -1, 0), | |
| direction=(0, 1, 0), | |
| tip_length=0.5, | |
| tip_radius=0.25, | |
| scale=1.0, | |
| ) | |
| FZ = pv.Arrow( | |
| start=(0, 0, -1), | |
| direction=(0, 0, 1), | |
| tip_length=0.5, | |
| tip_radius=0.25, | |
| scale=1.0, | |
| ) | |
| def get_VOLT(): | |
| model_a = pv.Cylinder( | |
| center=(0, 0, 0), direction=(1, 0, 0), radius=0.2, height=2 | |
| ).triangulate() | |
| model_b = pv.Cylinder( | |
| center=(0, 0, 0), direction=(0, 1, 0), radius=0.2, height=2 | |
| ).triangulate() | |
| model_c = pv.Cylinder( | |
| center=(0, 0, 0), direction=(0, 0, 1), radius=0.2, height=2 | |
| ).triangulate() | |
| result = model_a.merge(model_b).triangulate() | |
| result = result.merge(model_c) | |
| result.rotate_z(45.0, inplace=True) | |
| result.rotate_vector( | |
| vector=(1, -1, 0), angle=-45, point=(0, 0, 0), inplace=True | |
| ) | |
| return result | |
| VOLT = get_VOLT() | |
| HEAT = pv.Cube(center=(0, 0, 0), x_length=1.0, y_length=1.0, z_length=1.0) |
One way to mitigate that, is making those objects attributes of a new class:
# Symbols for constrains
class DefaultSymbol:
def __init__(self):
self.TEMP = pv.Sphere(center=(0, 0, 0), radius=0.5)
....Temporary fix
There are two temporary solutions until I have time to implement the above change.
- Uninstall pyvista from the local python environment (in
PyCall.python) - If PyMAPDL is installed in editable you can replace the following line 70:
pymapdl/src/ansys/mapdl/core/plotting.py
Line 70 in 22b85be
if _HAS_PYVISTA:
by:
if _HAS_PYVISTA and False:
import pyvista as pvBut this can create issues later.
Metadata
Metadata
Assignees
Labels
No labels