Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DXF Importer (legacy) groups layers differently depending on open or import command #13621

Closed
2 tasks done
furgo16 opened this issue Apr 24, 2024 · 0 comments · Fixed by #13689
Closed
2 tasks done

DXF Importer (legacy) groups layers differently depending on open or import command #13621

furgo16 opened this issue Apr 24, 2024 · 0 comments · Fixed by #13689
Labels
File format: DXF WB Draft Related to the Draft Workbench

Comments

@furgo16
Copy link
Contributor

furgo16 commented Apr 24, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Problem description

Refer to screenshot below. The expanded treeviews show the result of importing a DXF twice, using either File > Open or File > Import:

Captura de pantalla de 2024-04-24 13-35-20

  1. If I import a DXF file with File > Open, the layers are imported and grouped correctly under the Layers parent
  2. If I import a DXF file with File > Import, the layers are put inside a group, and the Layers parent layer does not contain any layer

Full version info

OS: Ubuntu Core 22 (ubuntu:GNOME/ubuntu)
Word size of FreeCAD: 64-bit
Version: 0.22.0dev.36961 (Git) Snap 996
Build type: Release
Branch: main
Hash: c4c453312d148fd67bd893366c42b559e28a85e6
Python 3.10.12, Qt 5.15.10, Coin 4.0.0, Vtk 7.1.1, OCC 7.7.1
Installed mods: 
  * OpenTheme 2024.4.20
  * BIM 2021.12.0
  * Curves 0.6.35
  * ezydxf
  * ExplodedAssembly
  * BillOfMaterials 0.0.8.2
  * Ondsel-Lens 2024.4.16.01
  * Assembly4 0.50.12

Subproject(s) affected?

File formats

Anything else?

Importer settings that I used:

Captura de pantalla de 2024-04-24 13-36-19

Files to reproduce:

  1. arch_radius_bug.zip
  2. arch_radius_bug_open_legacy.zip
  3. arch_radius_bug_import_legacy.zip

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Roy-043 Roy-043 added WB Draft Related to the Draft Workbench File format: DXF labels Apr 25, 2024
Roy-043 added a commit to Roy-043/FreeCAD that referenced this issue Apr 27, 2024
Fixes FreeCAD#13621.

Currently the legacy DXF importer creates a main group with the DXF name if a DXF is imported into an existing FreeCAD document. For each DXF layer it then creates a sub-group (or Draft Layer) inside that main group. Objects are nested in the sub-groups (or Draft Layers).

This does not make sense for Draft Layers as they should be nested in the LayerContainer, which should be in the root of the FreeCAD document.

Both for Draft Layers and sub-groups there is the issue that if mutliple DXF files are imported in the same FreeCAD document, exising Draft Layers and sub-groups are not taken into account. For each DXF a new "0" group/layer is created (with a Label that is not "0" and therefore not recognized), and if there are objects on that layer a new group/layer is created for each object (labelled "0001", "0002", "0003", etc).

To solve this the main group with the DXF name is no longer created in the revised code and the layers variable is initialized with the groups/layers that already exist in the FreeCAD document.

Additionally the formatObject function should not format objects that are in Draft Layers. Its action conflicts with the layer mechanism resulting in the last imported object having an incorrect color.
yorikvanhavre pushed a commit that referenced this issue Apr 29, 2024
Fixes #13621.

Currently the legacy DXF importer creates a main group with the DXF name if a DXF is imported into an existing FreeCAD document. For each DXF layer it then creates a sub-group (or Draft Layer) inside that main group. Objects are nested in the sub-groups (or Draft Layers).

This does not make sense for Draft Layers as they should be nested in the LayerContainer, which should be in the root of the FreeCAD document.

Both for Draft Layers and sub-groups there is the issue that if mutliple DXF files are imported in the same FreeCAD document, exising Draft Layers and sub-groups are not taken into account. For each DXF a new "0" group/layer is created (with a Label that is not "0" and therefore not recognized), and if there are objects on that layer a new group/layer is created for each object (labelled "0001", "0002", "0003", etc).

To solve this the main group with the DXF name is no longer created in the revised code and the layers variable is initialized with the groups/layers that already exist in the FreeCAD document.

Additionally the formatObject function should not format objects that are in Draft Layers. Its action conflicts with the layer mechanism resulting in the last imported object having an incorrect color.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
File format: DXF WB Draft Related to the Draft Workbench
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants