Export DXF

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!
ddlm
Posts: 11
Joined: Mon Nov 23, 2009 11:06 pm

Re: Export DXF

Post by ddlm »

Hi

Installed the fcgeo.py file in the draftlibs folder and FreeCAD throws the following exception:

Code: Select all

Exception (Thu Dec 10 09:58:23 2009): PolyLine instance has no attribute 'polyface' 
Stack Trace: Traceback (most recent call last):
  File "<string>", line 4, in <module>
  File "C:\Program Files\FreeCAD0.8\Mod\Draft\importDXF.py", line 469, in export
    dxf.saveas(filename)
  File "C:\Program Files\FreeCAD0.8\Mod\Draft\draftlibs\dxfLibrary.py", line 655, in saveas
    self.save()
  File "C:\Program Files\FreeCAD0.8\Mod\Draft\draftlibs\dxfLibrary.py", line 659, in save
    test.write(str(self))
  File "C:\Program Files\FreeCAD0.8\Mod\Draft\draftlibs\dxfLibrary.py", line 648, in __str__
    entities=self._section('entities',[str(x) for x in self.entities])
  File "C:\Program Files\FreeCAD0.8\Mod\Draft\draftlibs\dxfLibrary.py", line 327, in __str__
    if self.polyface:
I have the FreeCAD 0.8 (from the installer)

By the way, don't worry about this piece, I already finish it... but would be nice to have a tool like freeCAD to make this calculation instead by hand

Also, I'm sure this will help to have a more complete FreeCAD...

Regards
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Export DXF

Post by yorik »

Hmm actually the 0.8 version is a bit old now... Many things changed since then, including that dxfLibrary.py that gives the error.
The windows installer for the 0.9 version is still not ready, but I suppose Jürgen will have it ready soon.

Otherwise, you can still try to replace the needed files manually, I'm not 100% sure it'll work but I think it should. You need to replace those 3 files:
http://free-cad.svn.sourceforge.net/vie ... portDXF.py in Mod/Draft
http://free-cad.svn.sourceforge.net/vie ... Library.py in Mod/Draft/draftlibs
http://free-cad.svn.sourceforge.net/vie ... s/fcvec.py in Mod/Draft/draftlibs
But make a backup copy of your existing files before replacing, in case something goes wrong.
ddlm
Posts: 11
Joined: Mon Nov 23, 2009 11:06 pm

Re: Export DXF

Post by ddlm »

It works! I can export to dxf!

Thank you very much for your help... maybe the b-splines to polylines should be the next task?

Regards
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Export DXF

Post by yorik »

ddlm wrote:maybe the b-splines to polylines should be the next task?
Yes, definitely! I need to study a little better how splines work, both in FreeCAD and dxf, but it's on my todo list.
Another thing that might be very interesting in the future, is that inkscape can now import and export dxf files (although rudimentary, our dxf support is at the moment better than theirs! but this will change of course) and inkscape can also perform command line-only operations such as open a svg file and save it as dxf... So, we might use that to output sheets from the drawing module to dxf... That could be very interesting too.
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Export DXF

Post by wmayer »

Hi,

a general solution could be to get the parameter range (u_min, u_max) of the curve and depending on the wanted accuracy use a certain number of parameter values of this range. Then for each u value simply calculate the point on the curve. From this set of points it's easy to get the polyline.

A special case is if the B-Spline curve has degree 1 because then it describes a line and there you can just use the both poles to create the line.

Werner
User avatar
yorik
Founder
Posts: 13664
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: Export DXF

Post by yorik »

Hmm very simple approach!
I was looking at the spline object in FreeCAD, it is very thoroughly implemented... You can indeed do all kinds of calculations! Other thing I was looking at, in a "splined" dxf polyline, the vertices of the polyline behave actually like control points of a spline... So maybe there is also a trick to make a quick & easy conversion... I'll see what works best.
Post Reply