📄 unidat-fiducials.ulp
字号:
if (W.layer == LAYER_TPLACE || W.layer == LAYER_BPLACE) {
xmin = min(u2u(W.x1),xmin);
xmin = min(u2u(W.x2),xmin);
ymin = min(u2u(W.y1),ymin);
ymin = min(u2u(W.y2),ymin);
xmax = max(u2u(W.x1),xmax);
xmax = max(u2u(W.x2),xmax);
ymax = max(u2u(W.y1),ymax);
ymax = max(u2u(W.y2),ymax);
}
}
cx = (xmin+xmax)/2; cy = (ymin+ymax)/2;
}
//-----------------------------------------------------
string smd_info(UL_ELEMENT E) {
E.package.contacts(C) {
if (C.pad)
return "THT";
else
return "SMD";
}
return "SMD"; // in case it has no electrical connection (e.g. fiducial)
}
//---------------------------------------------------
void get_user_parameters(UL_ELEMENT E) { // assign property_values[]
string s, pname, pvalue;
int pos, len;
if (project.schematic) {
project.schematic(S) {
S.parts(P) {
if (P.name == E.name) {
P.instances(I) {
for (i = 0; i <= max_property; i++) { // clear properties
property_value[i] = "";
}
I.gate.symbol.texts(T) {
if (strlwr(layer_name[T.layer]) == user_layer_name) {
s = T.value;
len = strlen(s);
pos = strstr(s, property_assign_char);
if (pos > 0) {
pname = strsub(s, 0, pos);
pvalue = strsub(s, pos+1, len - pos);
i = 0;
while (i <= max_property) {
if (property[i] == strlwr(pname)) {
property_value[i] = pvalue;
}
i++;
}
}
}
}
}
}
}
}
}
else { // no schematic -> no properties
for (i = 0; i <= max_property; i++) { // clear properties
property_value[i] = "";
}
}
}
//---------------------------------------------------
string signame(string elname, string padname) {
string s = "";
board(B) {
B.signals(S) {
S.contactrefs(C) {
if (C.element.name == elname) {
if (C.contact.name == padname) {
s = S.name;
}
}
}
}
}
return s;
}
//////////////////////////////////////////////////////
void create_info () {
int t = time();
printf ("%%%%%%INFO\n");
printf ("DATE=%02d.%02d.%02d %02d:%02d:%02d\n",
t2day(t),t2month(t)+1,t2year(t),t2hour(t),t2minute(t),t2second(t));
printf ("DELIMITER=|\n");
printf ("UNITS=MM\n");
printf ("UNIDAT_VERSION=1.2\n"); // Unidat Software Version
printf ("JOB_NAME=%s\n", jobname);
//printf ("JOB_REVISION=%s\n", jobrevision); // get from somewhere
printf ("NR_OF_PCBOARDS=1\n");
printf ("TOP_LAYER=1\n");
printf ("BOTTOM_LAYER=16\n");
printf ("CADSOFTWARE=EAGLE %d.%d\n", EAGLE_VERSION, EAGLE_RELEASE);
// schematic information could be added here
// e.g. create script file which creates a postscript schematic file
}
//////////////////////////////////////////////////////
void outline(UL_BOARD B) {
printf ("\n%%%%OUTLINE\n");
printf ("%%GRAFITEM\n");
B.wires(W) {
if(W.curve) {
if (W.layer == LAYER_DIMENSION) {
printf("A %g,%g,%g,%.1f,%.1f\n",
u2u(W.arc.xc),u2u(W.arc.yc),u2u(W.arc.radius),u2ang(W.arc.angle1),u2ang(W.arc.angle2 - W.arc.angle1));
}
}
else {
if (W.layer == LAYER_DIMENSION) {
printf("L (%g,%g) (%g,%g)\n", u2u(W.x1), u2u(W.y1), u2u(W.x2), u2u(W.y2));
}
}
}
B.circles(C) {
if (C.layer == LAYER_DIMENSION) {
printf("C %g,%g,%g\n", u2u(C.x), u2u(C.y), u2u(C.radius));
}
}
B.elements(E) {
E.package.wires(W) {
if(W.curve) {
if (W.layer == LAYER_DIMENSION) {
printf("A %g,%g,%g,%.1f,%.1f\n",
u2u(W.arc.xc),u2u(W.arc.yc),u2u(W.arc.radius),u2ang(W.arc.angle1),u2ang(W.arc.angle2 - W.arc.angle1));
}
}
else {
if (W.layer == LAYER_DIMENSION) {
printf("L (%g,%g) (%g,%g)\n", u2u(W.x1), u2u(W.y1), u2u(W.x2), u2u(W.y2));
}
}
}
}
printf ("%%ENDGRAFITEM\n");
}
//////////////////////////////////////////////////////
void fiducials(UL_BOARD B) {
printf ("\n%%%%FIDUCIALS\n");
B.elements(E) {
if (E.package.library == _MARKER_) {
printf("%s|||",E.name); // NAME
printf("%g|%g|",u2u(E.x), u2u(E.y)); // X,Y
printf("%.1f|",u2ang(E.angle)); // ROTATION
if (E.mirror) // ASSEMBLY SIDE
printf("bottom|");
else
printf("top|");
printf("%s|",E.package.name); // SHAPE (e.g. SH_IC1) // special version
printf("\n");
}
}
}
//////////////////////////////////////////////////////
void component(UL_BOARD B) {
printf ("\n%%%%COMPONENT\n");
B.elements(E) { // add exclusion for el. w/o package!!!
if (E.package.library != _MARKER_) {
if (E.package) {
get_user_parameters(E); // get user defined prop. from spec. layer
printf("%s|",E.name); // NAME
printf("%s|",property_value[0]); // PARTNUMBER
printf("|"); // PARTCODE not used
printf("%s|",property_value[1]); // PARTTYPE
printf("%s|",property_value[2]); // PARTDESCRIPTION
printf("%s|",E.package.name); // SHAPE (e.g. SH_IC1) // special version
printf("%.1f|",u2ang(E.angle)); // ROTATION
if (E.mirror) // ASSEMBLY SIDE
printf("bottom|");
else
printf("top|");
printf("%g|%g|",u2u(E.x), u2u(E.y)); // X,Y
center(E);
printf("%g|%g|",cx, cy); // X,Y of center point
printf("%s|", smd_info(E)); // SMD or Through-hole
printf("|0|"); // VALUE = 0
printf("%s|",property_value[3]); // POS TOLERANCE
printf("%s|",property_value[4]); // NEG TOLERANCE
printf("%s|",property_value[5]); // USER1
printf("%s|",property_value[6]); // USER2
printf("%s",property_value[7]); // USER3
printf("\n");
}
}
}
}
//////////////////////////////////////////////////////
void other_drillings(UL_BOARD B) {
printf ("\n%%%%OTHER_DRILLINGS\n");
}
//////////////////////////////////////////////////////
void component_pin(UL_BOARD B) {
printf ("\n%%%%COMPONENT_PIN\n");
B.elements(E) {
if (E.package.library != _MARKER_) {
pad_is_numeric = 1;
E.package.contacts(C) { // test if name numeric
padname = C.name;
for (i = 0; padname[i]; ++i) {
if (!isdigit(padname[i])) {
pad_is_numeric = 0;
}
}
}
padcount = 1;
rx = u2u(E.x); ry = u2u(E.y); // origin of package
E.package.contacts(C) {
printf("%s|",E.name); // COMP. NAME
if (pad_is_numeric) {
printf("%s|", C.name); // PADNR
}
else {
printf("%d|", padcount);
padcount++;
}
int pin = search_Pad_Pin(E.name, C.name);
if (sheetload) {
if (pin < 0) {
printf("|"); // Gate not placed
}
else {
printf("%s|", pn[pin]); // PIN NAME
}
}
else {
printf("no-sheet|");
}
printf("%s|", signame(E.name, C.name)); // NET NAME
x1 = u2u(C.x)-rx; y1 = u2u(C.y)-ry;
rot(E.angle, x1, y1); // get x,y
printf("%g|%g|", x, y); // REL. POSITION OF PADS
if (C.pad) {
printf("%s|", padtype(C)); // PADTYPE TOP
printf("%.1f|", u2ang(E.angle)); // PAD ORIENTATION TOP
printf("%s|", padtype(C)); // PADTYPE BOTTOM
printf("%.1f", u2ang(E.angle)); // PAD ORIENTATION BOTTOM
}
if (C.smd) {
if (C.smd.layer == LAYER_TOP) {
printf("%s|", padtype(C)); // PADTYPE TOP
printf("%.1f|", u2ang(E.angle)); // PAD ORIENTATION TOP
printf("|"); // BOTTOM empty
}
else {
printf("||"); // TOP empty
printf("%s|", padtype(C)); // PADTYPE BOTTOM
printf("%.1f", u2ang(E.angle)); // PAD ORIENTATION BOTTOM
}
}
printf("\n");
}
}
}
}
//////////////////////////////////////////////////////
void pad(UL_BOARD B) {
string t[];
int i, j = 0, new;
printf ("\n%%%%PAD\n");
B.elements(E) {
if (E.package.library != _MARKER_) {
E.package.contacts(C) {
new = 1; // padtype not generated yet
for (i = 0; t[i]; i++) {
if (t[i] == padtype(C))
new = 0; // padtype exists
}
if (new) {
t[j] = padtype(C);
j++;
printf("PAD=%s\n", padtype(C));
printf("%%GRAFITEM\n");
printf("FC 9,0,0,0\n");
print_pad_shape(padtype(C), padrotation(C), padelongation(C));
printf("%%ENDGRAFITEM\n");
}
}
}
}
B.signals(S) {
S.vias(V) {
new = 1;
for (i = 0; t[i]; i++) {
if (t[i] == viatype(V))
new = 0; // padtype exists
}
if (new) {
t[j] = viatype(V);
j++;
printf("PAD=%s\n", viatype(V));
printf("%%GRAFITEM\n");
printf("FC 9,0,0,0\n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -