TAGGED: ansys-apdl, ansys-mapdl, ansys-mechanical-apdl, apdl, macro, pyansys
-
-
October 17, 2023 at 2:05 pmKoen FranseSubscriber
Hi all,
I'm trying to get a macro that is normally used in Ansys Mechan
ical, working in PyAnsys scripting. Normally, the macro is called in a 'Commands (APDL)' section under the Solution tree of my Modal analysis:
Containing the following lines:
finish
/psearch, C:
momain which moma.mac is the macro. Now I want to be able to run the macro seperately, after the Modal analysis has finished, in PyAnsys scripting. Therefore I set 'Save MPADL db' to Yes in Mechanical.
In PyAnsys, I set the path to the simulation folder containing the .db file:
mapdl=launch_mapdl(run_location=path)
And read the .db file:
mapdl.run("cdread,db,file.db")
I run the psearch command and execute the macro in the same way as in Workbench:
mapdl.run("/psearch,C:")
mapdl.run("moma")This gives me the output "USE COMMAND MACRO moma", but I'm not sure if the macro is actually ran, since the output file I expect is not created in the folder as it is when I run the macro in Mechanical. Is there something I am still doing wrong?
Thanks in advance!
-
October 18, 2023 at 6:50 amErik KostsonAnsys Employee
Hi
I would suggest to post this in the pyAnsys/pyMAPDL forum – also is your macro post processing results, then we need to read in the rst file.
See: FILE (ansys.com)
All the best
Erik
-
October 18, 2023 at 7:21 amKoen FranseSubscriber
Hey Erik,
Thanks, I'll post it in the pyMAPDL forum on git!
-
-
October 18, 2023 at 8:22 amErik KostsonAnsys Employee
Hi
So if you are post processing which I think you are, then:
Issue file so (if you are in the same directory as the file.rst results, otherwise give the file path - see file command in help manual for more info):
mapdl.run(“file,,rst”)
All the best
Erik
-
- The topic ‘Run macro with PyAnsys’ is closed to new replies.
-
446
-
199
-
194
-
166
-
162
© 2024 Copyright ANSYS, Inc. All rights reserved.