-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoplace_v3.ulp
56 lines (52 loc) · 2.12 KB
/
autoplace_v3.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
/* Simple autoplace ulp based upon component position in schematic
* this ULp was origianlly written by one of the CADSOFT team I believe
* apologies for lack of full reference and acknoledgement
* run the ULP in the sch window and run place.scr in BRD
* changing the scale parameter will produce tighter/looser grouping
* Ideally stick in a pop-up window to select scale and x/y offset at some time
*/
string c,cmd;
real scale = 0.75;
int HasPins,
IsSupplySymbol,
Px, Py, xoffset, yoffset,
ix,
GridDist = 50,
ShOffset = 3000,
y_ShOffset = 4000,
x_ShOffset = 7500;
output("place.scr") {
if (schematic) schematic(SCH) {
cmd+= "board; \n";
sprintf(c, "Grid mil 50;\n");
cmd+= c;
SCH.sheets(S) {
S.parts(P) {
ix = 0;
P.instances(I) {
if (ix==0) {
Px = round(scale*(u2mil(I.x)) / GridDist) * GridDist;
Py = round(scale*(u2mil(I.y)) / GridDist) * GridDist;
}
HasPins = 0;
IsSupplySymbol = 0;
I.gate.symbol.pins(PIN) {
if ((PIN.direction == PIN_DIRECTION_SUP))
IsSupplySymbol = 1;
HasPins = 1;
}
ix++;
}
if (HasPins && !IsSupplySymbol) {
xoffset = x_ShOffset*trunc(0.5*(S.number-1));
yoffset = y_ShOffset*2*frac(0.5*(S.number-1));
sprintf(c, "Move %s (%d %d);\n", P.name, Px+xoffset, Py+yoffset);
cmd+= c;
}
} // end parts
} // end sheets
printf("GRID LAST;\n");
printf("RATSNEST;\n");
}
}
exit(cmd);