Closed germa89 closed 1 year ago
I have faced a similar problem. I was about to post it in discussion #1624, but since I saw this opened issue I opted to do it here.
I am trying to generate a report using Pymapdl and Jupyter notebooks (with which I am not very familiar yet, I must admit) but I am having troubles when inserting the plot as static images in the exported HTML (on Windows)
My first issue is that I am not able to embed the VTK/Pyvista widgets as static into the HTML using the Jupyter-lab interface (the output appears white), but this is 99% sure not Pymapdl's problem, but jupyter's. I just mention it here in case somebody reads it and can give me some advice. In this attachment you can see the PDF output, up to step 4 of lathe_cutter.ipynb
(generated by opening HTML in MS Edge and printing (Ctrl+P))
As a workaround to that, I have decided to switch to non-interactive widgets using the vtk=False
option of ansys.mapdl.core.plotting.general_plotter
, because embedding static matplotlib plots in HTML does work in my jupyter-lab.
My actual Pymapdl issue is that I am not able to apply even this workaround to a basic pymapdl notebook that I have created from scratch (below), whose output is this: 1_post-lab.pdf.
# %%
%matplotlib inline
# %% [markdown]
# 1. start ANSYS APDL session from python
# %%
from ansys.mapdl.core import launch_mapdl
import os
from os import path
import platform
import numpy as np
curdir = os.getcwd()
# license = "ansys" # Ansys Mechanical Enterprise
license = "mech_2" # Ansys Mechanical Premium
if 'Windows' in platform.system():
execfile = "C:\\Program Files\\ANSYS Inc\\v212\\ansys\\bin\\winx64\\ANSYS212.exe"
else:
execfile = ""
mapdl = launch_mapdl(exec_file=execfile, run_location=curdir, license_type=license, override=True, additional_switches='-smp')
print(mapdl)
# %% [markdown]
# 2. Run the APDL input file and save the .db
# %%
mapdl.input("0_main.inp")
# %%
mapdl.prep7()
mapdl.allsel()
# mapdl.nplot(plot_bc=True)
#mapdl.show('png')
mapdl.nplot(vtk=False)
#mapdl.show('close')
# %%
mapdl.post1()
mapdl.plesol(item='F',comp='X',vtk=False, savefig='plesol.png')
# %%
mapdl.exit()
At first I had not written the initial %matplotlib inline% command
, so I thought that that would be the issue; but it was not. I am invoking plotting commands at prep7
and post1
processors, and none of them works. I also tried the mapdl.show('png')
+ mapdl.show('close')
pair, and also nothing changes (they are commented in the version I have posted).
Probably there is something basic which I am not using correctly, but I cannot find what it is. I do not think that it is a problem with my environment, because the lathe_cutter example works fine.
Hi @Jalmenara
Can you send also the input file 0_main.inp
??
Kind regards,
Hi @germa89. Sure! I forgot ...
It is actually the same input I was using in issue #1650
Hi @Jalmenara
Apologies for the (very) late answer. I'm just cleaning issues.
When I run your code with v0.65.0 I get the following error:
MapdlCommandIgnoredError: DISPLAY ELEMENT SOLUTION, ITEM=F COMP=X
*** WARNING *** CP = 64.971 TIME= 09:20:45
Element forces are not available for display. The PLESOL command is
ignored.
Ignore these messages by setting 'ignore_errors'=True
Probably this error wasn't caught by PyMAPDL in the version back then (because you do not mention it).
Please plot other boundary loads/results.
Discussed in https://github.com/pyansys/pymapdl/discussions/1624