This program demonstrates how you access the Schematic object with an Eagle PCB User Language Program – ULP.


dlgMessageBox("Do you want to count the parts?","Yes","No","Maybe");                       //opens a dialog box: no matter what you answer it will count the parts.  

int cnt=0;
if (schematic) schematic(S)                                                                //This nested set of loops cycle through all the parts and increment the count each pass through
  {
    S.parts(P)
      {
        P.instances(E)                                                             
          {
            cnt++;
          }
      }
  }

string result;
sprintf(result, "The parts count is %d", cnt);
dlgMessageBox(result, "+Yes", "No","Maybe");                                               // display the parts count in a dlgMessageBox
  
exit(0); 

Categories: Eagle PCBElectronics

Leave a Reply

Your email address will not be published. Required fields are marked *