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.
if (schematic) schematic(S) //This nested set of loops cycle through all the parts and increment the count each pass through
sprintf(result, "The parts count is %d", cnt);
dlgMessageBox(result, "+Yes", "No","Maybe"); // display the parts count in a dlgMessageBox