#usage "Convert relevant Parts from .brd Files into Library-Package\n" "
" "Makes it easier to use Bords as Parts in other " "
"
"
"
"Based on the bga_vias_brd.ulp from Jim Thurman (tlj@pcez.com)"
string HelpText =
"This ULP will generate a eagle-script file to be executed within a library."
"A Package-name can be specified, and the elements can be chosen."
"When executed within a library this package will be created."
"This makes it easy to create parts based on your boards, so you can use your boards"
"as Modules in future projects"
;
//*****************************************************************************************************************************
//*****************************************************************************************************************************
void DisplayHelp(void) {
dlgDialog("Library Merge Help") {
dlgHBoxLayout dlgSpacing(400);
dlgHBoxLayout {
dlgVBoxLayout dlgSpacing(300);
dlgTextView(HelpText);
}
dlgHBoxLayout {
dlgStretch(1);
dlgPushButton("-Close") dlgReject();
}
};
}
//******************************************************************************************************
// get file path of any file open.
//******************************************************************************************************
string get_project_path() {
if (library) library(B) return(filedir(B.name));
if (board) board(B) return(filedir(B.name));
if (schematic) schematic(B) return(filedir(B.name));
}
//**************************************************************************************************
// convert the grid unit code to text
//**************************************************************************************************
string GridUnitToString(int GridUnit) {
string str1;
switch(GridUnit) {
case GRID_UNIT_MIC: str1="mic"; break;
case GRID_UNIT_MM: str1="mm"; break;
case GRID_UNIT_MIL: str1="mil"; break;
case GRID_UNIT_INCH: str1="inch"; break;
default: str1="INVALID"; break;
}
return(str1);
}
//**************************************************************************************************
// convert the grid unit code to text
//**************************************************************************************************
real SelUnitToMM(int GridUnit,real Value) {
real Result;
string TempStr;
switch(GridUnit) {
case 0: Result=Value/1000; break;
case 1: Result=Value; break;
case 2: Result=Value*25.4/1000; break;
case 3: Result=Value*25.4; break;
default: Result=0;
}
return(Result);
}
string GetShapeName(int shapeFlag){
string Result="";
switch(shapeFlag) {
case 0:
Result="SQARE";
break;
case 1:
Result="ROUND";
break;
case 2:
Result="OCTAGON";
break;
case 3:
Result="LONG";
break;
case 4:
Result="OFFSET";
break;
case 5:
Result="ANNULUS";
break;
case 6:
Result="THERMAL";
break;
default:
Result="";
}
return(Result);
}
//*****************************************************************************************************************************
//*****************************************************************************************************************************
void main() {
int x,y,z;
int NumElements; // number of board elements
int Selected; // element selected from list
int CurrentGridUnit; // units grid set for at start of program
int SelectedNames; // number of devices selected
int SelName; // index of name selected in select list
int Units; // units selected from selection box
int SelUnit; // redisplay on select from list value
int SelectUnits[]; // units selected for each component selected
int Sigs; // number of signals on board
int SigInx[]; // index used to access board signal data after sort
int CurrentLayer; // layer currently being used
real ContactX,ContactY; // signal contact x,y
real r; // temporary
real XDisplacement,YDisplacement; // displacement of via adjusted to mm
real SelectXDisp[],SelectYDisp[]; // via displacement for selected component
real EndX,EndY; // Via final position and wire end point
real SignalWidths[]; // width of signals on board
real SignalDrills[]; // drill sizes for signals on board
real CurrentDrill; // current drill size for write out
string FileName; // file name to write to
string ElementNames[]; // elements in board
string SelectNames[]; // component names selected
string NetName; // net name for wire and via
string SignalNames[]; // signal names on board
string BoardDirectory; // board's directory
UL_ELEMENT element; // element pointer
UL_PACKAGE Pkg; // package pointer
UL_CONTACT contact; // contact pointer
int SelBoardHoles = 1;
int SelElementHoles = 1;
int SelTHDPads = 1;
int SelSMDPads = 0;
int SelBoardWires = 1;
UL_HOLE hole;
UL_WIRE wire,piece;
real PadDiameter;
real ContactDrill;
ContactDrill = 0;
real WireX1,WireY1,WireX2,WireY2; // signal contact x,y
real EndX2,EndY2;
real WireWidth;
string PackageName;
real ProgVer = 0.1;
// Via final position and wire end point
CurrentDrill=0; // no current drill
SelectedNames=0; // no selected names
SelName=-1; // no index to selected names
Units=0; // units default to microns (1/1000 mm)
if (board) { // if this was run from a board window
board (brd) { // access the board
Sigs=0;
brd.signals(Signal) { // go through the signals on board
if (Signal.name) {
SignalNames[Sigs]=Signal.name; // save signal name
SignalWidths[Sigs]=Signal.class.width; // width
SignalWidths[Sigs]/=10000;
SignalDrills[Sigs]=Signal.class.drill; // and drill size
SignalDrills[Sigs]/=10000;
Sigs++;
}
}
sort(Sigs,SigInx,SignalNames,SignalWidths,SignalDrills); // sort this data for later binary search
NumElements=0;
brd.elements(element) { // go through the elements on the board
ElementNames[NumElements++]=element.name; // get their names
}
dlgDialog("Component ID") { // make the dialog box
dlgVBoxLayout {
dlgLabel("Create script file for BGA via's. "); // general instructions
dlgLabel(" 1. First select the unit of measure.");
dlgLabel(" 2. Then select the x,y displacement of via from each pad");
dlgLabel(" 3. Then double click on one or more components to select");
dlgLabel(" 4. Then hit 'Ok'.");
}
dlgHBoxLayout {
dlgVBoxLayout {
dlgLabel("Component ID:");
dlgListBox(ElementNames,Selected) { // the component list
SelectNames[SelectedNames]=ElementNames[Selected]; // this component has been selected
SelectXDisp[SelectedNames]=XDisplacement;
SelectYDisp[SelectedNames]=YDisplacement;
SelectUnits[SelectedNames]=Units;
SelectedNames++;
SelName=-1;
}
}
dlgVBoxLayout {
dlgLabel("Selected Components");
dlgListBox(SelectNames,SelName) { // the selected components list for display or deletion
XDisplacement=SelectXDisp[SelName]; // display the current values for the selected component
YDisplacement=SelectYDisp[SelName];
SelUnit=SelectUnits[SelName];
}
dlgPushButton("Delete") {
if (SelName>=0) { // if a name was selected from the list
for (y=SelName;y