⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unidat-fiducials.ulp

📁 老外的PCB设计软件,是免费的.可以上网更新.
💻 ULP
📖 第 1 页 / 共 3 页
字号:
#usage "<b>Export UNIDAT format</b>\n"
       "<p>"
       "<author>Author: support@cadsoft.de</author>"

// THIS PROGRAM IS PROVIDED AS IS AND WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED

///////////////////////////////////////////////////////////////////////////////////////////
// Rudi Hofer, CadSoft, rudi.hofer@cadsoft.de, 9/1999
//
// Revision 1.1: shape names derived from element names instead of package names (unique!)
// Revision 1.2: output limited to elements with package in routine "component"
// Revision 1.3: output of round pads corrected
// Revision 2.0: shape names again derived from package names (seems to be the only
//               solution which makes sense)
//
// Revision 3.0: include Crossref.ULP with Pin_Name from Sheet     -- alf@cadsoft.de
// Revision 4.0: for EAGLE Version 4.0 with Dialog                 -- alf@cadsoft.de
// Revision 5.0: exports Polygon of signals                        -- alf@cadsoft.de
// Revision 6.0: exports Fiducial if placed from MAKRS.lbr         -- alf@cadsoft.de 30.03.2004
//               Source: unidat.format.91010.doc from <Claus.Kessel@tecnomatix.com>
//
///////////////////////////////////////////////////////////////////////////////////////////
// Since version 2.0 all packages with the same name must be identical (avoid REPLACE!)
///////////////////////////////////////////////////////////////////////////////////////////
// This ULP generates output for UNICAM software which is able to convert the
// data for automatic mounting and test equipment. The resolution is fixed to 1/100 mm.
//
// To generate the output, load the board and run this ULP.
//
// You can provide properties like "partnumber", "tolerance" etc. in the
// component library:
//
// - define a user layer named UNIDAT
// - add texts in the form "propertyname=value" to this layer, e.g.
//   partnumber=12345
//   pos_tolerance=0.05
// - see array property[] below for predefined property names
// - by changing the array contents you can change the property names
//   (do not change the number of array entries!)
//
// OUTPUT OF PROPERTIES IS ONLY POSSIBLE IF FORWARD & BACK ANNOTATION IS USED AND
// IF THE SCHEMATIC AND THE BOARD ARE LOADED!
// THE PROGRAM HAS TO BE EXECUTED FROM THE BOARD WINDOW!
//
//
// Pads of the shape type OCTAGON are changed to round, if the following variable
// is set to 1 (otherwise set to 0)

   int disp_oct_as_round = 1;

//
///////////////////////////////////////////////////////////////////////////////////////////

/* Dieses ULP erzeugt eine Cross-Referenzliste zwischen Pad und Pin ***
 * Dabei wird eine Liste generiert, in der die Koordinaten
 * der Pads/Netze im Board, in Bezug zu den Pins/Netze im
 * Schaltplan(Sheet Nr.) stehen.
 * A. Zaffran CadSoft 07.09.1999
 */

/*

%COMPONENT
C1|N$5|sheet2|15.240,8.890|mm|
C1|1|N$5|sheet2|15.240,8.890|mm|
|  | |     |       |    |
|  | |     |       X    Y
|  | |    Seite
|  | Netzname
|  Pad-Name
Bauteil

%PINS
IC1|IC1A|FILTER|1|I0|sheet1|25.40,22.86|mm|
|    |     |    |  |   |      |     |
|    |     |    |  |   |      X     Y
|    |     |    |  |   Seite
|    |     |    |  Symbolischer Pin-Name
|    |     |    Numerischer Pin-Name
|    |     Netzname
|    Gate-Name
Bauteil

*/

string _MARKER_ = "marks";  // the library name for fiducials

int   px[], py[], ps[], PinPoints = 0;  // Pin: x, y, sheet, counter
string  pa[],      pg[],      pc[],         pn[],    pnn[];
     // Part-name, gate-name, contact-name, pinname, pin-netname

int   padx[], pady[], pads[], PadPoints = 0;  // Pad: x, y, sheet, counter
string  padd[], padn[], padnn[];              // devicename, padname, pad-netname

int   sheetload = 0;
string proz = "%";
string Pad_Pin = "";

enum { bottom = 16 };

string reffile;
string unifile;

string ULPversion = filename(argv[0]);

//-----------------------------------------------------

string user_layer_name = "unidat", // layer name for property definitions (lower case!)
       jobname,
//     jobrevision = "1.0",
       layer_name[],
       property_assign_char = "=",
       property[] = {"partnumber"        // propterty[0] is partnumber and so on
                    ,"parttype"
                    ,"description"
                    ,"pos_tolerance"
                    ,"neg_tolerance"
                    ,"user1"
                    ,"user2"
                    ,"user3"
                    },
       property_value[],
       /*
       PAD_SHAPE_SQUARE   square
       PAD_SHAPE_ROUND    round
       PAD_SHAPE_OCTAGON  octagon
       PAD_SHAPE_LONG     long
       PAD_SHAPE_OFFSET   offset
       PAD_SHAPE_ANNULUS  annulus (only in Supply-Layer)
       PAD_SHAPE_THERMAL  thermal (only in Supply-Layer)
       */
       padshape[] = {"S","R","O","L","T"},  // shapes - square, round, oct, long, offset
       padname,
       shapename[];

real   ang2, cx, cy, rx, ry, x, y, x1, x2, y1, y2, r, a1, a2;;

int    i,
       padcount,
       pad_is_numeric,
       max_property = 7,
       new,
       sx = 0;

// --------------------------------------------------------------------

void test(void) {
  string ref;
  int nr = fileread(ref, reffile);
  string uni;
  int nu = fileread(uni, unifile);
  dlgDialog("UNIDAT File export") {
     dlgLabel("UNIDAT File: " + unifile);
     dlgTextView(uni);
     dlgLabel("Cross reference file: " + reffile);
     dlgTextView(ref);
     dlgHBoxLayout { dlgSpacing(400); }
     dlgLabel("Fiducial library = '" + _MARKER_ + "'");
     dlgHBoxLayout {
        dlgStretch(1);
        dlgPushButton("+OK") dlgAccept();
        dlgStretch(1);
        }
     };


  return;
  }

void Header(string name)
  {
  printf(";This file is generated by %s from:\n", ULPversion);
  printf(";%s';\n", name);
  }

int search_Pad_Pin(string name, string pad) {
   for (int pin = 0; pin < PinPoints; pin++) {
      if (pa[pin] == name && pc[pin] == pad){
         break;
         }
      }
   if (pin == PinPoints) pin = -2;
   return pin;
   }

// --------------------------------------------------------------------

real u2u(int x) { // resolution 1/100 mm
   x = round(x * 100)/100;
   return u2mm(x);  // if mm
  }

real u2ang(real x) {
  if (x > 360)
     x = x -360;
  x = round(x * 10)/10;
  return x;
  }

//-----------------------------------------------------
void rot(real alfa, real xt, real yt) { // change if finer rotation possible
  if (alfa == 0) {
     x = xt; y = yt;
     }
  else {
    real rad = PI / 180 * alfa;
    real RADIUS = sqrt(xt * yt);
    x + (cos(rad) * RADIUS);
    y + (sin(rad) * RADIUS);
  }
  x = round(x * 100)/100; y = round(y * 100)/100; // resolution 1/100 mm
  return;
  }

//-----------------------------------------------------
string padtype(UL_CONTACT C) { // name contains shape SROXY or SM for SMD
  string s;                    // diam_drill (in 1/100mm) or smdx_y in (1/100 mm)
  real pdi, pdr, sx, sy;       // e.g. SR_140_80 or SM_100_120
  if (C.pad) {
     pdi = round(u2u(C.pad.diameter[bottom]) * 100);
     pdr = round(u2u(C.pad.drill) * 100);                  // not used
     sprintf(s, "P%s_%03.0f", padshape[C.pad.shape[bottom]], pdi); // pdr could be used, too
     }
  if (C.smd) {
     sx = round(u2u(C.smd.dx) * 100);
     sy = round(u2u(C.smd.dy) * 100);
     sprintf(s, "SM_%03.0f_%03.0f", sx, sy);
     }
  return s;
  }
//-----------------------------------------------------
real padrotation(UL_CONTACT C) {
  if (C.pad) return C.pad.angle;
  if (C.smd) return C.smd.angle;
}
//-----------------------------------------------------
int padelongation(UL_CONTACT C) {
  int e = 0;
  if (C.pad) e = C.pad.elongation;
  return e;
}
//-----------------------------------------------------
string viatype(UL_VIA V) {
  string s;                    // diam_drill (in 1/100mm)
  real pdi, pdr, sx, sy;       // e.g. SR_140_80 or SM_100_120
  pdi = round(u2u(V.diameter[bottom]) * 100);
  pdr = round(u2u(V.drill) * 100);                      // not used
  sprintf(s, "P%s_%03.0f", padshape[V.shape[bottom]], pdi);     // pdr could be used, too
  return s;
  }
//-----------------------------------------------------
void print_pad_shape(string s, real r, int e) {
  real x, y, w, wx, wy, a, b, c, d, elong = e/100;

  string s1;
  sprintf(s1, "%s.%s", strsub(s, 3, 1), strsub(s, 4, 2));
  x = strtod(s1);
  if (strsub(s, 1, 1) == padshape[0]) { // look for padshape S|R|O|L|T
     w = x/2;
     printf("L (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g)\n",
                 w, w,   w,-w,  -w,-w,  -w, w,   w, w);
     }
  if (strsub(s, 1, 1) == padshape[1]) {
     printf("C 0,0,%s.%s\n", strsub(s, 3, 1), strsub(s, 4, 2));
     }
  if (strsub(s, 1, 1) == padshape[2]) {
     if (!disp_oct_as_round) {
        x = x/2;
        w = x/2;
        printf("L (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g)\n",
                    w, x,   x, w,   x,-w,   w,-x,  -w,-x,  -x,-w,  -x, w,  -w, x,   w, x);
        }
     else {
        printf("C 0,0,%s.%s\n", strsub(s, 3, 1), strsub(s, 4, 2));
        }
     }
  if (strsub(s, 1, 1) == padshape[3]) { // long
     a = 3*x/8; b = x/2*elong; c = x/8; d = x/4; // dimension ratio x:y = elong
     printf("L (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g)\n",
                 a,d, b,c, b,-c, a,-d, -a,-d, -b,-c, -b,c, -a,d, a,d);
     }
  if (strsub(s, 1, 1) == padshape[4]) { // offset
     a = 3*x/8; b = x/2*elong; c = x/8; d = x/4; // dimension ratio x:y = elong
     printf("L (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g)\n",
                 a,d, b,c, b,-c, a,-d, -a,-d, -b,-c, -b,c, -a,d, a,d);

     }
  if (strsub(s, 1, 1) == "M") {         // look for padshape M = SMD
     sprintf(s1, "%s.%s", strsub(s, 7, 1), strsub(s, 8, 2));
     y = strtod(s1);
     wx = x/2; wy = y/2;
     printf("L (%g,%g) (%g,%g) (%g,%g) (%g,%g) (%g,%g)\n",
                wx, wy,  wx,-wy,  -wx,-wy,  -wx, wy,  wx, wy);
     }
  }
//-----------------------------------------------------
void center(UL_ELEMENT E) { // returns cx, cy
  real xmin, xmax, ymin, ymax;
  xmin = u2u(E.x); xmax = xmin;
  ymin = u2u(E.y); ymax = ymin;
  E.package.wires(W){

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -