question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

mapdl.cdread() doesn't seem to work, when cdb file directory is specified via mapdl.cwd()

See original GitHub issue

I am trying to do read a cdb file using mapdl.cdread() and provided the working directory via mapdl.cwd(). However, I get some errors.

Here are the commands I have used:

from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(exec_file='C:\\Program Files\\ANSYS Inc\\v212\\ansys\\bin\\winx64\\ansys212.exe', loglevel='ERROR',additional_switches='-smp',nproc=2)
mapdl.cwd(r'D:\AKD\PyANSYS\issues\cdb')
mapdl.prep7()
mapdl.cdread('db',fname='test',ext='db')

Errors I get:

Traceback (most recent call last):
  File "C:/Users/rgpatchi/PycharmProjects/pythonProject/venv/issue_rst_testing.py", line 10, in <module>
    mapdl.cdread('db',fname='test',ext='db')
  File "C:\Users\rgpatchi\PycharmProjects\pythonProject\venv\lib\site-packages\ansys\mapdl\core\mapdl_grpc.py", line 933, in cdread
    fname = kwargs.get('fname', args[1])
IndexError: tuple index out of range

I was able to workaround this issue using the below code.

import os
from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl(exec_file='C:\\Program Files\\ANSYS Inc\\v212\\ansys\\bin\\winx64\\ansys212.exe', loglevel='ERROR',additional_switches='-smp',nproc=2)
mapdl.cwd(r'D:\AKD\PyANSYS\issues\cdb')

my_path = r'D:\AKD\PyANSYS\issues\cdb'
my_file = os.path.join(my_path,'test.cdb')

mapdl.prep7()
#mapdl.cdread('db',fname='test',ext='db')
mapdl.cdread('db',my_file,'cdb')

mapdl.eplot()

Is this a bug?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
germa89commented, Sep 29, 2021

Hi @RGPATCHI

Indeed this is a bug. Python checks if the file exists, but it checks in the python execution directory, not in the Mapdl directory (changed by cwd).

As you realized, input the full path to cdread fixes the issue.

I will look into this to be fixed in future releases. Thank you!

0reactions
germa89commented, Oct 5, 2021

Hi @mcMunich ! Feel free to create another issue and post some example code we can replicate. Regards,

Read more comments on GitHub >

github_iconTop Results From Across the Web

CDWRITE - BME-MM
Write only the solid model geometry and solid model load data. This output will be in IGES or ANF format, as specified in...
Read more >
/cwd will not change the directory if there are blank spaces in ...
I am trying to set the directory where a pymapdl analysis results will be saved using the /cwd command. I have found that...
Read more >
Post-Processing APDL Models in Mechanical | Ansys ...
By default, in APDL, contain element and node data for the model. Go to /PREP7 and use CDWRITE to write a CDB mesh...
Read more >
Path directory format in APDL - Ansys Learning Forum
Is there any option to avoid writing the path (so, the directories) in a way that directly is saving the file in the...
Read more >
How to open ANSYS APDL File in Workbench & Vice versa
This video explains, how to write workbench output file & how to read in APDL. Similarly, it explains how to write CDB file...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found