It is still pretty simple to use: Create some objects, create a page, the select the page and File->Export->DXF.
There are three important things to know:
1)Not all Drawing views are supported. At the moment, only Part views, Draft views made with the Draft->Drawing tool, Arch views made by using the Draft->Drawing button with an Arch section plane selected and Drawing Annotations. The others (Clipping views, and SVG-based custom views) are not (yet) supported.
2) The template is exported only if a DXF template with the same name as the SVG one is found in he same directory. Otherwise, the template is simply not considered. I created DXF templates for the two default FreeCAD A3 and A4 templates. Creating a DXF template from an existing SVG template is not difficult, I'll explain below.
3) The exported DXF code is of version DXFr12. This version doesn't support some entities that didn't exist at that time, such as Splines and Ellipses. Such edge types are exported anyway (yeah, hacky, I know). Some applications (LibreCAD) will gladly open these "unorthodox" files, others (draftsight) will open them but not import the "bad" objects, and some others (autocad) will simply not open the file. Later on I'll work further on that problem.
Here is a more complex example, with a custom template and my IFC test house:
The export operation leaves the template at 1:1 scale, and turns each view into a block, then scales, places and rotates that block according to what's in the drawing page. I thought it's the smartest solution. So the result is scaled the same way as in FreeCAD, but since they are blocks, it's a piece of cake to scale everything back to 1:1. For example, below I simply scaled everything up, made sure all blocks had (1,1,1) scale, exploded them, and made adjustments to dimension styles, that's 5 minutes work:
The DXF template system might seem redundant (yet another template?) but I found it the most efficient and reliable way. There is basically no good SVG->DXF conversion tool available, everything I found is complicated and very error-prone, this seemed to me the most controllable solution with the best output.
Creating a DXF template is easy if you already have an SVG template. I'll add better instructions on the wiki, but basically it involves:
- Open the template in Inkscape
- Export it as DXF, choosing "px" as the unit
- Open the exported DXF in a DXF app such as LibreCAD
- Adjust/add/fix everything you want, make sure the top left corner of the template is at (0,0) (so the coordinates match those of the Drawing page)
- If needed, change all texts to match the editable text names in the SVG template
- Save as DXF r12 in the same folder and with the same name as the corresponding SVG template
Then the little modification you need to do in a text editor:
- Add a "$blocks" line at the end of the blocks section (just before the ENDSEC)
- Add a "$entities" line at the end of the entities section (just before the ENDSEC)
This last modifications unfortunately turns the template unopenable, I still didn't find how to solve that.
Ah there is one important change for who was using the Drawing.projectToDXF(shape) function (but I think that will be very few people, if any). Before, that function returned a complete DXF file description, with a complete file header. This seemed not correct to me, though, so I changed this function to return only the DXF code corresponding to the shape, the same way as projectToSVG(). This way, you can join several shapes into one file.
So if you were using this function before, you must add a minimal DXF header: change all occurences of:
Code: Select all
dxfcode = Drawing.projectToDXF(myshape)
Code: Select all
dxfcode = "0\n0\nSECTION\n2\nENTITIES\n" + Drawing.projectToDXF(myshape) + "0\nENDSEC\n0\nEOF"
I think that's it for now, not perfect yet, but already much better, no?