← Back to team overview

kicad-developers team mailing list archive

[PATCH] fixing module position file millimeters

 

Hi all,

my PCB assembler requested a Pick&Place file in millimeters so, as Dick suggested me here some time ago, I modified pcbnew/gen_modules_placefile.cpp and changed the #if 1 into #if 0 so that the unit conversion would be hardcoded to be in millimeters.

However, I discovered that there was a 0 more in the scale factor for the millimeters. The attacched patch fixes this and also the comments on the generated file to have "Unit = mm" instead of Inches. Seems to be working good here.

I'd like to further modify this so that the generated file uses the unit set in PCBnew on the GUI. I tried digging a bit in the code but I still not found how to get the unit used in PCBnew from gen_modules_placefile.cpp ... Any suggestion? I'm willing to patch back the code if you guys find this interesting.

Thanks,

Fabio
=== modified file 'pcbnew/gen_modules_placefile.cpp'
--- pcbnew/gen_modules_placefile.cpp	2012-01-23 04:33:36 +0000
+++ pcbnew/gen_modules_placefile.cpp	2012-02-11 13:20:46 +0000
@@ -35,8 +35,10 @@
 
 #if 1
 static const double conv_unit = 0.0001;      // units = INCHES
+static const char * unit_text = "## Unit = inches, Angle = deg.\n";
 #else
-static const double conv_unit = 0.000254;    // units = mm
+static const double conv_unit = 0.00254;    // units = mm
+static const char * unit_text = "## Unit = mm, Angle = deg.\n";
 #endif
 
 static wxPoint File_Place_Offset;  /* Offset coordinates for generated file. */
@@ -225,7 +227,7 @@
     if( doBoardBack )
         fputs( line, fpBack );
 
-    sprintf( line, "## Unit = inches, Angle = deg.\n" );
+    sprintf( line, unit_text );
     fputs( line, fpFront );
 
     if( doBoardBack )
@@ -360,7 +362,7 @@
     wxString Title = wxGetApp().GetAppName() + wxT( " " ) + GetBuildVersion();
     sprintf( line, "## Created by Pcbnew version %s\n", TO_UTF8( Title ) );
     fputs( line, rptfile );
-    fputs( "## Unit = inches, Angle = deg.\n", rptfile );
+    fputs( unit_text, rptfile );
 
     fputs( "##\n", rptfile );
     fputs( "\n$BeginDESCRIPTION\n", rptfile );


Follow ups