diff --git a/doc/changelog.d/7298.fixed.md b/doc/changelog.d/7298.fixed.md new file mode 100644 index 00000000000..e1673fde01b --- /dev/null +++ b/doc/changelog.d/7298.fixed.md @@ -0,0 +1 @@ +Dxf fixes on mcad & ecad diff --git a/src/ansys/aedt/core/application/analysis_3d.py b/src/ansys/aedt/core/application/analysis_3d.py index 97f0cb5ec3b..420f5644538 100644 --- a/src/ansys/aedt/core/application/analysis_3d.py +++ b/src/ansys/aedt/core/application/analysis_3d.py @@ -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, @@ -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 @@ -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 diff --git a/src/ansys/aedt/core/generic/file_utils.py b/src/ansys/aedt/core/generic/file_utils.py index 4e5cf6b69b2..2da6b1563e5 100644 --- a/src/ansys/aedt/core/generic/file_utils.py +++ b/src/ansys/aedt/core/generic/file_utils.py @@ -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: + index_offset = 1 + for idx in indices: + if "2" in lines[idx + index_offset]: + layer_names.append(lines[idx + index_offset + 1].replace("\n", "")) return layer_names diff --git a/src/ansys/aedt/core/hfss3dlayout.py b/src/ansys/aedt/core/hfss3dlayout.py index 1d5b266eab6..5f343dff304 100644 --- a/src/ansys/aedt/core/hfss3dlayout.py +++ b/src/ansys/aedt/core/hfss3dlayout.py @@ -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")) elif Path(xml_path).suffix == ".tech": xml_path = Path(tech_to_control_file(xml_path)).name if cad_format == "gds":