Units once more, DXF import trouble

I use freecad, and found out the same problem is in there also…
So I beleive that freecad somehow messes up something on the way ?
-I have a factory created DXF (don’t know what made it)
-I open it in freecad, and it look ok
-Clean it up a bit and export to DXF
-import it to kicad

Sound super easy and straight forward, but not this time. The oddest thing is that why pads, eagle and altium can import it without any problems at all ?
If there where a scaling option in the import dialog, then I would have just scaled the image.

I will go on with my project using eagle, but I’ll get back to this asap as time gives.

It would be grat if there where a tutorial howto do DXF import/export from freecad and kicad,
I could put some effort into that.

I will test libre-cad for sure, very interesting. Now I’m using freecad, but not an expert. I’ve used acad and solidworks in previous works.

It may be the header is a variant KiCad does not understand.
Can you post the two DXF’s - original ex Web, and Free-cad saved ?

Agreed, hence my suggestion to add that to the DXF Import menu.

1 Like

I’ve just downloaded the latest LibreCAD (146MB installed), and loaded a box DXF from the web, that KiCad fails to load. (no errors, ‘loads-blank’)
LibreCAD has save-as choices of DXF-2007 back to DXF-R12

A9CAD(18MB installed) & KiCad both ‘load blank’ on original web, and both load OK, once LibreCad does a Load/Save as DXF-R12.

If you use freecad have a look at the kicad-stepup workbench.
It can export footprints directly. (You will get pads directly. No need to eyeball them from a dxf overlay)

4 Likes

Good point, but note there can be DXF files that load-blank into freecad.

The test case above needed a LibreCAD load/save as DXF-R12, to then load into KiCad/FreeCAD.

@PCB_Wiz, any chance you can post the link for that sample or attach it right away?

@aaltomikael, same for you, can you please attach a sample file for us?

Even if this doesn’t solve your problem right now, it might be some step-stone for a dev later down the road if he needs to troubleshoot things.

I’m sorry but I can’t publish the part I’m strugling with, because it’s my customers.
I’ll try to find a suitable variant behaving the same way.

1 Like

Only this way we can pinpoint the problem… but as I said I can’t publish it sadly.
I even tried to export from freecad and import back again and it works, very strange.
Also as I should have done in the first place was to import the untouched original dxf-part into kicad in the begining:
IT WORKS !

-So as a conclusion, the problem is in freecad, it inserts something od into the dxf. But still the strnge thing is that other progs like pads, eagle etc. will import it correctly !?
Still I will comper the two dxf:es and check the diffs.

And a GREAT thanks to everyone’s help !!!
I will post the resolution as get it done.

If you can atleast find out what is different (I suspect a header flag) it will be something the devs may be able to work with.

test.dxf (8.9 KB)

Here is one. It is exported from Onshape as a “release 11/12” file. It doesn’t seem to matter which release I choose. When importing to kicad, the result is 1/25.4 the correct size. The file is in inches. I don’t see anything obvious in the dxf giving the dimension or a scale factor.

header tag “$LUNITS” with value 2, on line 278

Its not clear, but it appears “2” is used as feet for the units in another program.

I suspect the lack of “$INSUNITS” tag is what is causing the issue, it seems to be an issue with a number of dxf imports / exports,

Try manually editing that LUNITS value, if it doesnt change, add a $INSUNITS tag value of 1 (Inches), I suspect without this tag kicad defaults to mm.

so

$INSUNITS
70
1
9

One of these should make clear the underlying issue.

Changing $LUNITS to 1 didn’t change the imported scale. Adding $INSUNITS gives the correct behavior.

I now see that SolidWorks exports dxf’s with the $INSUNITS variable, and those dxf’s work fine when imported into kicad without modification.

That solved it !
I added both:
$LUNITS
70
2
9
$INSUNITS
70
1
9
-Both where missing from the freecad export. And they need to be both in the file to work accordingly.
There must be some other vari’s other sw use to get the correct unit-base configured ?

1 Like

Is there any chance you could attach an effected freecad export. Even if you just grab the above posters file and re-export it.

Now that i know what is missing. We may aswell find a workaround for the devs,

2 Likes

My office uses AutoCad 2018 and FreeCad and LibreCad cannot open the DXF at all. It seems that every AutoCad release breaks the Opensource projects. Unfortunately DXF is not an open standard

1 Like

David, have an example file? If we are to make kicad work with all these sources, saying “Read this string and it will work” is going to be very quick for the devs to bake in,

To maui, Again, its not clear that they follow the same unit table, because feet would not make sense for an inch scaled file.

So digging more, the attached file is exported from Autocad R11/R12,
http://help.autodesk.com/view/ACD/2017/ENU/?guid=GUID-A85E8E67-27CD-4C59-BE61-4DC9FADBE74A

Equally it does appear autocad keeps its dxf format pretty open,

https://github.com/KiCad/kicad-source-mirror/blob/master/pcbnew/import_dxf/dxf2brd_items.cpp#L515