Skip to content

Commit 8f4bf0a

Browse files
germa89akaszynski
andauthored
Fix/ adding star repeat to non interactive only (#675)
* Added '*REPEAT` to INVAL_COMMANDS * Added '*REPEAT` to INVAL_COMMANDS * Updated test unit. * Added mechanism to wrap *REPEAT in a non_interactive block when converting APDL code. * Grammar fixing. * Added missing return * Update ansys/mapdl/core/convert.py Co-authored-by: Alex Kaszynski <[email protected]> Co-authored-by: Alex Kaszynski <[email protected]>
1 parent 1b5ac00 commit 8f4bf0a

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

ansys/mapdl/core/convert.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,16 @@ def translate_line(self, line):
169169
if not line:
170170
return
171171

172+
if line[:4].upper() == "*REP":
173+
if not self.non_interactive:
174+
prev_cmd = self.lines.pop(-1)
175+
self.start_non_interactive()
176+
new_prev_cmd = ' ' + prev_cmd # Since we are writing in self.lines we need to add the indentation by ourselves.
177+
self.lines.append(new_prev_cmd)
178+
self.store_run_command(line) # Using run but it could be `store_command`
179+
self.end_non_interactive()
180+
return
181+
172182
if line[:4].upper() in COMMANDS_TO_NOT_BE_CONVERTED:
173183
self.store_run_command(line)
174184
return

ansys/mapdl/core/mapdl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
"/EOF": "Unsupported command. Use ``exit`` to stop the server.",
6060
"*ASK": "Unsupported command. Use python ``input`` instead.",
6161
"*IF": "Use a python ``if`` or run as non_interactive",
62-
"CMAT": "Use as non_interactive",
62+
"CMAT": "Run `CMAT` as ``non_interactive``.",
63+
"*REP": "Run '*REPEAT' in ``non_interactive``."
6364
}
6465

6566
## Soft-invalid commands

tests/test_mapdl.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ def test_cdread_in_apdl_directory(mapdl, cleared):
839839

840840
def test_inval_commands(mapdl, cleared):
841841
"""Test the output of invalid commands"""
842-
cmds = ["*END", "*vwrite", "/eof", "cmatrix"]
842+
cmds = ["*END", "*vwrite", "/eof", "cmatrix", "*REpeAT"]
843843
for each_cmd in cmds:
844844
with pytest.raises(RuntimeError):
845845
mapdl.run(each_cmd)

0 commit comments

Comments
 (0)