Closed Eistee1024 closed 1 year ago
Hi @Eistee1024 @germa89 Well this is interesting:
Looks like another bug. @germa89...
Hi all,
I couldn't replicate what @Eistee1024 is showing, for me the empty parameters are correctly parsed. As @mikerife showed:
>>> from ansys.mapdl.core.convert import convert_apdl_block
>>> code = """
view,1,,1,
view,1,,1
view,1,,1,,
"""
"""Script generated by ansys-mapdl-core version 0.64.dev0"""
from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(loglevel="WARNING", print_com=True)
mapdl.view(1, 1)
mapdl.view(1, "", 1)
mapdl.view(1, "", 1)
mapdl.exit()
Could you @Eistee1024 try to upgrade to the latest PyMAPDL and let me know if you still have the issue?
Now, as @mikerife showed, there is an issue with the parameters which starts with /
or *
because converter translate them directly usign mapdl.run
which is not right.
This is being fixed now in #1478
Ok, I replicated the issue:
In [8]: print(convert_apdl_block("vget,1,,'asdf',", only_commands=True))
mapdl.vget(1, "asdf")
In [9]: print(convert_apdl_block("vget,1,,'asdf'", only_commands=True))
mapdl.vget(1, "", "asdf")
It seems is related to the ending ",". I will keep investigating.
Funny, I got the reason why it was failing:
for ind, each in enumerate(line_)):
if each:
break
else:
line_.pop(ind)
line = ",".join(line_[::-1])
Because I was pop
ing on the same object list object (line_
) it was skipping some arguments.
The solution was to do:
for ind, each in enumerate(line_.copy()):
if each:
break
else:
line_.pop(ind)
line = ",".join(line_[::-1])
More stable:
for ind, each in enumerate(line_):
if each.strip(): # To clear spaces in empty arguments.
break
line = ",".join(line_[ind:][::-1])
Before submitting the issue
pip install --upgrade --upgrade-strategy eager ansys-mapdl-core
)Description of the bug
The pymapdl.convert_script skips empty values instead of filling them or maintaining them.
Example: apdl code
/VIEW,1,,1,
is interpreted as/VIEW,1,0,1,0
by ANSYS and works just fine. converter_script translates/VIEW,1,,1,
tomapdl.run("/VIEW,1,1")
, which is interpreted by ANSYS as/VIEW,1,1,0,0
instead of the intended/VIEW,1,0,1,0
Maybe I am lazy, but I am used to using double comma for empty parameters. Took me some time to find this now. Once you know this it's no big deal 😅
Steps To Reproduce
put
/VIEW,1,,1,
in a filetranslate it using pymapdl.convert_script
see the result
Which Operating System are you using?
No response
Which Python version are you using?
No response
PyMAPDL Report
PyMAPDL Software and Environment Report
Packages Requirements
Core packages
ansys.mapdl.core : 0.63.0 numpy : 1.23.1 appdirs : 1.4.4 scipy : 1.8.1 grpc : Package not found ansys.api.mapdl.v0 : Package not found ansys.mapdl.reader : 0.51.15 google.protobuf : Package not found
Optional packages
matplotlib : 3.5.2 pyvista : 0.36.1 pyiges : 0.2.1 tqdm : 4.64.0 ansys_corba : 0.1.0
Ansys Installation
Version Location
221 C:\Program Files\ANSYS Inc\v221
Ansys Environment Variables
ANSYS221_DIR C:\Program Files\ANSYS Inc\v221\ANSYS ANSYS222_DIR C:\Program Files\ANSYS Inc\v222\ANSYS ANSYSLIC_DIR C:\Program Files\ANSYS Inc\Shared Files\Licensing ANSYSLI_SERVERS 2325@tbhw1 ANSYSLMD_LICENSE_FILE 1055@tbhw1 ANSYS_SYSDIR winx64 ANSYS_SYSDIR32 win32 AWP_LOCALE192 en-us AWP_LOCALE202 en-us AWP_LOCALE221 en-us AWP_LOCALE222 en-us AWP_ROOT221 C:\Program Files\ANSYS Inc\v221 AWP_ROOT222 C:\Program Files\ANSYS Inc\v222 CADOE_LIBDIR221 C:\Program Files\ANSYS Inc\v221\CommonFiles\Language\de CADOE_LIBDIR222 C:\Program Files\ANSYS Inc\v222\CommonFiles\Language\de
Installed packages
--