Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/changelog.d/7298.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dxf fixes on mcad & ecad
19 changes: 11 additions & 8 deletions src/ansys/aedt/core/application/analysis_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ def check_intersections(output, input_list, cad_in=None):
def import_dxf(
self,
input_file: str | Path,
layers: list[str],
layers: list[str] = None,
auto_detect_close: bool = True,
self_stitch: bool = True,
self_stitch_tolerance: float = 0.0,
Expand All @@ -1247,9 +1247,9 @@ def import_dxf(
----------
input_file : str or :class:`pathlib.Path`
Path to the DXF file.
layers : list
List of layer names to import. To get the dxf_layers in the DXF file,
you can call the ``get_dxf_layers`` method.
layers : list, optional
List of layer names to import, if ``None`` or empty list all layers will be imported.
To get the layers in the DXF file, you can call the ``get_dxf_layers`` method.
auto_detect_close : bool, optional
Whether to check polylines to see if they are closed.
The default is ``True``. If a polyline is closed, the modeler
Expand Down Expand Up @@ -1294,10 +1294,13 @@ def import_dxf(
self.logger.error("Method is supported only in graphical mode.")
return False
dxf_layers = get_dxf_layers(input_file)
for layer in layers:
if layer not in dxf_layers:
self.logger.error(f"{layer} does not exist in specified dxf.")
return False
if not layers:
layers = dxf_layers
else:
for layer in layers:
if layer not in dxf_layers:
self.logger.error(f"{layer} does not exist in specified DXF file.")
return False

if hasattr(self, "is3d") and self.is3d:
sheet_bodies_2d = False
Expand Down
5 changes: 5 additions & 0 deletions src/ansys/aedt/core/generic/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,11 @@ def find_indices(list_to_check, item_to_find):
for idx in indices:
if "2" in lines[idx + index_offset]:
layer_names.append(lines[idx + index_offset + 1].replace("\n", ""))
if not layer_names:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, add some tests to cover the new lines you implemented

index_offset = 1
for idx in indices:
if "2" in lines[idx + index_offset]:
layer_names.append(lines[idx + index_offset + 1].replace("\n", ""))
Comment on lines +825 to +828
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain the logic behind this code ?

return layer_names


Expand Down
2 changes: 1 addition & 1 deletion src/ansys/aedt/core/hfss3dlayout.py
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ def _import_cad(
aedb_path = aedb_path.replace(old_name, project_name)
self.logger.warning("aedb_exists. Renaming it to %s", project_name)
if xml_path is None:
xml_path = Path("").name
xml_path = str(Path(cad_path).with_suffix(".xml"))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you casting into str when the previous code was using Path ? That's also the case for the elif a line below

elif Path(xml_path).suffix == ".tech":
xml_path = Path(tech_to_control_file(xml_path)).name
if cad_format == "gds":
Expand Down
Loading