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

📄 import-ultiboard-ddf.ulp

📁 老外的PCB设计软件,是免费的.可以上网更新.
💻 ULP
📖 第 1 页 / 共 4 页
字号:
  int Tracelayer = strtol(read(' ', 0));
  real Tracecoord1 = strtod(read(cr, 0));
  n++;
  do {
     string Tracec2 = read(' ', 0);
     if (Tracec2 == ";") { n++; break;}
     real Tracecoord2 = strtod(Tracec2);
     real Tracecoord3 = strtod(read(' ', 0));
     int TraceNetnr = strtol(read(' ', 0));
     int TraceCode = strtol(read(' ', 0));
     int TraceType = strtol(read(' ', 0));
     int TraceOrient = strtol(read(' ', 0));
     route(Tracelayer, Tracecoord1, Tracecoord2, Tracecoord3, TraceNetnr, TraceCode, TraceType, TraceOrient);
     } while (c[n]);
   return ;
   }
void LVector() {
   n++;
   int    VectLayer     = strtod(read(' ', 0));
   real   VectX1        = strtol(read(' ', 0));
   real   VectY1        = strtol(read(' ', 0));
   real   VectX2        = strtol(read(' ', 0));
   real   VectY2        = strtol(read(' ', 0));
   int    VectNetnr     = strtod(read(' ', 0));
   int    VectTraceCode = strtod(read(' ', 0));
   string VectTraceType = read(cr, 1);
   rwire(VectNetnr, VectLayer, VectX1, VectY1, VectX2, VectY2);
   return ;
   }
void LArc(void) {
   n++;
   int    ArcLayer     = strtod(read(' ', 0));
   real   ArcX         = val2mil(read(' ', 0));
   real   ArcY         = val2mil(read(' ', 0));
   real   ArcRadius    = val2mil(read(' ', 0));
   real   Arc1         = strtol(read(' ', 0)) / rotatemultiple;
   real   Arc2         = strtol(read(' ', 0)) / rotatemultiple;
   int    ArcNetnr     = strtod(read(' ', 0));
   int    ArcTraceCode = strtod(read(' ', 0));
   string ArcTraceType = read(cr, 1);
   arcDraw( ArcLayer, ArcX, ArcY, ArcRadius, Arc1, Arc2, ArcNetnr, ArcTraceCode, ArcTraceType);
   return ;
   }
string polygonstart(void) {
   string polygx1 = read(' ', 0);
   string polygy1 = read(' ', 0);
   string polystart;
   sprintf(polystart, "(%s %s) ", format(val2mil(polygx1)), format(val2mil(polygy1)));
   return polystart;
   }
void LPolygon(void) {
   n++;
   int    PolyLayer     = strtod(read(' ', 0));
   int    PolyNetnr     = strtod(read(' ', 0));
   string PolyPattern   = read(' ', 0);
   string PolyDummy     = read(' ', 0);
   int    PolyDist      = strtod(read(' ', 0));
   int    PolyCode      = strtod(read(' ', 0));
   int    PolyClearance = strtod(read(' ', 0));
   string PolyType      = read(cr, 1);
   string pld;
   sprintf(pld , "\n Layer %d\n Net %s\n Pattern %s\n Dist %d\n Code %d\n Clearance %d\n Type %s\n Dummy %s",
                     PolyLayer,
                     netname[PolyNetnr],
                     PolyPattern,
                     PolyDist,
                     PolyCode,
                     PolyClearance,
                     PolyType,
                     PolyDummy
                     );
   n++;
   polygon += "CHANGE LAYER " + refLayer[PolyLayer] + ";\n";
   polygon += "CHANGE ORPHANS ON;\n";
   polygon += "CHANGE WIDTH " + format(v2mil(nettracecode[PolyNetnr])) + ";\n";
   polygon += "CHANGE ISOLATE " + format(v2mil(PolyCode)) + ";\n";
   int fillpoly = 1;
   string polystart = polygonstart();
   polygon += "POLYGON " + "'" + netname[PolyNetnr] + "' " + polystart ;
   string TotalPolygon = "";
   do {
      string TotalPolygon = readstring(' ',  semikolon, polysepar);
      if(TotalPolygon[0] == semikolon) {
         n++;
         polygon += ";\n";
         return;
         }
      if(TotalPolygon[0] == polysepar) {
         n+= 3;
         fillpoly = 0;
         polystart = polygonstart();
         if (fillpoly) {
            polygon += ";\nPOLYGON " + "'" + netname[PolyNetnr] + "' " + polystart ;
            }
         TotalPolygon = "";
         }
      else {
         if (fillpoly) {
            polygon += TotalPolygon;
            TotalPolygon = "";
            polygon += polystart;
            }
         polystart = polygonstart();
         }
      } while (c[n]);
   }
void ViaList(void) {
   n++;
   string via;
   int ViaX = strtod(read(cr, 1));
   do {
      string VY = read(' ', 0);
      if (VY == ";") break;
      int    ViaY      = strtod(VY);
      int    ViaNetnr       = strtod(read(' ', 0));
      int    ViaPadCode     = strtod(read(' ', 0));
      string ViaPadSetting  = read(' ', 0);
      real   ViaPadRotation = strtol(read(' ', 0)) / 32;
      int    ViaPadShift    = strtod(read(' ', 0));
      string ViaIndex = read(' ', 0);
      string ViaGLueFlag = read(';', 1);
      sprintf(via , "CHANGE SHAPE ROUND;\n");
      brd += via;
      sprintf(via , "CHANGE DIAMETER %s;\n", format(v2mil( pad2bottomY[ViaPadCode])) );
      brd += via;
      sprintf(via , "CHANGE DRILL %s;\n", format(v2mil( drillcode[ViaPadCode])) );
      brd += via;
      sprintf(via , "VIA '%s' (%s %s);\n", netname[ViaNetnr], format(v2mil(ViaX)), format(v2mil(ViaY)) );
      brd += via;
      } while (c[n]);
   return ;
   }
void Text(void) {
   n++;
   string text;
   real TextX         = strtod(read(' ', 0));
   real TextY         = strtod(read(' ', 0));
   real TextHeight    = strtod(read(' ', 0));
   real TextWidth     = strtod(read(' ', 0));
   real TextThick     = strtod(read(' ', 0));
   real TextRotation  = strtod(read(' ', 0)) / rotatemultiple;
   int TextLayer      = strtod(read(' ', 0));
   string TextString  = readTstring();
   real strgLength2 = stringLength( TextString, TextHeight) / 2;
   sprintf(text, "CHANGE SIZE %s\n", format(v2mil(TextHeight)) );
   brd += text;
   sprintf( text, "CHANGE LAYER %s;\n", refLayer[TextLayer]);
   brd += text;
   int ro = TextRotation;
   if (TMrefLayer[TextLayer] == "M") {
      strgLength2 = (strgLength2 * -1);
      }
   switch (ro) {
      case   0 : sprintf(text , "TEXT '%s' %sR%.0f (%s %s);\n",
                         TextString, TMrefLayer[TextLayer], TextRotation,
                         format(v2mil(TextX - (strgLength2))), format(v2mil(TextY - (TextHeight / 2))) );
             break;
      case  90 : sprintf(text , "TEXT '%s' %sR%.0f (%s %s);\n",
                         TextString, TMrefLayer[TextLayer], TextRotation,
                         format(v2mil(TextX + (TextHeight / 2))), format(v2mil(TextY - (strgLength2))) );
             break;
      case 180 : sprintf(text , "TEXT '%s' %sR%.0f (%s %s);\n",
                         TextString, TMrefLayer[TextLayer], TextRotation,
                         format(v2mil(TextX + (strgLength2))), format(v2mil(TextY + (TextHeight / 2))) );
             break;
      case 270 : sprintf(text , "TEXT '%s' %sR%.0f (%s %s);\n",
                         TextString, TMrefLayer[TextLayer], TextRotation,
                         format(v2mil(TextX - (TextHeight / 2))), format(v2mil(TextY + strgLength2)) );
             break;
      }
   brd += text;
   return ;
   }
void RecTechnology(void) {
  n++;
  switch (c[n]) {
     case    'P' : padset();
                     break;
     case    'T' : TraceCode();
                     break;
     case    'C' : Drilltolerance();
                     break;
     case    'D' : DrillCode();
                     break;
     case    '0' : PadDefinitionInner();
                     break;
     case    '1' : PadDefinitionTop();
                     break;
     case    '2' : PadDefiniBottom();
                     break;
     case    'S' : WaveSolderDir();
                     break;
     }
   return ;
  }
void SubRecordL(void) {
  n++;
  switch (c[n]) {
     case    'T' : LTrace();
                     break;
     case    'V' : LVector();
                     break;
     case    'A' : LArc();
                     break;
     case    'P' : LPolygon();
                     break;
     }
   return ;
   }
void Record(void) {
  n++;
  switch (c[n]) {
     case    'P' : Headerfield();
                     break;
     case    'T' : RecTechnology();
                     break;
     case    'S' : ShapeDef();
                     break;
     case    'N' : NetDef();
                     break;
     case    'C' : ComponentDef();
                     break;
     case    'L' : SubRecordL();
                     break;
     case    'V' : ViaList();
                     break;
     case    'X' : Text();
                     break;
  }
  return ;
}
void BRDTrailer(void) {
   printf("CHANGE LAYER 20;\n");
   printf("SET WIRE_BEND 0;\n");
   printf("WIRE 0 (%s %s) (%s %s) (%s %s) ;\n",
                 format(v2mil(boardoutline[1])),
                 format(v2mil(boardoutline[2])),
                 format(v2mil(boardoutline[3])),
                 format(v2mil(boardoutline[4])),
                 format(v2mil(boardoutline[1])),
                 format(v2mil(boardoutline[2]))
                  );
   printf("CHANGE SIZE 50;\n");
   real tx;
   if (boardoutline[1] < boardoutline[3]) tx = boardoutline[1];
   else tx = boardoutline[3];
   real ty;
   if (boardoutline[2] > boardoutline[4]) ty = boardoutline[2];
   else ty = boardoutline[4];
   int yy = 75;
   printf("# 'ULTIBOARD - %s Version %s Revision %s' (%s %s);\n", costomer, versionnumb, revisionnum, format(v2mil(tx)) ,format(v2mil(ty) + yy) );
   yy += 75;
   printf("# 'with import filter : %s %s' (%s %s);\n", filter, Version, format(v2mil(tx)) ,format(v2mil(ty) + yy) );
   yy += 75;
   printf("# 'converted from ULTIBOARD-DDF file : %s at %s' (%s %s);\n", ddffile, t2string(time()), format(v2mil(tx)) ,format(v2mil(ty) + yy) );
   yy += 75;
   printf("# '%s' (%s %s);\n", EAGLE_SIGNATURE, format(v2mil(tx)) ,format(v2mil(ty) + yy) );
   yy += 75;
   }
void sign() {
   printf("# %s\n", EAGLE_SIGNATURE);
   printf("# Script converted from ULTIBOARD-DDF file : %s at %s\n", ddffile, t2string(time()) );
   printf("# with %s\n\n", filter );
   return;
   }
void LBRdescript(void) {
   printf("Description 'Library converted from <b>ULTIBOARD-DDF file</b> :<p> \\n\\\n %s at %s <p>\\n\\\n with import filter : %s';\n", ddffile, t2string(time()), filter );
   }
void ULPhelp(void) {
   dlgDialog("Import ddf help") {
      dlgStretch(0);
      dlgHBoxLayout {
         dlgSpacing(500);
         }
      dlgStretch(0);
      dlgLabel(usage, 1);
      dlgStretch(0);
      dlgHBoxLayout {
         dlgStretch(0);
         dlgPushButton("+&OK") dlgAccept();
         dlgStretch(0);
         dlgPushButton("-&Cancel") {dlgReject(); exit(0);}
         dlgStretch(1);
         dlgPushButton("&Version Info") dlgMessageBox(ULTIBoardinfo, "OK");
         dlgStretch(0);
//         dlgPushButton("Hilf&e") dlgMessageBox(InfoDE, "OK");
//         dlgStretch(0);
         dlgPushButton("&Help") dlgMessageBox(InfoUS, "OK");
         dlgStretch(0);
         }
      dlgStretch(1);
      };
   }
void main(void) {
   if (board) board(B) {
      char bkslash = '/';
      int pos = strrchr(argv[0], bkslash);
      if (argv[1] == "") ULPhelp();
      if (argv[1] == "PASS2") importpass2();
      else {
         if (pos >= 0) {
            ulp_path = strsub(argv[0], 0, pos + 1);
            }
         filter = strsub(argv[0], pos + 1);
         fileName = dlgFileOpen("Select a DDF-File", "", "*.ddf");
         }
      if (!fileName) exit (0);
      string changetextfile = filesetext(fileName, tmpchtxtfile);
      string scriptfile = filesetext(fileName, tmpextfile);
      pos = strrchr(fileName, bkslash);
      ddffile = strsub(fileName, pos + 1);
      nBytes = fileread(c, fileName);
      output(scriptfile, "wt") {
         sign();
         printf("OPEN '%s';\n", filesetext(fileName, ".lbr"));
         LBRdescript();
         do {
            switch (c[n]) {
               case    0:
                           break;
               case  '*':  Record();
                           break;
               case  ';':  break;
               case   10:
                           break;
               case   12:
                           break;
               case   13:
                           break;
               case   27:  cmd += "\nEscape\n";
                           break;
               default:    test(c[n]);
                           break;
               }
            n++;
            } while (n <= nBytes);
         printf("SET UNDO_LOG ON;\n");
         printf("WRITE\n");
         printf("CLOSE;\n");
         sign();
         printf("EDIT '%s'\n", filesetext(fileName, ".brd") );
         printf("SET VECTOR_FONT ON;\n");
         printf("%s", scriptheader());
         printf("USE -*;\n");
         printf("USE '%s';\n",filesetext(fileName, ".lbr") );
         printf("\n%s\nWINDOW FIT;\n", brd);
         printf("%s\n", GenNet() );
         printf("%s\n", cmdroute);
         printf("%s\n", arcscript);
         if (polygon) printf("%s\n", polygon);
         printf("RATSNEST;\n");
         BRDTrailer();
         printf("SET UNDO_LOG ON;\n");
         printf("WINDOW FIT;\n");
         printf("WRITE;\n");
         printf("RUN '%s' 'PASS2' '%s';\n", argv[0], changetextfile);
         }
      output(changetextfile, "wt") {
         printf("%s\n", cmdchname);
         }
      string ecmd = "SCRIPT '" + scriptfile + "';\n";
      string r;
      sprintf(r, "REMOVE '%s';\n", scriptfile);
      ecmd += r;
      sprintf(r, "REMOVE '%s';\n", filesetext(changetextfile, "$" + tmpextfile) );
      ecmd += r;
      sprintf(r, "REMOVE '%s';\n", changetextfile);
      ecmd += r;
      exit (ecmd);
      }
   else {
      dlgMessageBox( "ERROR:\nStart this ULP from a Board", "&OK") ;
      }
   }

⌨️ 快捷键说明

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