delorie.com/archives/browse.cgi   search  
Mail Archives: geda-user/2013/05/31/18:14:38

X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f
X-Recipient: geda-user AT delorie DOT com
X-Envelope-From: paubert AT iram DOT es
Date: Sat, 1 Jun 2013 00:13:16 +0200
From: Gabriel Paubert <paubert AT iram DOT es>
To: geda-user AT delorie DOT com
Subject: [geda-user] [RFC][PATCH] Separate aperture and drill number spaces.
Message-ID: <20130531221316.GA14164@visitor2.iram.es>
MIME-Version: 1.0
User-Agent: Mutt/1.5.20 (2009-06-14)
X-Spamina-Bogosity: Unsure
X-Spam-Score: -1.4 (-)
X-Spam-Report: Content analysis details: (-1.4 points)
pts rule name description
---- ---------------------- --------------------------------------------------
-1.4 ALL_TRUSTED Passed through trusted hosts only via SMTP
Reply-To: geda-user AT delorie DOT com

	Hi,

I was a bit annoyed to see that the drill numbers in my gerber exports
were well above 100. The reason for this is that there is a single number
space for all kinds of apertures (gerber and drills).

I have modified the code and now I have drill files starting with 1,
but I must say that I'm not completely satisfied with the patch.
I think that it is quite minimalist but if someone has a better idea
on how to implement this, I'm ready to hear this. (Note that the
patch also replaces a µ character with a u in a comment).

On a related note, I have found the latest version of the gerber
file format specification: 

http://www.ucamco.com/LinkClick.aspx?fileticket=xjsk072bCps%3d&tabid=87&mid=1904&language=en-US

PCB is far from complying with it, but I had a board recently subcontracted
to a person using CadStar and it's not much better. However, this document
makes at least a few things clear, for example that circular interpolation
is exactly this, circular and in no way elliptical.

On the other hand, the description is sometimes optimistic:
"Line separator style can be Windows (CRLF), Unix (LF), Macintosh (CR) or a mix. 
Line separators are only allowed between data blocks and within aperture macro 
definitions (see AM parameter)."

Many PCB shops won't accept anything else than Windows line termination.

Anyway, here is my current patch, tested only on one moderately complex
board (6 layers, 168 components, mixture of through hole and SMD, 
200x80mm, aperture number reaching 200 something).

	Gabriel

diff --git a/src/hid/gerber/gerber.c b/src/hid/gerber/gerber.c
index 6d7c7c1..d02d35d 100644
--- a/src/hid/gerber/gerber.c
+++ b/src/hid/gerber/gerber.c
@@ -106,7 +106,8 @@ enum ApertureShape
   SQUARE,			/* Shaped like a square */
   ROUNDCLEAR,			/* clearance in negatives */
   SQUARECLEAR,
-  THERMAL			/* negative thermal relief */
+  THERMAL,			/* negative thermal relief */
+  DRILL
 };
 typedef enum ApertureShape ApertureShape;
 
@@ -174,7 +175,7 @@ deinitApertureList (ApertureList *list)
   initApertureList (list);
 }
 
-static int aperture_count;
+static int aperture_count, drill_count;
 
 static void resetApertures()
 {
@@ -187,6 +188,7 @@ static void resetApertures()
   layer_list_max = 0;
   layer_list_idx = 0;
   aperture_count = 0;
+  drill_count = 0;
 }
 
 /* Create and add a new aperture to the list */
@@ -200,7 +202,8 @@ addAperture (ApertureList *list, Coord width, ApertureShape shape)
 
   app->width = width;
   app->shape = shape;
-  app->dCode = DCODE_BASE + aperture_count++;
+  if (shape == DRILL) app->dCode = ++drill_count;
+  else app->dCode = DCODE_BASE + aperture_count++;
   app->next  = list->data;
 
   list->data = app;
@@ -694,7 +697,7 @@ gerber_set_layer (const char *name, int group, int empty)
 	{
 	  if (i == 0 || pending_drills[i].diam != pending_drills[i - 1].diam)
 	    {
-	      Aperture *ap = findAperture (curr_aptr_list, pending_drills[i].diam, ROUND);
+	      Aperture *ap = findAperture (curr_aptr_list, pending_drills[i].diam, DRILL);
 	      fprintf (f, "T%02d\r\n", ap->dCode);
 	    }
 	  pcb_fprintf (f, metric ? "X%06.0muY%06.0mu\r\n" : "X%06.0mtY%06.0mt\r\n",
@@ -762,7 +765,7 @@ gerber_set_layer (const char *name, int group, int empty)
       if (is_drill)
 	{
 	  /* We omit the ,TZ here because we are not omitting trailing zeros.  Our format is
-	     always six-digit 0.1 mil or µm resolution (i.e. 001100 = 0.11" or 1.1mm)*/
+	     always six-digit 0.1 mil or um resolution (i.e. 001100 = 0.11" or 1.1mm)*/
 	  fprintf (f, "M48\r\n");
 	  fprintf (f, metric ? "METRIC,000.000\r\n" : "INCH\r\n");
 	  for (search = aptr_list->data; search; search = search->next)
@@ -947,7 +950,8 @@ use_gc (hidGC gc, int radius)
       radius *= 2;
       if (radius != linewidth || lastcap != Round_Cap)
 	{
-	  Aperture *aptr = findAperture (curr_aptr_list, radius, ROUND);
+	  Aperture *aptr = findAperture (curr_aptr_list, radius,
+					 is_drill ? DRILL : ROUND);
 	  if (aptr == NULL)
 	    pcb_fprintf (stderr, "error: aperture for radius %$mS type ROUND is null\n", radius);
 	  else if (f && !is_drill)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019