-
Any suggestion to run macro with arguments in PyMAPDL ? >>> out = mapdl.run("*use,gcmlife,1,0")
2022-07-14 14:19:44,726 [ERROR] ansys.mapdl.core.mapdl: USE DATA BLOCK gcmlife FROM *ULIB
*** ERROR *** CP = 0.375 TIME= 14:19:44
Cannot find macro file named gcmlife. Not searching for datablock
named gcmlife since no library has been specified with *ULIB command.
Traceback (most recent call last):
File "D:/Consulting_Team/Engagements_2022/Consulting_Projects/PyAnsys/PyDPF_Garrett/static2.py", line 57, in <module> out = mapdl.run("*use,gcmlife,1,0") # executing macro with arguments 1 and 0
File "C:\Users\vnamdeo\AppData\Local\Programs\Python\Python38\lib\site-packages\ansys\mapdl\core\mapdl.py", line 1778, in run
raise MapdlRuntimeError(self._response) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Hi @vnamdeo Where is the file 'gcmlife.mac' located? Was the MAPDL aaS instance started in a temp directory (default)? Was /psearch used to define the path to the macro? Depending on your answers you may want to copy the macro to the MAPDL working directory with the PyMAPDL 'upload' command since the MAPDL aaS instance can't find the macro file. Mike |
Beta Was this translation helpful? Give feedback.
-
Thanks, Mike for the suggestions. Just for the clarity, I have kept all the relevant files in the same working directory (local). And, passing few arguments via macro like we use to do using *use command in MAPDL. I gave due consideration to the path to recognize the macro. If we consider the macro as a input file to read via /input command line then it works (e.g. mapdl.input(mac_file)). However, we missed to provide the arguments as inputs to the macro. And, if we use *use command to read the macro and passing the arguments (e.g. mapdl.run("*use,gcmlife,1,0") ), it won't work. Also, Upload command won't help either. Please refer the Python script for your review and let me know your suggestion here (https://ansys-my.sharepoint.com/:f:/p/vikas_namdeo/EgEtjkuiu4xOsAgNOOAk8_oBKqBi4ZqRkC0-fd2CDuC6xw?email=Michael.Rife%40ansys.com&e=eyhpJ7) |
Beta Was this translation helpful? Give feedback.
-
PyMAPDL has a version of the *USE APDL command but the * character is dropped. So this will work if the macro is in the MAPDL working directory: mapdl.use("gmclife.mac,1,0") Or the *USE command can be issued non-interactively via the PyMAPDL 'run' command: with mapdl.non_interactive:
mapdl.run("*use,gcmlife.mac,1,0")
mapdl.last_response Or the macro just issued as if it were a command: with mapdl.non_interactive:
mapdl.run("gcmlife.mac,1,0")
mapdl.last_response Note that the mac extension is needed in either method. Mike |
Beta Was this translation helpful? Give feedback.
PyMAPDL has a version of the *USE APDL command but the * character is dropped. So this will work if the macro is in the MAPDL working directory:
Or the *USE command can be issued non-interactively via the PyMAPDL 'run' command:
Or the macro just issued as if it were a command:
Note that the mac extension is needed in either method. Mike