[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-user: freerouting export



   dsn exporter supports multilayer boards and no longer crashes from
   null element names or refdes.
   An unrelated but essential change is to stop the library window from
   opening every time pcb opens in gtk.
   There is no freerouting import yet but you can route boards and save
   the .ses file for future importing.  I ran it on dj's furnace board
   and it reduced vias from 235 to 145 taking 12 hours.
   -Josh
diff --git a/src/Makefile.am b/src/Makefile.am
index 1c97b60..0572e01 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,7 +12,7 @@ HIDLIST = @HIDLIST@
 noinst_LIBRARIES = @HIDLIBS@
 EXTRA_LIBRARIES = \
 	libgtk.a liblesstif.a libbatch.a \
-	liblpr.a libgerber.a libbom.a libpng.a libps.a libnelma.a libgts.a
+	liblpr.a libgerber.a libbom.a libspecctra.a libpng.a libps.a libnelma.a libgts.a
 
 pcblib_DATA=	\
 	default_font \
@@ -198,6 +198,7 @@ EXTRA_DIST= \
 	default_font \
 	$(srcdir)/hid/batch/hid.conf \
 	$(srcdir)/hid/bom/hid.conf \
+  $(srcdir)/hid/specctra/hid.conf \
 	$(srcdir)/hid/gerber/hid.conf \
 	$(srcdir)/hid/gtk/gui-icons-misc.data \
 	$(srcdir)/hid/gtk/gui-icons-mode-buttons.data \
@@ -385,6 +386,10 @@ libbom_a_SOURCES = \
 	hid/hidint.h \
 	hid/bom/bom.c
 
+libspecctra_a_SOURCES = \
+  hid/hidint.h \
+  hid/specctra/specctra.c
+
 libps_a_CPPFLAGS = -I./hid/ps
 LIBPS_SRCS = \
 	dolists.h \
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index cbdd104..f3086ca 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -1741,11 +1741,15 @@ LayerGroupsChanged (int argc, char **argv, int x, int y)
 }
 
 /* ---------------------------------------------------------------------- */
+int stop_annoying_library = 1;
 
 static int
 LibraryChanged (int argc, char **argv, int x, int y)
 {
-  ghid_library_window_show (&ghid_port, FALSE);
+  if(stop_annoying_library)
+    stop_annoying_library = 0;
+  else
+    ghid_library_window_show (&ghid_port, FALSE);
   return 0;
 }
 
@@ -2413,6 +2417,7 @@ Open the DRC violations window.
 
 %end-doc */
 
+
 static int
 DoWindows (int argc, char **argv, int x, int y)
 {
diff --git a/src/hid/specctra/specctra.c b/src/hid/specctra/specctra.c
index 1dab7b5..d4cb39f 100644
--- a/src/hid/specctra/specctra.c
+++ b/src/hid/specctra/specctra.c
@@ -1,6 +1,7 @@
 /*
 This program exports specctra .dsn files from geda .pcb files.
-By Josh Jordan
+By Josh Jordan and Dan McMahill, modified from bom.c
+
 */
 
 #ifdef HAVE_CONFIG_H
@@ -24,40 +25,33 @@ By Josh Jordan
 
 #include "hid.h"
 #include "../hidint.h"
+#include "specctra.h"
 
 #ifdef HAVE_LIBDMALLOC
 #include <dmalloc.h>
 #endif
 
+int trackwidth = 8; //user options defined in export dialog
+int clearance = 8;
+
 static HID_Attribute specctra_options[] = {
   {"specctrafile", "SPECCTRA output file",
    HID_String, 0, 0, {0, 0, 0}, 0, 0},
 #define HA_specctrafile 0
   {"trackwidth", "default track width in mils",
-   HID_Integer, 0, 0, {0, 0, 0}, 0, 0},
+   HID_Integer, 1, 100, {8, 0, 0}, 0, 0},
 #define HA_trackwidth 1
+  {"clearance", "default clearance in mils",
+   HID_Integer, 1, 100, {8, 0, 0}, 0, 0},
+#define HA_clearance 2
 };
 
 #define NUM_OPTIONS (sizeof(specctra_options)/sizeof(specctra_options[0]))
-
-static HID_Attr_Val specctra_values[NUM_OPTIONS];
+REGISTER_ATTRIBUTES (specctra_options)
+  static HID_Attr_Val specctra_values[NUM_OPTIONS];
 
 static char *specctra_filename;
 
-typedef struct _StringList
-{
-  char *str;
-  struct _StringList *next;
-} StringList;
-
-typedef struct _SpecctraList
-{
-  char *descr;
-  char *value;
-  int num;
-  StringList *refdes;
-  struct _SpecctraList *next;
-} SpecctraList;
 
 static HID_Attribute *
 specctra_get_export_options (int *n)
@@ -66,45 +60,12 @@ specctra_get_export_options (int *n)
   if (PCB) {
 	derive_default_filename(PCB->Filename, &specctra_options[HA_specctrafile], ".dsn", &last_specctra_filename);
   }
-
   if (n)
     *n = NUM_OPTIONS;
   return specctra_options;
 }
 
 
-static char *
-CleanSPECCTRAString (char *in)
-{
-  char *out;
-  int i;
-
-  if ((out = malloc ((strlen (in) + 1) * sizeof (char))) == NULL)
-    {
-      fprintf (stderr, "Error:  CleanSPECCTRAString() malloc() failed\n");
-      exit (1);
-    }
-
-  /* 
-   * copy over in to out with some character conversions.
-   * Go all the way to then end to get the terminating \0
-   */
-  for (i = 0; i <= strlen (in); i++)
-    {
-      switch (in[i])
-	{
-	case '"':
-	  out[i] = '\'';
-	  break;
-	default:
-	  out[i] = in[i];
-	}
-    }
-
-  return out;
-}
-
-
 static double
 xyToAngle (double x, double y)
 {
@@ -276,149 +237,52 @@ get_rotation_and_centroid (ElementType *element){
   }
 }
 
+Boolean is_layer_group_active[MAX_LAYER];
+GList *layerlist = NULL; //contain unique layer names- (PCB copper layers, aka geda pcb layergroups, not geda pcb layers)
+int layersN; //global var holding how many layers are found
 
-static StringList *
-string_insert (char *str, StringList * list)
-{
-  StringList *new, *cur;
-
-  if ((new = (StringList *) malloc (sizeof (StringList))) == NULL)
-    {
-      fprintf (stderr, "malloc() failed in string_insert()\n");
-      exit (1);
-    }
-
-  new->next = NULL;
-  new->str = strdup (str);
-
-  if (list == NULL)
-    return (new);
-
-  cur = list;
-  while (cur->next != NULL)
-    cur = cur->next;
-
-  cur->next = new;
-
-  return (list);
-}
-
-static SpecctraList *
-specctra_insert (char *refdes, char *descr, char *value, SpecctraList * specctra)
+static void
+print_structure (FILE *fp)
 {
-  SpecctraList *new, *cur, *prev = NULL;
-
-  if (specctra == NULL)
-    {
-      /* this is the first element so automatically create an entry */
-      if ((new = (SpecctraList *) malloc (sizeof (SpecctraList))) == NULL)
-	{
-	  fprintf (stderr, "malloc() failed in specctra_insert()\n");
-	  exit (1);
-	}
-
-      new->next = NULL;
-      new->descr = strdup (descr);
-      new->value = strdup (value);
-      new->num = 1;
-      new->refdes = string_insert (refdes, NULL);
-      return (new);
-    }
-
-  /* search and see if we already have used one of these
-     components */
-  cur = specctra;
-  while (cur != NULL)
-    {
-      if ((NSTRCMP (descr, cur->descr) == 0) &&
-	  (NSTRCMP (value, cur->value) == 0))
-	{
-	  cur->num++;
-	  cur->refdes = string_insert (refdes, cur->refdes);
-	  break;
-	}
-      prev = cur;
-      cur = cur->next;
-    }
-
-  if (cur == NULL)
+  /* check which layers are active first */
+  int i;
+  int group;
+  fprintf (fp, "  (structure\n");
+  layersN = 0;
+//#if 0  //this is to find layergroup names. hardcoded for now
+  for (group = 0; group < max_layer; group++)
+  {
+    for (i = 0; i < PCB->LayerGroups.Number[group]; i++)
+    /* layer must be 1) not silk (ie, < max_layer) and 2) on */
+    if ((PCB->LayerGroups.Entries[group][i] < max_layer) && PCB->Data->Layer[PCB->LayerGroups.Entries[group][i]].On)
     {
-      if ((new = (SpecctraList *) malloc (sizeof (SpecctraList))) == NULL)
-	{
-	  fprintf (stderr, "malloc() failed in specctra_insert()\n");
-	  exit (1);
-	}
-
-      prev->next = new;
-
-      new->next = NULL;
-      new->descr = strdup (descr);
-      new->value = strdup (value);
-      new->num = 1;
-      new->refdes = string_insert (refdes, NULL);
+      char * lname;
+      layersN++;
+      is_layer_group_active[group] = True;
+      GROUP_LOOP(PCB->Data, group);
+      {
+        lname = strdup(layer->Name);
+        layerlist = g_list_insert( layerlist, lname, group );
+        printf("adding %s to list in position %d\n", lname, group);
+        break;
+      }
+      END_LOOP;
+      break;
     }
-
-  return (specctra);
-
-}
-
-/* 
- * If fp is not NULL then print out the bill of materials contained in
- * specctra.  Either way, free all memory which has been allocated for specctra.
- */
-static void
-print_and_free (FILE *fp, SpecctraList *specctra)
-{
-  SpecctraList *lastb;
-  StringList *lasts;
-  char *descr, *value;
-
-  while (specctra != NULL)
+	  else
+	    is_layer_group_active[group] = False;
+  }
+  //layerlist = g_list_reverse( layerlist ); //this is because layer order is reversed for .dsn files
+  printf("found %d layergroups\n", layersN);
+  for(i = 0; i < max_layer; i++)
+  {
+    if(is_layer_group_active[i])
     {
-      if (fp)
-	{
-	  descr = CleanSPECCTRAString (specctra->descr);
-	  value = CleanSPECCTRAString (specctra->value);
-	  fprintf (fp, "%d,\"%s\",\"%s\",", specctra->num, descr, value);
-	  free (descr);
-	  free (value);
-	}
-      
-      while (specctra->refdes != NULL)
-	{
-	  if (fp)
-	    {
-	      fprintf (fp, "%s ", specctra->refdes->str);
-	    }
-	  free (specctra->refdes->str);
-	  lasts = specctra->refdes;
-	  specctra->refdes = specctra->refdes->next;
-	  free (lasts);
-	}
-      if (fp)
-	{
-	  fprintf (fp, "\n");
-	}
-      lastb = specctra;
-      specctra = specctra->next;
-      free (lastb);
+      printf("layergroup %d (%s)\n", i, g_list_nth_data( layerlist, i ));
+      fprintf( fp, "    (layer %s\n      (type signal)\n      (property\n        (index %d)\n      )\n    )\n",
+              g_list_nth_data( layerlist, i ), i);
     }
-}
-
-static void
-print_structure (FILE *fp)
-{
-  fprintf (fp, "  (structure\n");
-
-  /* define layers */
-  fprintf (fp, "    (layer Component\n");
-  fprintf (fp, "      (type signal)\n");
-  fprintf (fp, "      (property\n");
-  fprintf (fp, "        (index 0)\n      )\n    )\n");
-  fprintf (fp, "    (layer Copper\n");
-  fprintf (fp, "      (type signal)\n");
-  fprintf (fp, "      (property\n");
-  fprintf (fp, "        (index 1)\n      )\n    )\n");
+  }
 
   /* PCB outline */
   fprintf (fp, "    (boundary\n");
@@ -429,138 +293,122 @@ print_structure (FILE *fp)
 
   /* DRC rules */
   fprintf (fp, "    (rule\n");
-  fprintf (fp, "      (width 8)\n");
-  fprintf (fp, "      (clear 10)\n");
-  fprintf (fp, "      (clear 10 (type wire_area))\n");
-  fprintf (fp, "      (clear 10 (type via_smd via_pin))\n");
-  fprintf (fp, "      (clear 10 (type smd_smd))\n");
-  fprintf (fp, "      (clear 10 (type default_smd))\n");
+  fprintf (fp, "      (width %d)\n", trackwidth);
+  fprintf (fp, "      (clear %d)\n", clearance);
+  fprintf (fp, "      (clear %d (type wire_area))\n", clearance);
+  fprintf (fp, "      (clear %d (type via_smd via_pin))\n", clearance);
+  fprintf (fp, "      (clear %d (type smd_smd))\n", clearance);
+  fprintf (fp, "      (clear %d (type default_smd))\n", clearance);
   fprintf (fp, "    )\n  )\n");
 }
 
 static void
 print_placement (FILE *fp)
-/* gather all footprint names in a list
-   gather list of refdes for each footprint in list */
 {
-  int i;
-  GList *footprints; //contain unique footprint names
   fprintf (fp, "  (placement\n");
+  printf("status: placement section\n");
+  /* pcb doesnt remember footprint library- place all elements as their own library image */
   ELEMENT_LOOP (PCB->Data);
   {
-    gconstpointer descript = DESCRIPTION_NAME (element);
-    if( !g_list_find_custom( footprints, descript, strcmp ) ){
-      footprints = g_list_append( footprints, descript );
-    }
-  }
-  END_LOOP;
-  for(i=0; i < g_list_length( footprints ); i++){
-    int firstrot = -1; //change to the degree of the first element found
-    fprintf (fp, "    (component %s\n", g_list_nth_data( footprints, i ));
-    ELEMENT_LOOP (PCB->Data);
-    {
-      if(!strcmp(DESCRIPTION_NAME (element), g_list_nth_data( footprints, i ) )){
-        CentroidRotation crot = get_rotation_and_centroid(element);
-        if (firstrot == -1)
-        {
-          firstrot = crot.rot;
-        }
-        char* side = TEST_FLAG (ONSOLDERFLAG, element) ? "back" : "front";
-        fprintf (fp, "      (place %s %.2f %.2f %s %d (PN %s))\n", NAMEONPCB_NAME (element), crot.centx, crot.centy, side, firstrot-crot.rot, VALUE_NAME (element) );
-      }
-    }
-    END_LOOP;
+    char * ename;
+    CentroidRotation ecenter = get_rotation_and_centroid(element); //only need centroid
+    char* side = TEST_FLAG (ONSOLDERFLAG, element) ? "back" : "front";
+    //ename = (strncmp(NAMEONPCB_NAME(element), "(null)", 6) ? NAMEONPCB_NAME(element) : "null");
+    ename = NAMEONPCB_NAME(element);
+    if(!ename)
+      ename = g_strdup_printf("null");
+    fprintf( fp, "    (component %d\n", element->ID);
+    fprintf (fp, "      (place %s %.2f %.2f %s 0 (PN 0))\n", ename, ecenter.centx, ecenter.centy, side);
     fprintf (fp, "    )\n");
   }
+  END_LOOP;
+  printf("status: placement finished\n");
   fprintf (fp, "  )\n");
-  g_list_free( footprints );
 }
 
 static void
 print_library (FILE *fp)
-/* gather all footprint names in a list
-   print info on each footprint */
 {
   int i;
-  GList *footprints; //contain unique footprint names
-  GList *pads; //contain unique pad names
+  GList *pads = NULL; //contain unique pad names
   fprintf (fp, "  (library\n");
+  printf ("status: library section\n");
   ELEMENT_LOOP (PCB->Data);
   {
-    if( !g_list_find_custom( footprints, DESCRIPTION_NAME (element), strcmp ) ){
-      char *padstack;
-      int rotation;
-      int whichside = TEST_FLAG (ONSOLDERFLAG, element) ? -1 : 1;
-      CentroidRotation crot = get_rotation_and_centroid(element);
-      footprints = g_list_append( footprints, g_strdup( DESCRIPTION_NAME (element) ) );
-      fprintf (fp, "    (image %s\n", DESCRIPTION_NAME (element) );
-      /* loop thru pins and pads here */
-      PIN_LOOP (element);
+    char *padstack;
+    int rotation;
+    int partside = TEST_FLAG (ONSOLDERFLAG, element) ? layersN-1 : 0; //0 for component side, highest for solder side
+    int partsidesign = TEST_FLAG (ONSOLDERFLAG, element) ? -1 : 1;
+    CentroidRotation crot = get_rotation_and_centroid(element);
+    fprintf (fp, "    (image %d\n", element->ID); //map every element by ID
+    /* loop thru pins and pads to add to image */
+    PIN_LOOP (element);
+    {
+      int ty;
+      float pinthickness;
+      float lx, ly; //hold local pin coordinates
+      ty = PCB->MaxHeight - pin->Y;
+      pinthickness = pin->Thickness*0.01;
+      padstack = g_strdup_printf ("Th_round_%.0f_mil", pinthickness);
+      lx = (pin->X*0.01-crot.centx)*partsidesign;
+      ly = (crot.centy - ty*0.01)*(-1);
+      if( !g_list_find_custom( pads, padstack, strcmp ) )
+        pads = g_list_append( pads, padstack );
+      
+      if (!pin->Number) //if pin is null just make it a keepout
       {
-        int ty;
-        float pinthickness;
-        float lx, ly; //hold local pin coordinates
-        ty = PCB->MaxHeight - pin->Y;
-        pinthickness = pin->Thickness*0.01;
-        padstack = g_strdup_printf ("Th_round_%.0f_mil", pinthickness);
-        lx = (pin->X*0.01-crot.centx)*whichside;
-        ly = (crot.centy - ty*0.01)*(-1);
-        if( !g_list_find_custom( pads, padstack, strcmp ) )
-        {
-          pads = g_list_append( pads, padstack );
-        }
-        if (!pin->Number) //if pin is null just make it a keepout
-        {
-          fprintf (fp, "      (keepout \"\" (circle Component %.0f %.2f %.2f))\n", pinthickness, lx, ly);
-          fprintf (fp, "      (keepout \"\" (circle Copper %.0f %.2f %.2f))\n", pinthickness, lx, ly);
-        }
-        else
+        for(int i = 0; i < layersN; i++)
         {
-          fprintf (fp, "      (pin %s %s %.2f %.2f)\n", padstack, pin->Number, lx, ly);
+          fprintf (fp, "      (keepout \"\" (circle %s %.0f %.2f %.2f))\n", g_list_nth_data( layerlist, i ), pinthickness, lx, ly);
         }
       }
-      END_LOOP;
-      PAD_LOOP (element);
+      else
       {
-        int xlen, ylen, xc, yc, p1y, p2y;
-        float lx, ly; //store local coordinates for pins
-        p1y = PCB->MaxHeight - pad->Point1.Y;
-        p2y = PCB->MaxHeight - pad->Point2.Y;
-        /* pad dimensions are thickness and point difference plus thickness */
-        xlen = (ABS(pad->Point1.X - pad->Point2.X)+50)/100; //round to mil
-        if (xlen == 0)
-        {
-          xlen = (pad->Thickness+50)/100; //round to mil
-          ylen = (ABS(p1y - p2y)+50)/100 + xlen; //round to mil
-        }
-        else
-        {
-          ylen = (pad->Thickness+50)/100;
-          xlen += ylen;
-        }
-        xc = (pad->Point1.X + pad->Point2.X)/2;
-        yc = (p1y + p2y)/2;
-        lx = (xc*0.01-crot.centx)*whichside;
-        ly = (crot.centy - yc*0.01)*(-1);
-        padstack = g_strdup_printf ("Smd_rect_%dx%d_mil", xlen, ylen);
-        if( !g_list_find_custom( pads, padstack, strcmp ) )
-        {
-          pads = g_list_append( pads, padstack );
-        }
-        if (!pad->Number) //if pad is null just make it a keepout
-        {
-          fprintf (fp, "      (keepout \"\" (rect %s %.2f %.2f %.2f %.2f))\n", (whichside == 1) ? "Component" : "Copper", lx-xlen/2, ly-ylen/2, lx+xlen/2, ly+ylen/2);
-        }
-        else
-        {
-          fprintf (fp, "      (pin %s %s %.2f %.2f)\n", padstack, pad->Number, lx, ly);
-        }
+        fprintf (fp, "      (pin %s %s %.2f %.2f)\n", padstack, pin->Number, lx, ly);
       }
-      END_LOOP;
-      fprintf (fp, "    )\n");
     }
+    END_LOOP;
+    PAD_LOOP (element);
+    {
+      int xlen, ylen, xc, yc, p1y, p2y;
+      float lx, ly; //store local coordinates for pins
+      p1y = PCB->MaxHeight - pad->Point1.Y;
+      p2y = PCB->MaxHeight - pad->Point2.Y;
+      /* pad dimensions are unusual-
+        the width is thickness and length is point difference plus thickness */
+      xlen = (ABS(pad->Point1.X - pad->Point2.X)+50)/100; //round to mil
+      if (xlen == 0)
+      {
+        xlen = (pad->Thickness+50)/100; //round to mil
+        ylen = (ABS(p1y - p2y)+50)/100 + xlen; //round to mil
+      }
+      else
+      {
+        ylen = (pad->Thickness+50)/100;
+        xlen += ylen;
+      }
+      xc = (pad->Point1.X + pad->Point2.X)/2;
+      yc = (p1y + p2y)/2;
+      lx = (xc*0.01-crot.centx)*partsidesign;
+      ly = (crot.centy - yc*0.01)*(-1);
+      padstack = g_strdup_printf ("Smd_rect_%dx%d_mil", xlen, ylen);
+      if( !g_list_find_custom( pads, padstack, strcmp ) )
+        pads = g_list_append( pads, padstack );
+   
+      if (!pad->Number) //if pad is null just make it a keepout
+      {
+        fprintf (fp, "      (keepout \"\" (rect %s %.2f %.2f %.2f %.2f))\n", g_list_nth_data( layerlist, partside ), lx-xlen/2, ly-ylen/2, lx+xlen/2, ly+ylen/2);
+      }
+      else
+      {
+        fprintf (fp, "      (pin %s %s %.2f %.2f)\n", padstack, pad->Number, lx, ly);
+      }
+    }
+    END_LOOP;
+    fprintf (fp, "    )\n");
   }
   END_LOOP;
+  printf("status: padstacks\n");
   /* loop thru padstacks and define them all */
   for(i=0; i < g_list_length( pads ); i++)
   {
@@ -571,22 +419,27 @@ print_library (FILE *fp)
     retargs = sscanf (padstring, "Smd_rect_%dx%d_mil", &dim1, &dim2);
     if (retargs == 2) //then pad is smd
     { 
-      fprintf (fp, "      (shape (rect Component %.1f %.1f %.1f %.1f))\n", dim1/(-2.0), dim2/(-2.0), dim1/2.0, dim2/2.0);
+      fprintf (fp, "      (shape (rect %s %.1f %.1f %.1f %.1f))\n", g_list_nth_data( layerlist, 0 ), dim1/(-2.0), dim2/(-2.0), dim1/2.0, dim2/2.0);
     }
     else ///then pad is th
     {
       retargs = sscanf (padstring, "Th_round_%d_mil", &dim1);
-      fprintf (fp, "      (shape (circle Component %d))\n", dim1);
-      fprintf (fp, "      (shape (circle Copper %d))\n", dim1);
+      for(int ii = 0; ii < layersN; ii++)
+      {
+        fprintf (fp, "      (shape (circle %s %d))\n", g_list_nth_data( layerlist, ii ), dim1);
+      }
     }
     fprintf (fp, "      (attach off)\n");
     fprintf (fp, "    )\n");
   }
   /* add padstack for via */
-  fprintf (fp, "    (padstack \"via_45_25_mil\"\n      (shape (circle Component 45))\n      (shape (circle Copper 45))\n      (attach off)\n    )\n");
+  fprintf (fp, "    (padstack \"via_45_25_mil\"\n");
+  for(i = 0; i < layersN; i++)
+  {
+    fprintf (fp, "      (shape (circle %s 45))\n", g_list_nth_data( layerlist, i ) );
+  }
+  fprintf (fp, "      (attach off)\n    )\n");
   fprintf (fp, "  )\n");
-  g_list_foreach( footprints, (GFunc)g_free, NULL );
-  g_list_free( footprints );
   g_list_foreach( pads, (GFunc)g_free, NULL );
   g_list_free( pads );
 }
@@ -594,104 +447,43 @@ print_library (FILE *fp)
 static void
 print_network (FILE *fp)
 {
-  GList *netlistnames;  //contain unique strings of netlist names
-  int i, firstcon;
   NetListListType Nets;
   Nets = CollectSubnets (False);
   fprintf (fp, "  (network\n");
-  NETLIST_LOOP (&Nets);
+  printf("status: network section\n");
+
+  int ni, nei;
+  for (ni = 0; ni < PCB->NetlistLib.MenuN; ni++) //loop thru all nets
   {
-    firstcon = 1; //clear flag after net name is found
-    NET_LOOP (netlist);
+    fprintf (fp, "    (net %s\n      (pins", PCB->NetlistLib.Menu[ni].Name + 2);
+    for (nei = 0; nei < PCB->NetlistLib.Menu[ni].EntryN; nei++) //loop thru all entries in all nets
     {
-      CONNECTION_LOOP (net);
-      {
-        int ni, nei;
-	      char *ename;
-	      char *pname;
-	      char *n;
-        char *netname;
-        /* looking for pins and pads */
-        if (connection->type == PIN_TYPE || connection->type == PAD_TYPE)
-        {
-          PinTypePtr thispin;
-          PadTypePtr thispad;
-          ElementTypePtr thiselem;
-          if (connection->type == PIN_TYPE)
-          {
-            thispin = connection->ptr2;
-            thiselem = thispin->Element;
-            pname = thispin->Number;
-          }
-          else
-          {
-            thispad = connection->ptr2;
-            thiselem = thispad->Element;
-            pname = thispad->Number;
-          }
-          ename = NAMEONPCB_NAME(thiselem);
-          n = g_strconcat (ename, "-", pname, NULL);
-	        for (ni = 0; ni < PCB->NetlistLib.MenuN; ni++) //loop thru all nets
-		      for (nei = 0; nei < PCB->NetlistLib.Menu[ni].EntryN; nei++) //loop thru all entries in all nets
-		      {
-		        if (strcmp (PCB->NetlistLib.Menu[ni].Entry[nei].ListEntry, n) == 0) //find the entry that matches this pin or pad
-		        {
-              netname = g_strdup (PCB->NetlistLib.Menu[ni].Name + 2); //find the net name of this entry
-              //if( !g_list_find_custom( netlistnames, netname, strcmp ) ) //see if netlist was written down already
-              if(firstcon == 1)
-              {
-                firstcon = 0;
-                netlistnames = g_list_append( netlistnames, netname );
-                fprintf (fp, "    (net %s\n      (pins", netname);
-              }
-            }
-          }
-          fprintf (fp, " %s", n);
-          g_free(n);
-        }
-      }
-      END_LOOP;
+      char *netentry;
+      netentry = PCB->NetlistLib.Menu[ni].Entry[nei].ListEntry;
+      fprintf (fp, " %s", netentry);
     }
-    END_LOOP;
     fprintf (fp, ")\n    )\n");
   }
-  END_LOOP;
+
   fprintf (fp, "    (class geda_default");
-  for(i=0; i < g_list_length( netlistnames ); i++)
+  for (ni = 0; ni < PCB->NetlistLib.MenuN; ni++) //loop thru all nets
   {
-    fprintf (fp, " %s", g_list_nth_data( netlistnames, i ) );
+    fprintf (fp, " %s", PCB->NetlistLib.Menu[ni].Name + 2);
   }
   fprintf (fp, "\n      (circuit\n        (use_via via_45_25_mil)\n      )\n");
-  fprintf (fp, "      (rule (width 8))\n    )\n  )\n");
+  fprintf (fp, "      (rule (width %d))\n    )\n  )\n", trackwidth);
   fprintf (fp, "  (wiring\n  )\n)\n");
-  
-  g_list_foreach( netlistnames, (GFunc)g_free, NULL );
-  g_list_free( netlistnames );
 }
 
 static int
 PrintSPECCTRA (void)
 {
-  char utcTime[64];
-  double x, y, theta = 0.0, user_x, user_y;
-  double sumx, sumy;
-  double pin1x = 0.0, pin1y = 0.0, pin1angle = 0.0;
-  double pin2x = 0.0, pin2y = 0.0, pin2angle;
-  int found_pin1;
-  int found_pin2;
-  int pin_cnt;
-  time_t currenttime;
   FILE *fp;
-  SpecctraList *specctra = NULL;
-  char *name, *descr, *value;
-
   /* Print out the specctra .dsn file. */
-
   fp = fopen (specctra_filename, "w");
   if (!fp)
     {
       gui->log ("Cannot open file %s for writing\n", specctra_filename);
-      print_and_free (NULL, specctra);
       return 1;
     }
 
@@ -745,31 +537,34 @@ PrintSPECCTRA (void)
   /* wiring descriptor [optional] */
   
   /* color descriptor [optional] */
-  
-  print_and_free (fp, specctra);
+  printf("status: almost done\n");
 
   fclose (fp);
 
   return (0);
 }
 
+
 static void
 specctra_do_export (HID_Attr_Val * options)
 {
   int i;
-
+  int trackwidth, clearance;
   if (!options)
-    {
-      specctra_get_export_options (0);
-      for (i = 0; i < NUM_OPTIONS; i++)
-	specctra_values[i] = specctra_options[i].default_val;
-      options = specctra_values;
-    }
-
+  {
+    specctra_get_export_options (0);
+    for (i = 0; i < NUM_OPTIONS; i++)
+      specctra_values[i] = specctra_options[i].default_val;
+    options = specctra_values;
+  }
   specctra_filename = options[HA_specctrafile].str_value;
   if (!specctra_filename)
     specctra_filename = "pcb-out.dsn";
 
+  trackwidth = options[HA_trackwidth].int_value;
+  clearance = options[HA_clearance].int_value;
+  printf("tracks %d/%d\n", trackwidth, clearance);
+
   PrintSPECCTRA ();
 }
 

_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user