[BUG?] Problem with the default C++ DXF import function

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
aapo
Posts: 626
Joined: Mon Oct 29, 2018 6:41 pm

[BUG?] Problem with the default C++ DXF import function

Post by aapo »

Hi!

I made the attached DXF file with FreeCAD, using the Draft-WB method suggested in the Wiki (Face -> Shape2DView -> DXF). Everything seems to be actually fine with the export, but the FreeCAD default import reads the file incorrectly, with the circular arcs interpreted as full circles. I tried the file with Python FreeCAD legacy DXF importer, LibreCAD, and IrfanView, which all read the file correctly, which leads me to conclude that the problem lies with the FreeCAD default DXF import.


FreeCAD C++ DXF import (the default one):
20200824_FreeCAD_DXF-import_bug_pic01.png
20200824_FreeCAD_DXF-import_bug_pic01.png (18.23 KiB) Viewed 642 times

FreeCAD Python DXF legacy import:
20200824_FreeCAD_DXF-import_bug_pic02.png
20200824_FreeCAD_DXF-import_bug_pic02.png (9.54 KiB) Viewed 642 times

LibreCAD:
20200824_FreeCAD_DXF-import_bug_pic03.png
20200824_FreeCAD_DXF-import_bug_pic03.png (2.49 KiB) Viewed 642 times

IrfanView:
20200824_FreeCAD_DXF-import_bug_pic04.png
20200824_FreeCAD_DXF-import_bug_pic04.png (1.29 KiB) Viewed 642 times

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22284 (Git)
Build type: Release
Branch: master
Hash: bf1e8e48389f5e9e25bd77b67fe98da4213e797c
Python version: 3.8.5
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United Kingdom (en_GB)
Attachments
Lifting_hook_plate_05.dxf
(10.42 KiB) Downloaded 16 times
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: [BUG?] Problem with the default C++ DXF import function

Post by GeneFC »

Works correctly for me in both the Conda version and the Libpack version.

Capture.PNG
Capture.PNG (5.38 KiB) Viewed 623 times

OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22284 (Git)
Build type: Release
Branch: master
Hash: bf1e8e48389f5e9e25bd77b67fe98da4213e797c
Python version: 3.8.5
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: English/United States (en_US)


OS: Windows 7 SP 1 (6.1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.22284 (Git)
Build type: Release
Branch: master
Hash: bf1e8e48389f5e9e25bd77b67fe98da4213e797c
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/United States (en_US)

[Edit] I never import DXF files, so I used whatever happens when I select "Import" from the file menu.

Gene
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: [BUG?] Problem with the default C++ DXF import function

Post by vocx »

aapo wrote: Mon Aug 24, 2020 2:13 pm ...
FreeCAD C++ DXF import (the default one):
I can confirm that with the C++ importer, it doesn't work well.

I also get this message.

Code: Select all

<Part> ViewProviderExt.cpp(1332): Cannot compute Inventor representation for the shape of Lifting_hook_plate_05#Ellipse
If I recall correctly the C++ importer is faster for big DXFs, but it isn't as complete as the Python importer, so use the latter if there are problems with the former.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
aapo
Posts: 626
Joined: Mon Oct 29, 2018 6:41 pm

Re: [BUG?] Problem with the default C++ DXF import function

Post by aapo »

GeneFC wrote: Mon Aug 24, 2020 2:56 pm Works correctly for me in both the Conda version and the Libpack version.
Thanks for testing! :) Interesting, we seem to have exactly the same FreeCAD version, even the version hash code is the same; but still different end result. The other weird thing is that I made a few very similar DFX parts, and I only have the import problem with this particular number 05 part. Every other part imports fine, oddly enough. Maybe it's something in my DXF preferences? Here's a screenshot of my preferences window.

20200824_FreeCAD_DXF-import_bug_pic05.png
20200824_FreeCAD_DXF-import_bug_pic05.png (68.79 KiB) Viewed 610 times
aapo
Posts: 626
Joined: Mon Oct 29, 2018 6:41 pm

Re: [BUG?] Problem with the default C++ DXF import function

Post by aapo »

vocx wrote: Mon Aug 24, 2020 3:25 pm I can confirm that with the C++ importer, it doesn't work well.

I also get this message.

Code: Select all

<Part> ViewProviderExt.cpp(1332): Cannot compute Inventor representation for the shape of Lifting_hook_plate_05#Ellipse
Thank for testing this, too! Interesting, I don't get anything in the report view window. I wonder where the "Ellipse" in your error message comes from, there should only be circular arcs in the file. If I've understood correctly, one should always avoid ellipses with FreeCAD DXF, because they are not fully supported.

Aaannd... Looking inside the offending 05 DXF file with a text editor there sure are "ELLIPSE" commands there for some reason. The other files that have only circles and circular arcs import completely fine. It seems that the 05 file contains elliptic arcs that are shaped like circle segments, circles are special cases of ellipses I guess. I wonder why the FreeCAD DXF export on this particular file triggered ellipses, when the other files were fine. We may never find out, but this explains why the file imports fine with programs fully supporting DXF ellipses! :D
chrisb
Veteran
Posts: 54277
Joined: Tue Mar 17, 2015 9:14 am

Re: [BUG?] Problem with the default C++ DXF import function

Post by chrisb »

Moved to help forum.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
Roy_043
Veteran
Posts: 8576
Joined: Thu Dec 27, 2018 12:28 pm

Re: [BUG?] Problem with the default C++ DXF import function

Post by Roy_043 »

aapo wrote: Mon Aug 24, 2020 3:42 pm We may never find out,
You have checked the 'Project exported objects along current view direction' export option. This may cause arcs/circles to become elliptical.
GeneFC
Veteran
Posts: 5373
Joined: Sat Mar 19, 2016 3:36 pm
Location: Punta Gorda, FL

Re: [BUG?] Problem with the default C++ DXF import function

Post by GeneFC »

aapo wrote: Mon Aug 24, 2020 3:30 pm Interesting, we seem to have exactly the same FreeCAD version, even the version hash code is the same; but still different end result.
I went back and looked at the Preferences. My configuration has the "Use Python" checked. (Must be default, because I am sure I never changed it.) When I unchecked that box the import looked just like your original image.

It looks like the C++ / Python difference is the cause.

Gene
aapo
Posts: 626
Joined: Mon Oct 29, 2018 6:41 pm

Re: [BUG?] Problem with the default C++ DXF import function

Post by aapo »

Roy_043 wrote: Mon Aug 24, 2020 5:39 pm
aapo wrote: Mon Aug 24, 2020 3:42 pm We may never find out,
You have checked the 'Project exported objects along current view direction' export option. This may cause arcs/circles to become elliptical.
No, it's not only the configuration option. I naturally already tested with and without this configuration option, and there's no difference between the output files; provided that the view direction is perfectly perpendicular to the face (I used the default views by number "1", "2", "3", etc. shortcuts, as always.

However, I did find out how to trigger the export bug: If you make the Draft->Shape2DView projection step the body face upside-down (I originally made the part 05 Shape2DView so that the navigation cube had the word "BOTTOM" upside down), then the resulting Shape2DView object always produces ellipses when exported. It seems that the accuracy of the navigation on Shape2DView step was not good enough, and the arcs were not perfect circles. I don't understand how this happens, though, because I imagined that the navicube perpendicular directions would be perfectly perpendicular, but apparently not. :shock:

I attached my test file, where there is an example of a failed Shape2Dview.
Attachments
20200824_FreeCAD_DXF_export_import_bug.FCStd
(19.7 KiB) Downloaded 11 times
Post Reply