For my BOM ULP I want to use attribute fields that you can see here.  To do this I need to know how to read an attribute.  The code snippet below does that.  The test attribute name is FUDGE and the test value is VANILLA.   To read attributes you need to know what they are called as you will see below.


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.   It is a joke.


//—— Get the ULP Path ——//

string ULP_Path;
char bkslash = '/';
int pos = strrchr(argv[0], bkslash);

  if (pos >= 0) 
    { 
      ULP_Path = strsub(argv[0], 0, pos + 1);
    }
    

//—— This is the loop that gets the parts and writes to file —–//

int cnt=0;

output(ULP_Path + "ListOfParts.txt", "wt")
{  
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)                                                             
          { 
            printf(E.name + "     " + E.value + "     " + P.attribute[“FUDGE”] + "\n");
            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

0 Comments

Leave a Reply

Avatar placeholder

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