← Back to team overview

kicad-developers team mailing list archive

Re: gerbview to pcbnew export of arcs

 

Committed.

I have a Gerber file of a board outline with arcs that I need to export
to pcbnew. gerbview doesn't support arcs yet, so I gave implementing it
a try. The patch is below. Here's the example I used:

From
http://downloads.openmoko.org/developer/schematics/GTA02/gta02_outline_footprints_netlist.tar.bz2
the file
gta02_outline_footprints_netlist/gen020.pho

And this is the resulting board (shifted, rotated, and flipped):
http://svn.openmoko.org/trunk/gta02-core/gta02-core.brd

- Werner

---------------------------------- cut here -----------------------------------

Add support for exporting arcs in non-copper layers to gerbview.

Index: kicad/gerbview/export_to_pcbnew.cpp
===================================================================
--- kicad.orig/gerbview/export_to_pcbnew.cpp	2009-05-21 23:00:00.000000000 -0300
+++ kicad/gerbview/export_to_pcbnew.cpp	2009-05-22 01:42:40.000000000 -0300
@@ -165,6 +162,19 @@
drawitem->m_End = track->m_End;
drawitem->m_Width = track->m_Width;

+	if( track->m_Shape == S_ARC )
+	{
+	double cx = track->m_Param;
+	double cy = track->GetSubNet();
+	double a = atan2( track->m_Start.y-cy, track->m_Start.x-cx );
+	double b = atan2( track->m_End.y-cy, track->m_End.x-cx );
+
+	drawitem->m_Shape = S_ARC;
+	drawitem->m_Angle = fmod( (a-b)/M_PI*1800.0+3600.0, 3600.0 );
+	drawitem->m_Start.x = cx;
+	drawitem->m_Start.y = cy;
+	}
+
pcb->Add( drawitem );
}
else









Follow ups

References