-
I want to import an IGES file and then show it, but I get an error from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(loglevel="ERROR")
# clear
mapdl.finish()
mapdl.clear()
mapdl.prep7()
mapdl.igesin("D:/1", "IGS")
mapdl.geometry.areas.plot() Here's the error message
Also, I have this question, if I want to import a file in STL format and do finite element analysis, is there any way? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Hi @tryzang try using Mechanical APDL interactive and import the iges file. It may be failing in a bad way (that takes down the gRPC connection). What CAD program created the iges file? If Space Claim or Design Modeler try exporting an ANF file instead, then using the 'input' command to read it into MAPDL aaS in PyMAPDL. MAPDL does not support STL directly. If you have access to Space Claim you can use that to import the STL, then convert to a regular body then export out the ANF. Or since STL is just a lot of triagles, maybe you can create a STL-to-APDL convertor and write out a MAPDL keypoint for every STL point. Then a APDL area for each STL triangle. Then in MAPDL create the volume from all the areas. The STL format is publically available. Mike |
Beta Was this translation helpful? Give feedback.
-
Mike @mikerife, hello. First of all, thank you very much for your reply. I built my model using SolidWorks and then exported it to STL and IGES formats. My work requires automating the finite element analysis of many complex STL models, and this process cannot be done using a GUI. So, I chose PyANSYS for this. It has performed excellently in this regard. Due to the reasons mentioned above, and the fact that I did not find a Python interface for Space Claim or Design Modeler in the list of supported modules for PyANSYS, I cannot use Space Claim or Design Modeler to convert the models. Therefore, I can only use a third-party Python library to convert the STL files to IGES files and then import them into PyANSYS. Unfortunately, during this process, I encounter a disconnection error. Is there a way to solve this error or determine its cause? Additionally, in the past few days, I have found a method which involves importing the file into a temporary file and then importing it into PyANSYS. The code is attached below. I am not sure if this method has any limitations or how feasible it is. Once again, thank you for your reply, and I look forward to hearing from you again. import os
import tempfile
from ansys.mapdl.reader import save_as_archive
import pyvista as pv
from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(loglevel="ERROR")
#Read an STL file using PyVista.
mesh = pv.read('part.stl')
#Save mesh as temporary file
archive_filename = os.path.join(tempfile.gettempdir(), "tmp.cdb")
save_as_archive(archive_filename, mesh)
#Read the grid from a temporary file
response = mapdl.cdread("db", archive_filename)
mapdl.prep7()
mapdl.eplot()
mapdl.exit() |
Beta Was this translation helpful? Give feedback.
-
Thank you @germa89 for your reply. Of course, I can provide the model files. Since it's still in the development stage, I've only used a very simple model. The compressed file below contains the STL and IGES formats of this model. model.zip. |
Beta Was this translation helpful? Give feedback.
-
@tryzang @germa89 from ansys.mapdl.core import launch_mapdl
import os
path = os.getcwd()
mapdl = launch_mapdl(run_location=path)
with mapdl.non_interactive:
mapdl.run("/aux15")
mapdl.run("igesin, part, IGS")
mapdl.run("finish")
mapdl.prep7()
mapdl.nummrg('kp')
mapdl.va('all')
mapdl.vplot() mike |
Beta Was this translation helpful? Give feedback.
Hi @tryzang try using Mechanical APDL interactive and import the iges file. It may be failing in a bad way (that takes down the gRPC connection). What CAD program created the iges file? If Space Claim or Design Modeler try exporting an ANF file instead, then using the 'input' command to read it into MAPDL aaS in PyMAPDL.
MAPDL does not support STL directly. If you have access to Space Claim you can use that to import the STL, then convert to a regular body then export out the ANF.
Or since STL is just a lot of triagles, maybe you can create a STL-to-APDL convertor and write out a MAPDL keypoint for every STL point. Then a APDL area for each STL triangle. Then in MAPDL create the volume fr…