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 (C++) wrongly scales polyline bulges #13600

Closed
2 tasks done
furgo16 opened this issue Apr 23, 2024 · 2 comments · Fixed by #13678
Closed
2 tasks done

DXF Importer (C++) wrongly scales polyline bulges #13600

furgo16 opened this issue Apr 23, 2024 · 2 comments · Fixed by #13678
Labels
Bug This issue or PR is related to a bug Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD File format: DXF

Comments

@furgo16
Copy link
Contributor

furgo16 commented Apr 23, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Problem description

I'm importing a DXF file that I would like to scale from mm to m. To keep things simple, I've deleted everything from it except from the problematic area => arch_radius_bug.zip

If I try to import the file with these settings, it imports well:

image

image

FreeCAD document after import:
arch_radius_bug_1.zip

But as soon as I set the scale to 1000 in the import settings, the radiuses of the two arches are unproportionately scaled:

Zooming in:
image

Zooming out:
image

FreeCAD document after import:
arch_radius_bug_1000.zip

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
  * ExplodedAssembly
  * BillOfMaterials 0.0.8.2
  * Ondsel-Lens 2024.4.16.01
  * Assembly4 0.50.12

Subproject(s) affected?

File formats

Anything else?

As a workaround, I would simply use the Draft_Scale command, but when I do, I'm presented with this error that prevents the scaling operation:

Unable to scale objects: Polyline, Polyline001, Line, Line001 - This object type cannot be scaled directly. Please use the clone method.

If I check the Clone option as suggested, scaling works, but the whole drawing is then one entity that I cannot easily manipulate (e.g. hide the individual items in layers).

As mentioned, this sample file is just a small part of the original file, where other radiuses are also unproportionately scaled. Too many to correct them all manually.

I can also trigger this bug by changing the DXF's unit from mm to m and then I simply import the file without scaling (e.g. Scale = 1 in the import settings).

Code of Conduct

  • I agree to follow this project's Code of Conduct
@furgo16 furgo16 changed the title DXF exporter wrongly scales arch radiuses DXF importer wrongly scales arch radiuses Apr 23, 2024
@maxwxyz maxwxyz added Bug This issue or PR is related to a bug Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD File format: DXF labels Apr 23, 2024
@Roy-043
Copy link
Contributor

Roy-043 commented Apr 23, 2024

The bulge of LWPoly segments is wrongly scaled. This should not happen as Bulge=1/4*tan(arc angle).

SetupScaledDoubleAttribute(eFloat3, currentVertex.bulge);

SetupScaledDoubleAttribute(eFloat3, currentVertex.bulge);

Try the legacy DXF importer

@furgo16 furgo16 changed the title DXF importer wrongly scales arch radiuses DXF Importer (C++) wrongly scales arch radiuses Apr 24, 2024
@furgo16
Copy link
Contributor Author

furgo16 commented Apr 24, 2024

This should not happen

Thank you. I understand the tan() part of the bulge value, but I'm not sure I follow the code. Do you mean that the value of the bulge is being (wrongly) multiplied by the scale factor?

Try the legacy DXF importer

I did, and it works for this case, but it comes with its own set of alternate bugs when I run it over the original, bigger file that contains this sample segment to reproduce the bug. I've been filing a few of them, but it might take me a while and I'm not sure if it's worth it for the legacy importer (e.g. is it going to be phased out at some point?).

For now, I've been using the ezdxf library with good results, via the ezydxf workbench.

@furgo16 furgo16 changed the title DXF Importer (C++) wrongly scales arch radiuses DXF Importer (C++) wrongly scales polyline bulges Apr 26, 2024
Roy-043 added a commit to Roy-043/FreeCAD that referenced this issue Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This issue or PR is related to a bug Core Issue or PR touches core sections (App, Gui, Base) of FreeCAD File format: DXF
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants