Skip to content

Commit 9dcc6a6

Browse files
committed
fix: error related to Union types in CustomFunctions
1 parent f965bbf commit 9dcc6a6

File tree

2 files changed

+91
-1
lines changed

2 files changed

+91
-1
lines changed

src/pyconverter/xml2py/custom_functions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,15 @@ def get_docstring_lists(filename: str) -> Tuple[list[str], list[str], list[str],
7474
if bool_def and not end_def:
7575
if ")" in line:
7676
end_def = True
77+
# TODO: Union types are ignored for now
78+
if re.search(r"\[(\w+, )+\w+\]", line) is not None:
79+
line = re.sub(r"\[(\w+, )+\w+\]", "", line)
7780
split_def = line.split(",")
7881
for split_arg in split_def:
7982
split_arg = split_arg.strip()
8083
if "**kwarg" in split_arg or split_arg == "self":
8184
break
82-
elif re.search(r"[a-zA-Z0-9_]+", split_arg) is None:
85+
elif re.search(r"\w+", split_arg) is None:
8386
break
8487
elif ":" in split_arg and "=" in split_arg:
8588
find = re.search(r"\w*(?=\:)", split_arg).group()
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Copyright (C) 2025 ANSYS, Inc. and/or its affiliates.
2+
# SPDX-License-Identifier: MIT
3+
#
4+
#
5+
# Permission is hereby granted, free of charge, to any person obtaining a copy
6+
# of this software and associated documentation files (the "Software"), to deal
7+
# in the Software without restriction, including without limitation the rights
8+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
# copies of the Software, and to permit persons to whom the Software is
10+
# furnished to do so, subject to the following conditions:
11+
#
12+
# The above copyright notice and this permission notice shall be included in all
13+
# copies or substantial portions of the Software.
14+
#
15+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
# SOFTWARE.
22+
23+
from typing import Optional, Union
24+
25+
26+
def enorm(self, enum: Union[str, int] = "", **kwargs) -> Optional[str]:
27+
"""Reorients shell element normals or line element node connectivity.
28+
29+
APDL Command: ENORM
30+
31+
Parameters
32+
----------
33+
enum: str, int
34+
Element number having the normal direction that the
35+
reoriented elements are to match.
36+
37+
Notes
38+
-----
39+
Reorients shell elements so that their outward normals are
40+
consistent with that of a specified element. ENORM can also be
41+
used to reorder nodal connectivity of line elements so that
42+
their nodal ordering is consistent with that of a specified
43+
element.
44+
45+
For shell elements, the operation reorients the element by
46+
reversing and shifting the node connectivity pattern. For
47+
example, for a 4-node shell element, the nodes in positions I,
48+
J, K and L of the original element are placed in positions J,
49+
I, L and K of the reoriented element. All 3-D shell elements
50+
in the selected set are considered for reorientation, and no
51+
element is reoriented more than once during the
52+
operation. Only shell elements adjacent to the lateral (side)
53+
faces are considered.
54+
55+
The command reorients the shell element normals on the same
56+
panel as the specified shell element. A panel is the geometry
57+
defined by a subset of shell elements bounded by free edges or
58+
T-junctions (anywhere three or more shell edges share common
59+
nodes).
60+
61+
Reorientation progresses within the selected set until either
62+
of the following conditions is true:
63+
64+
- The edge of the model is reached.
65+
66+
- More than two elements (whether selected or unselected) are
67+
adjacent to a lateral face.
68+
69+
In situations where unselected elements might undesirably
70+
cause case b to control, consider using ENSYM,0,,0,ALL instead
71+
of ENORM. It is recommended that reoriented elements be
72+
displayed and graphically reviewed.
73+
74+
You cannot use the ENORM command to change the normal
75+
direction of any element that has a body or surface load. We
76+
recommend that you apply all of your loads only after ensuring
77+
that the element normal directions are acceptable.
78+
79+
Real constant values are not reoriented and may be invalidated
80+
by an element reversal.
81+
82+
Examples
83+
--------
84+
>>> mapdl.enorm(1)
85+
86+
"""
87+
return self.run(f"ENORM,{enum}", **kwargs)

0 commit comments

Comments
 (0)