forked from robertstarr/ulp_user
-
Notifications
You must be signed in to change notification settings - Fork 0
/
place50.ulp
68 lines (61 loc) · 1.94 KB
/
place50.ulp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* Very simple Autoplacer
*
* -This EAGLE User Language Program produces a script
* file that can be used to place the elements of the
* current board to the position in the schematic.
* This is more useful than the stupid placing of eagle.
* -Useful for the very first placing of the parts.
* -run this ulp in the schematic
* -execute the resulting script "place.src" in the board
* -will put parts with more than one instance (e.g. gates) to
* the position of the last instance
* -Very useful for analog designs.
*
* [email protected] (Matthias Weingart)
* IngBuero fuer wiss. Geraeteentw.
* We have the solution for your embedded electronics.
*
*/
real GridDist = 50.0; // in Mil, can be changed to other values
real Scale = 0.5; //because Schematics (A3) are much bigger
//than boards (Euroformat) you can select a scale here
string fileName;
real snap(int n) // returns next grid point
{
return round(u2mil(n)*Scale / GridDist) * GridDist;
}
if (schematic)
{
schematic(SCH)
{
fileName = filesetext(SCH.name, "_PlaceInBRD~~~.scr");
output(fileName, "wtD")
{
int Xmax;
int XOffset;//sheet offset
Xmax = 0;
printf("GRID MIL %f;\n", GridDist);
SCH.sheets(S)
{
XOffset = round ( 1.05 * Xmax);
S.parts(P)
{
P.instances(I)
{
if (P.device.package)
{
printf("MOVE %s (%f %f);\n", P.name, snap(I.x+XOffset), snap(I.y) );
if (I.x > Xmax)
{
Xmax = I.x;
}
}
}
}
}
printf("GRID LAST;\n");
printf("RATSNEST;\n");
}
}
}