Nothing happens on import of DXF outline in Pcbnew

Continuing the discussion from Import DXF Board to PCB New:

I am trying to import a DXF file used to define the board edge cut in a new Pcbnew file.

I started with a .dxf file created by AutoCAD 2011 and saved as an ASCII R12/LT2 DXF file: no luck.

I then imported the above AutoCAD .dxf file into libreCAD, did the manipulation recommended in the KiCAD Pcbnew documentation: exploding the polyline and saving as DXF R12 format. Still no luck importing into Pcbnew.

I then tried something simpler: starting from scratch in libreCAD I created a simple 2 inches by 1 inch rectangle made of 4 lines. The bottom left of the rectangle is at position (0,0). I saved this again in DXF R12 format and tried to import into Pcbnew, still no luck.

I finally tried importing the NONAME_6_ASCII.dxf file mentioned in the above post in Pcbnew; still no result.

To import in Pcbnew I do the following:

  1. File --> New, to create a new board
  2. File --> Import --> DXF File, this opens the import DXF File dialog
  3. Select the .dxf file to import using Browse
  4. Select the origin: I tried all the choices, normally I do center of page
  5. Layer set to Edge.Cuts
  6. Press OK button

Then absolutely nothing happens; no error message, nothing on the display.

I have all the layers enabled on the left panel.
I tried with both the Default and OpenGL view.

I am using:
Pcbnew ver 4.0.1 - stable release build
wxWidget 3.0.2 Unicode and Boost 1.57.0
Platform: Windows 7 (build 7601, SP1), 64 bits

Help please

I just downloaded that DXF file and imported it into KiCAD BZR6097… this is where it lands (also nothing fancy in those import settings):

Page size of that red-frame at the ‘bottom right’ is A4 (210x279mm2) landscape… zoomed out max and moved the page frame to right bottom corner.

Can you attach that file please?

Just tested the same import in BZR6403 (which is newer than 4.0.1) and it looks the same (lands where it lands in BZR6097)… the DXF import menu has changed a bit and I selected Lower left corner of page instead of Right bottom corner.


Thanks for looking at my problem so rapidly.

My simple 2" x 1" rectangle file is here: simple.dxf (10.0 KB)

I tried once again with this simple DXF. I ensured that the page size was A4 and units=mm.

I imported using left lower corner and F.Fab layer (to replicate your settings).


As you can see, nothing is showing up. Zooming out to the max also doesn’t reveal anything.

So the file is OK and readable by KiCAD it seems.
Start a new project with an empty pcb, import for all possible locations, safe the file and open it (.kicad_pcb) with a text editor.
Search for this kind of stuff (for example all 4 locations that you can see in the pic above on Dwgs.User):

(gr_line (start 0 271.6022) (end 0 297.0022) (layer Dwgs.User) (width 0.1))
(gr_line (start 50.8 271.6022) (end 0 271.6022) (layer Dwgs.User) (width 0.1))
(gr_line (start 50.8 297.0022) (end 50.8 271.6022) (layer Dwgs.User) (width 0.1))
(gr_line (start 0 297.0022) (end 50.8 297.0022) (layer Dwgs.User) (width 0.1))

(gr_line (start 209.9945 123.1011) (end 209.9945 148.5011) (layer Dwgs.User) (width 0.1))
(gr_line (start 260.7945 123.1011) (end 209.9945 123.1011) (layer Dwgs.User) (width 0.1))
(gr_line (start 260.7945 148.5011) (end 260.7945 123.1011) (layer Dwgs.User) (width 0.1))
(gr_line (start 209.9945 148.5011) (end 260.7945 148.5011) (layer Dwgs.User) (width 0.1))

(gr_line (start 0 123.1011) (end 0 148.5011) (layer Dwgs.User) (width 0.1))
(gr_line (start 50.8 123.1011) (end 0 123.1011) (layer Dwgs.User) (width 0.1))
(gr_line (start 50.8 148.5011) (end 50.8 123.1011) (layer Dwgs.User) (width 0.1))
(gr_line (start 0 148.5011) (end 50.8 148.5011) (layer Dwgs.User) (width 0.1))

(gr_line (start 0 -25.4) (end 0 0) (layer Dwgs.User) (width 0.1))
(gr_line (start 50.8 -25.4) (end 0 -25.4) (layer Dwgs.User) (width 0.1))
(gr_line (start 50.8 0) (end 50.8 -25.4) (layer Dwgs.User) (width 0.1))
(gr_line (start 0 0) (end 50.8 0) (layer Dwgs.User) (width 0.1))

Test DXF.kicad_pcb (2.2 KB)

Output file obtained after importing according to the instructions.

Hum, the text from the previous reply got lost.


I followed your instructions, created a new project and imported the simple.dxf file in four positions supported by v. 4.0.1.

I then saved and closed the Pcbnew editor. I checked the .pcb file using a text editor: no gr_line in the output file.

I noticed from the screen dumps that you have a different version; not 4.0.1. Could this functionality be broken in the latest stable load?

I could try installing a nightly build.

Is there a way to enable debug logs?

Thanks for your help.

BZR6403 is importing that too (kicad-product-r6403.415c722-x86_64.exe), but that’s not online anymore afaik… just take the next one that is there 6408 and if that doesn’t work you can try up to the latest?

If there are no gr_line entries in the kicad_pcb after importing and saving the layout something is really wrong. I have no answer for that.

I totally removed 4.0.1 and replaced it with the r6408.ab585f4-x86_64 build.

I am still unable to import the DXF file.

Since this is open source, I had a quick browse through the code that controls the DXF import.

It was cute to go back to good old C++ code. :smile:

Not just old because it is C++, but in the programming style being used: no use of exceptions and very limited error handling! :frowning:

Here is a part of the DXF2BRD_CONVERTER class that reads in the DXF file and adds it to the pcb file:

bool DXF2BRD_CONVERTER::ImportDxfFile( const wxString& aFile )
dxfRW* dxf = new dxfRW( aFile.ToUTF8() );
bool success = dxf->read( this, true );

delete dxf;

return success;


The read() method will invoke needed methods to do conversions, like the following for the lines forming the shape rectangle:

void DXF2BRD_CONVERTER::addLine( const DRW_Line& aData )

segm->SetLayer( ToLAYER_ID( m_brdLayer ) );
wxPoint start( mapX( aData.basePoint.x ), mapY( aData.basePoint.y ) );
segm->SetStart( start );
wxPoint end( mapX( aData.secPoint.x ), mapY( aData.secPoint.y ) );
segm->SetEnd( end );
segm->SetWidth( mapDim( aData.thickness == 0 ? m_defaultThickness : aData.thickness ) );
m_newItemsList.push_back( segm );


The method doesn’t check for success as it is proceeding and doesn’t return any success/failure result at completion.

So, this explains why there are no error messages when my DXF file fails to import.

But, it doesn’t explain why it fails to import. I am now suspecting that there is something peculiar with my computer configuration.

I will do more probing…

OK found the cause of the problem :smile:

It was the file path of the DXF file that was too long for import code to handle.

The DXF file that couldn`t be imported was in a folder called: “D:\Biliothèque de Jean\Documents\KiCad\Projets\Panneau monomoteur FSX\Plaque avant”

But, if I move it to D:\temp, then it imports just fine.

Problem solved!

Thanks for your ideas Joan.

1 Like

Jean tu es un champion !!
Tu m’as sauvé : je bloquais sur ce point depuis quelques jours et là j’ai découvert ton post

Bravo à toi !!!

Jean you are a champion !!
You saved me: I blocked on this point for a few days and there I discovered your post

Well done !!!

Ah, it’s good you found the path problem. :slight_smile: It’s also good that the DXF importer is working for that case. There were quite a few bugs fixed in the DXF import since 4.01. In fact even the latest 4.x has bugs which have been fixed in the development branch but people are hoping for a 5.0 release rather than yet another 4.x so I doubt the bugs will ever be fixed in 4.x. I’m curious why the path was too long though; maybe there’s still yet another bug in the code.

1 Like

the path also contained space characters looking at this in retrospect :wink:

I noticed that too, but that’s generally not a problem in kicad unless we missed a few places where it matters. Have you tried using a non-ascii path with spaces to see if it’s a problem?