Units once more, DXF import trouble

Hello,
not sure I’m in the correct forum…
Anyway, I’ve read a lot of the problems concerning kicad’s unit problems.
So I just want to clarify for 100% I’ve understood it correctly.

-Kicad has ONLY mm (millimeters) as REAL units “under” the hood ?
-If I import a DXF that has for ex. 10.000 as unit inside the file, it will ALWAYS be 10.000 mm ?
-If I import a DXF with the unit inch (10.000"), this will really become 10.000/2.54=3.94", after I change the pref’s to imperial ?
-If kicad really works like this, is there any way of rescalling the imported part etc. to correct measure ?

Can you pro’s pls. confirm these to me, I’m out of ideas after 3 days of searching and testing…

br. Mike

I cannot confirm this is the way Kicad does it, but the DXF header can contain the unit type allowing for universal import so long as its been written in your file, and kicad knows to use it,

https://www.autodesk.com/techpubs/autocad/acad2000/dxf/header_section_group_codes_dxf_02.htm

Edit: The internal measurement units of kicads are nanometers

1 Like

Hi,
and thanks for you reply.
-This sounds interesting, and I tested it out, but no luck.
Tested the following DXF-variables:
$INSUNITS
1 => inch
$LUNITS
1 => inch
$DIMSCALE
0.0000001 or 100000000
$MEASUREMENT
0 = English
-No difference at all.
-Or do I need another one ?

Ok, so all units are in kicad mill’s, that’s why my imports are soooooo small…

Anyway, this DXF-importer is quite useless as it is, because you can’t give units nor scale factors for it. Also I tested the same for both eagle and pads, and it works out of the box without any custom variables etc.

And this feature is quite highly needed, if you make custom pcb’s, that need to be inserted into something created with some sort of cad-sw. Typically the universal way of transporting high-precision models from one cad to another is DXF.

Look’s sadly like a dead end for this feature ?

br. Mike

I think there are quite a variety of DXF format revisions and I am not sure that they are all supported in KiCad. I have had success with saving my DXF as a R12 format and importing that.Untitled 1.dxf (8.4 KB)
No resizing problems for this 10mm square / circle test image. (recent Kicad nightly tagged rc02)

45
(I am using ViaCad here)

15

2 Likes

Nothing in kicad is really a dead end feature. If we knew the format definitions for your export it would probably not be too hard to add if submitted as a feature request.

For dxf use libre cad. It does use the same geometrical kernal as kicad.

What CAD is the source for the DXF file?
Do you have some samples for us that we can look at?

I never had any trouble with DXF exports from Autodesk Inventor, via sheetmetal and then using the AutoCAD 2004 DXF version for export:

image

Dimensions in KiCAD were spot on with this.

1 Like

I use DraftSight for my board outline drawing and have No issues when I import them into KiCad. I do the drawing in Imperial and scale to Metric before saving the file in DXF format. I use AutoCAD ASCII 2007 - 2009 DXF format when I save the file (I never tried any other versions).

I also plot the final board as a DXF and import it into DraftSight to make Assembly and Fab drawings. I have to scale the imported file from Metric to get beck to Imperial. I do this regularly and have no problems.

What CAD pathway are you using ?
From above posts, it looks like DXF is not totally broken, and does work fine in many cases, I see it can support (under user defined position) user request of Inch or mm units (but not mils?)
It has also had a few fixes applies over time, so it certainly is active.

That said, I would think that adding an option in DXF import to force units/user scale is quite common, and well worth the saved time.
Many (web) DXF files users have no control over the exported finer points,

If I was coding a DXF import, expecting to do general any-source DXF handling, I would add mils to that user inch/mm list, and also add a user scale, if the defaults all fail to scale ‘as expected’.

I would also add simple report of imported File Extents and Vertex Count, as I have DXF files here, that give no errors, and no messages, and appear invisible. So I have no idea if anything at all imported, or if something is way-off-screen, or shrunk to one pixel, or zoomed across the room ?

I used to use A9CAD, which was an old, but simple/stable CAD pgm, that has proven useful for load/save of DXF and often that simple load/save-as step would clean-up headers etc enough to then import.
It seems links to A9CAD are no longer active ?

I tested this with freecad, and after some more tests…
When I checked deeper, I found a lot of discussions around freecad unit problems.
It looks like the part is 1x1 inch according to freecad, but in kicad it’s much smaller ?
->So I really beleive the problem is in freecad ?

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.