[Solved] ImportDXF fails in build 0.19.16474 appears to be regression in Draft.py

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
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

[Solved] ImportDXF fails in build 0.19.16474 appears to be regression in Draft.py

Post by Syres »

I believe @Yorik has requested any reports that are/maybe related to removal of FreeCAD.ActiveDocument.recompute() statements from src\Mod\Draft\Draft.py.

After downloading build 0.19.16474 one of the first things I tried was importing a DXF file that has worked before with numerous builds as recently as 0.19.16267 and it fails with the following in Report View:

Code: Select all

opening E:/Data/FreeCAD/DXFs/sink.dxf...
drawing 23 lines...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "E:\Data\My Downloads\FreeCAD_0.19.16474_Conda_Py3QT5-WinVS2015_x64\FreeCAD_0.19.16474_Conda_Py3QT5-WinVS2015_x64\Mod\Draft\importDXF.py", line 1630, in insert
    processdxf(doc,filename)
  File "E:\Data\My Downloads\FreeCAD_0.19.16474_Conda_Py3QT5-WinVS2015_x64\FreeCAD_0.19.16474_Conda_Py3QT5-WinVS2015_x64\Mod\Draft\importDXF.py", line 1122, in processdxf
    shape = Draft.makeSketch(shape,autoconstraints=True)
  File "E:\Data\My Downloads\FreeCAD_0.19.16474_Conda_Py3QT5-WinVS2015_x64\FreeCAD_0.19.16474_Conda_Py3QT5-WinVS2015_x64\Mod\Draft\Draft.py", line 2332, in makeSketch
    e = obj.Shape.Edges[0]
<class 'IndexError'>: list index out of range
On replacing all of the FreeCAD.ActiveDocument.recompute() statements in the Draft.py file it now works but that obviously doesn't narrow down exactly which of the 28 are needed.


OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.16474 (Git)
Build type: Release
Branch: master
Hash: 746997e48411f22a150b95b6fdbb9b02cbe741d5
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)
Last edited by Syres on Fri Apr 26, 2019 5:27 pm, edited 1 time in total.
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: ImportDXF fails in build 0.19.16474 appears to be regression in Draft.py

Post by yorik »

Strange.. Even if not recomputed, the shape of the object should already contain the correct data... I believe the problem here might be something else (an empty shape probably).. Anyway, in git commit 2ea552a7b I added a fix for that. If it still fails, can you attach the dxf file?
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: ImportDXF fails in build 0.19.16474 appears to be regression in Draft.py

Post by Syres »

yorik wrote: Mon Apr 22, 2019 1:41 pm Strange.. Even if not recomputed, the shape of the object should already contain the correct data... I believe the problem here might be something else (an empty shape probably).. Anyway, in git commit 2ea552a7b I added a fix for that. If it still fails, can you attach the dxf file?
Thanks for having a look into this Yorik, it's a lot better using 0.19.16523 but not error free and I think it's around circles and/or arcs that there are problems. The following output is for the two attached files, the TriumphLogoOuterProfile.dxf was completely successful but the hfs5_2040_50_view1_12.dxf errors and this works fine in 0.18.16110.

Code: Select all

opening E:/Data/FreeCAD/DXFs/TriumphLogoOuterProfile.dxf...
skipping texts...
skipping dimensions...
skipping points...
skipping leaders...
skipping hatches...
skipping *blocks...
drawing 1 blocks...
done processing
recompute done
successfully imported E:/Data/FreeCAD/DXFs/TriumphLogoOuterProfile.dxf
opening E:/Data/FreeCAD/DXFs/hfs5_2040_50_view1_12.dxf...
drawing 130 lines...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
-----error!!! rotation is still None...
drawing 24 arcs...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "E:\Data\My Downloads\FreeCAD_0.19.16523_x64_Conda_Py3QT5-WinVS2015\FreeCAD_0.19.16523_x64_Conda_Py3QT5-WinVS2015\Mod\Draft\importDXF.py", line 1630, in insert
    processdxf(doc,filename)
  File "E:\Data\My Downloads\FreeCAD_0.19.16523_x64_Conda_Py3QT5-WinVS2015\FreeCAD_0.19.16523_x64_Conda_Py3QT5-WinVS2015\Mod\Draft\importDXF.py", line 1194, in processdxf
    shape = Draft.makeSketch(shape,autoconstraints=True,addTo=sketch)
  File "E:\Data\My Downloads\FreeCAD_0.19.16523_x64_Conda_Py3QT5-WinVS2015\FreeCAD_0.19.16523_x64_Conda_Py3QT5-WinVS2015\Mod\Draft\Draft.py", line 2288, in makeSketch
    edge = obj.Shape.Edges[0]
<class 'IndexError'>: list index out of range
I attached my DXF Import/Export Preferences so you could test the exact same settings if required.

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.16523 (Git)
Build type: Release
Branch: master
Hash: 9b3ec233c8b21e0df66fada487cd10f471d60cac
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)
Attachments
DXFPrefs.jpg
DXFPrefs.jpg (83.54 KiB) Viewed 774 times
hfs5_2040_50_view1_12.dxf
(55.59 KiB) Downloaded 28 times
TriumphLogoOuterProfile.dxf
(10.11 KiB) Downloaded 20 times
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: ImportDXF fails in build 0.19.16474 appears to be regression in Draft.py

Post by yorik »

Ok I think I got it this time.. git commit 61f94d4b7 hfs5_2040_50_view1_12.dxf works correctly too
BC-carpenter
Posts: 10
Joined: Mon Feb 12, 2018 11:55 pm

Re: ImportDXF fails in build 0.19.16474 appears to be regression in Draft.py

Post by BC-carpenter »

Syres wrote: Wed Apr 24, 2019 8:36 am it's a lot better using 0.19.16523 but not error free and I think it's around circles and/or arcs that there are problems.
I attached my DXF Import/Export Preferences so you could test the exact same settings if required.
I don't know if my experience is relevant to your problem, but I noticed that you are using the legacy Python DXF importer, and claim to be experiencing problems with circles and arcs.
There are times when I prefer the legacy importer, but it has been my experience that it fails to scale radii correctly on import. This can be fixed manually by locating all the imported circles and arcs and fixing the radii one at a time.
Perhaps this is not the best importer to use for your tests.
Syres
Veteran
Posts: 2893
Joined: Thu Aug 09, 2018 11:14 am

Re: ImportDXF fails in build 0.19.16474 appears to be regression in Draft.py

Post by Syres »

yorik wrote: Thu Apr 25, 2019 9:19 pm Ok I think I got it this time.. git commit 61f94d4b7 hfs5_2040_50_view1_12.dxf works correctly too
Thanks again Yorik, I've manually changed the importDXF.py and Draft.py files on my system and tested a few other large DXF files and they import successfully.
Post Reply