dxf splines with ezdxf (python)

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!
amka
Posts: 63
Joined: Thu Sep 03, 2015 6:28 pm

dxf splines with ezdxf (python)

Post by amka »

Hi,

I need to open some dxf files with freecad, what usually works except one of them which is done with 'ezdxf' python module and contains a spline.
Can please somebody help me ? (It would be fine to do with freecad but, if it is necessary, I can do it too with an other software, but which ?)

Thanks and best regards,

amka

OS: Debian GNU/Linux 8.6 (jessie)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.
Build type: None
Python version: 2.7.9
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17

my python script :

import ezdxf

dwg = ezdxf.new('AC1015') # splines requires the DXF R2000 format or later

fit_points = [(0, 0, 0), (750, 500, 0), (1750, 500, 0), (2250, 1250, 0)]
msp = dwg.modelspace()
msp.add_spline(fit_points)

dwg.saveas("ezdxf_spline.dxf")
Attachments
ezdxf_spline.dxf
(16.13 KiB) Downloaded 116 times
User avatar
Willem
Veteran
Posts: 1852
Joined: Fri Aug 12, 2016 3:27 pm
Location: Lisse, The Netherlands

Re: dxf splines with ezdxf (python)

Post by Willem »

Hi,

Freecad works with DXF version R12. Your DXF file is probably made with a newer version. What I did is open the DXF file in Librecad ( a good free 2d CAD program ) and saved it as an R12 file. Now the new file is imported in Freecad without problems
Attachments
ezdxf_spline_Willem.dxf
(17.16 KiB) Downloaded 93 times
amka
Posts: 63
Joined: Thu Sep 03, 2015 6:28 pm

Re: dxf splines with ezdxf (python)

Post by amka »

My script does a R2000 version which is newer than R12, that's true. Thanks for the information, but...

How did you please do your file ? Impossible for me to open my own dxf with libreCAD, what I already tried.
Attachments
mylibrecadversion.png
mylibrecadversion.png (57.87 KiB) Viewed 3135 times
User avatar
Willem
Veteran
Posts: 1852
Joined: Fri Aug 12, 2016 3:27 pm
Location: Lisse, The Netherlands

Re: dxf splines with ezdxf (python)

Post by Willem »

I have a newer Librecad

Version: 2.2.0-alpha
Compiler: GNU GCC 5.4.0
Compiled on: Dec 30 2016
Qt Version: 5.5.1
Boost Version: 1.58.0
System: Ubuntu 16.04.1 LTS
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: dxf splines with ezdxf (python)

Post by yorik »

FreeCAD SAVES as R12, but opens normally any DXF file of any version (the format is incremental, so even newest versions should work). The new C++ importer still doesn't support splines, though, so you'll need to use the legacy importer (set that in the DXF preferences).
User avatar
Willem
Veteran
Posts: 1852
Joined: Fri Aug 12, 2016 3:27 pm
Location: Lisse, The Netherlands

Re: dxf splines with ezdxf (python)

Post by Willem »

Hi
@ Yorik, I checked in both version 0.16 and 0.17
The original ezdxf_spline.dxf file imported in Freecad creates in the Combo view a name, but no elements. It is empty
The in Librecad opened and saved as R12 ezdxf_spline_Willem.dxf file creates name and elements.
I work with the legacy DXF-importer. I also tried to modify the file with TeighaConverter and that also failes
DXF-importer.png
DXF-importer.png (246.84 KiB) Viewed 3096 times
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: dxf splines with ezdxf (python)

Post by yorik »

Ok there was a bug in the dxf importer, this is fixed with git commit 5d2e834bc3
User avatar
Willem
Veteran
Posts: 1852
Joined: Fri Aug 12, 2016 3:27 pm
Location: Lisse, The Netherlands

Re: dxf splines with ezdxf (python)

Post by Willem »

Yorik, thank for fixing the bug before it is posted as a bug :D . I am now busy redecorating my kitchen but I will try this fix asap
amka
Posts: 63
Joined: Thu Sep 03, 2015 6:28 pm

Re: dxf splines with ezdxf (python)

Post by amka »

Hi,

Thanks for replies and... I see 'src' on the path for the fix... Have I then please to compile FreeCad if I want to open my dxf ?

amka :(
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: dxf splines with ezdxf (python)

Post by yorik »

Yes, or, wait for someone to compile for you :)
Post Reply