I want to be able to write a script to mass change all the libraries that a project depends on in order to make better B.O.M. Bill Of Materials. The following script lists the libraries in the project directory. It writes the names of the libraries with full path to a text file named: ListOfLibraries.txt
//—— Get the Project Path ——//
string Project_Path;
string get_project_path() {
if (board) board(B) return(filedir(B.name));
if (schematic) schematic(S) return(filedir(S.name));
if (library) library(L) return(filedir(L.name));
}
Project_Path = get_project_path();
dlgMessageBox(Project_Path, "+Yes", "No","Maybe");
string F[];
int i;
int n = fileglob(F, Project_Path + "*.lbr"); //– Get file names with .lbr extension in project directory
output(Project_Path + "ListOfLibraries.txt", "wt"){ for(i=0;i<n;i++){ printf(F[i] + "\n");} } //– Write all the .lbr file names to text file
string ResultOfLibCount;
sprintf(ResultOfLibCount, "The number of libraries is %d", n);
dlgMessageBox(ResultOfLibCount, "+Yes", "No","Maybe");
fileglob stuffs an array with the files that satisfy the condition specified by the string supplied.
0 Comments