Created
April 19, 2017 19:36
-
-
Save macegr/4845678946164176da8eccf25e62a1af to your computer and use it in GitHub Desktop.
Align/distribute (origins only, for now) parts in Eagle 7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int yCenterMin = 0; | |
int yCenterMax = 0; | |
int xCenterMin = 0; | |
int xCenterMax = 0; | |
int yLeftMost = 0; | |
int xLeftMost = 0; | |
int numElements = 0; | |
// Storage for selected elements | |
UL_ELEMENT groupElements[]; | |
int xIndex[]; | |
int xLocations[]; | |
int yIndex[]; | |
int yLocations[]; | |
string outputString = ""; | |
string tempString = ""; | |
void getElements() { | |
board(B) { | |
B.elements(E) { | |
if (ingroup(E)) { | |
// Save element into array for processing later | |
groupElements[numElements] = E; | |
xLocations[numElements] = E.x; | |
yLocations[numElements] = E.y; | |
numElements++; | |
if (numElements == 1) { | |
xCenterMin = xCenterMax = E.x; | |
yCenterMin = yCenterMax = E.y; | |
} | |
// Check for min-max values | |
if (E.x >= xCenterMax) xCenterMax = E.x; | |
if (E.x <= xCenterMin) { | |
xCenterMin = E.x; | |
yLeftMost = E.y; | |
xLeftMost = E.x; | |
} | |
if (E.y >= yCenterMax) yCenterMax = E.y; | |
if (E.y <= yCenterMin) yCenterMin = E.y; | |
} | |
} | |
} | |
} | |
void processElements() { | |
UL_ELEMENT tempElement; | |
int xCoord = 0; | |
int yCoord = 0; | |
sort(numElements, xIndex, xLocations); | |
sort(numElements, yIndex, yLocations); | |
for (int i = 0; i < numElements; i++) { | |
if (argv[1] == "-vcenter") { | |
tempElement = groupElements[xIndex[i]]; | |
xCoord = tempElement.x; | |
yCoord = yLeftMost; | |
} else if (argv[1] == "-hcenter") { | |
tempElement = groupElements[xIndex[i]]; | |
xCoord = xLeftMost; | |
yCoord = tempElement.y; | |
} else if (argv[1] == "-vdistrib") { | |
tempElement = groupElements[yIndex[i]]; | |
xCoord = tempElement.x; | |
yCoord = ((yCenterMax - yCenterMin) / (numElements-1)) * i + yCenterMin; | |
} else if (argv[1] == "-hdistrib") { | |
tempElement = groupElements[xIndex[i]]; | |
xCoord = ((xCenterMax - xCenterMin) / (numElements-1)) * i + xCenterMin; | |
yCoord = tempElement.y; | |
} else { | |
exit(0); | |
} | |
sprintf(tempString,"MOVE %s (%fmm %fmm);\n", tempElement.name, u2mm(xCoord), u2mm(yCoord)); | |
outputString += tempString; | |
} | |
} | |
getElements(); | |
processElements(); | |
exit(outputString); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configuration Script | |
# | |
# This file can be used to configure the editor windows. | |
# | |
# Uncomment this if you want a set of useful default shortcuts! | |
#SCRIPT default-assign.scr; | |
# | |
BRD: | |
MENU '[] VCenter : Run align.ulp -vcenter'\ | |
'[] HCenter : Run align.ulp -hcenter'\ | |
'[] VDistrib : Run align.ulp -vdistrib'\ | |
'[] HDistrib : Run align.ulp -hdistrib'\ | |
; | |
SCH: | |
Grid Default; | |
Change Width 0.006in; | |
MENU ''; | |
LBR: | |
MENU ''; | |
DEV: | |
Grid Default; | |
MENU ''; | |
SYM: | |
Grid Default On; | |
Change Width 0.010in; | |
MENU ''; | |
PAC: | |
Grid Default On; | |
Change Width 0.005in; | |
Change Size 0.050in; | |
MENU ''; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment