Skip to content

Commit 430400a

Browse files
authored
Permit *.dat as Archive Objects (ansys#307)
* updated to read input files from workbench * fix edge case segfault
1 parent aaedc81 commit 430400a

File tree

4 files changed

+169
-116
lines changed

4 files changed

+169
-116
lines changed

pyansys/archive.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@
2424

2525

2626
class Archive(Mesh):
27-
"""Read a blocked ANSYS archive file.
27+
"""Read a blocked ANSYS archive file or input file.
2828
2929
Reads a blocked CDB file and optionally parses it to a vtk grid.
30+
This can be used to read in files written from MAPDL using the
31+
``CDWRITE`` command or input files (``*.dat) files written from
32+
ANSYS Workbench.
3033
3134
Write the archive file using ``CDWRITE, DB, archive.cdb``
3235
@@ -58,6 +61,13 @@ class Archive(Mesh):
5861
as empty (null) elements. Useful for debug or tracking
5962
element numbers. Default False.
6063
64+
verbose : bool, optional
65+
Print out each step when reading the archive file. Used for
66+
debug purposes and defaults to ``False``.
67+
68+
name : str, optional
69+
Internally used parameter used to have a custom ``__repr__``.
70+
6171
Examples
6272
--------
6373
>>> import pyansys
@@ -80,6 +90,18 @@ class Archive(Mesh):
8090
[0.75, 0.5 , 3.5 ],
8191
[0.75, 0.5 , 4. ],
8292
[0.75, 0.5 , 4.5 ]])
93+
94+
Read an ANSYS workbench input file
95+
96+
>>> my_archive = pyansys.Archive('C:\\Users\\jerry\\stuff.dat')
97+
98+
Notes
99+
-----
100+
This class only reads EBLOCK records with SOLID records. For
101+
example, the record ``EBLOCK,19,SOLID,,3588`` will be read, but
102+
``EBLOCK,10,,,3588`` will not be read. Generally, MAPDL will only
103+
write SOLID records and Mechanical Workbench may write SOLID
104+
records. These additional records will be ignored.
83105
"""
84106

85107
def __init__(self, filename, read_parameters=False,
@@ -198,7 +220,12 @@ def quality(self):
198220

199221
@wraps(pv.plot)
200222
def plot(self, *args, **kwargs):
201-
"""Plot the ANSYS archive file"""
223+
"""Plot the mesh"""
224+
if self._grid is None: # pragma: no cover
225+
raise AttributeError('Archive must be parsed as a vtk grid.\n'
226+
'Set `parse_vtk=True`')
227+
kwargs.setdefault('color', 'w')
228+
kwargs.setdefault('show_edges', True)
202229
self.grid.plot(*args, **kwargs)
203230

204231

0 commit comments

Comments
 (0)