//Auswahl auf ZielStartSpalteZeile "moven"
var myDoc = app.documents[0];
with(myDoc.viewPreferences){
rulerOrigin = RulerOrigin.PAGE_ORIGIN;
horizontalMeasurementUnits = MeasurementUnits.millimeters;
verticalMeasurementUnits = MeasurementUnits.millimeters;
}
//myDoc.gridPreferences.baselineDivision
var allX1Bounds = new Array(); //Leerer Array für die x1Bounds der selection
var allY1Bounds = new Array(); //Leerer Array für die Y1Bounds der selection
//alle Zeilen, alle Spalten
var theGridLines = new Array(22.487,26.06,29.633,33.206,36.779,40.352,43.925,47.498,51.071,54.644,58.217,61.79,65.363,68.936,72.509,76.082,79.655,83.228,86.801,90.374,93.947,97.52,101.093,104.666,108.239,111.812,115.385,118.958,122.531,126.104,129.677,133.25,136.823,140.396,143.969,147.542,151.115,154.688,158.261,161.834,165.407,168.98,172.553,176.126,179.699,183.272,186.845,190.418,193.991,197.564,201.137,204.71,208.283,211.856,215.429,219.002,222.575,226.148,229.721,233.294,236.867,240.44,244.013,247.586,251.159,254.732,258.305,261.878,265.451,269.024,272.597,276.17,279.743,283.316,286.889,290.462,294.035,297.608,301.181,304.754,308.327,311.9,315.473,319.046,322.619,326.192,329.765,333.338,336.911,340.484,344.057,347.63,351.203,354.776,358.349,361.922,365.495,369.068,372.641,376.214,379.787,383.36,386.933,390.506,394.079,397.652,401.225,404.798,408.371,411.944,415.517,419.09,422.663,426.236,429.809,433.382,436.955,440.528,444.101,447.674,451.247,454.82,458.393,461.966,465.539,469.112,472.685,476.258,479.831,483.404,486.977,490.55,494.123,497.696,501.269); ///Startwerte für alle Zeilen
var theRowsLeft = new Array(11.83,66.464,121.098,175.732,230.366,285.000);
var theFrames = app.selection;
var countofSelection = theFrames.length;
//Aufruf Funktion myInput (die Abfrage)
var arraySpalteZeile = myInput ();
//hier Überprüfung der Eingabe
if ((arraySpalteZeile[1] > 5) && (arraySpalteZeile[1] < 135) && (arraySpalteZeile[0]>0) && (arraySpalteZeile[0] < 7)) {
doScript(arraySpalteZeile[0],arraySpalteZeile[1],theFrames,countofSelection);
}
else {
alert("Falsche Eingabe");
}
//arraySpalteZeile[0],= Splate -> arraySpalteZeile[1], = Zeile
function doScript(Spalte,Zeile, theFrames, countofSelection) {
var theChoiceLine = theGridLines[Zeile-1];
var theChoiceRow = theRowsLeft[Spalte-1];
///////////////////////////////////////////////////////////////////////////////////////////////// Min Y1 aller Elemente ermitteln
for (var i=0; i<countofSelection; i++) {
theBox = theFrames[i];
getY1X1Bounds(theBox);
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Elemente der Auswahl versetzen
var theYOffset = (allY1Bounds[0] - theChoiceLine);
var theXOffset = (allX1Bounds[0] - theChoiceRow);
for (var i=0; i<countofSelection; i++) {
theBox = theFrames[i];
setBounds(theYOffset,theXOffset,theBox);
}
}
function getY1X1Bounds(theBox) {
var theBounds = theBox.geometricBounds;
allY1Bounds.push(theBounds[0]);
allY1Bounds.sort(Numsort);
allX1Bounds.push(theBounds[1]);
allX1Bounds.sort(Numsort);
}
//sort fuer Zahlen
function Numsort (a, b) {
return a - b;
}
function setBounds(theYOffset,theXOffset,theBox) {
var theBounds = theBox.geometricBounds;
if((theBox.constructor.name) == "Rectangle"){
theBox.move([theBounds[1]-theXOffset,theBounds[0]- theYOffset]);
}
else if((theBox.constructor.name) == "Group"){
theBox.move([theBounds[1]-theXOffset,theBounds[0]- theYOffset]);
}
else {
theBox.geometricBounds = [theBounds[0]- theYOffset, theBounds[1]-theXOffset , theBounds[2] - theYOffset, theBounds[3]-theXOffset] ;
}
}
function myInput ()
{
var myWindow = new Window ("dialog", "Form");
var myInputGroup = myWindow.add ("group");
myInputGroup.add ("statictext", undefined, "Spalte:");
var myText = myInputGroup.add ("edittext", undefined, "1");
myText.characters = 3;
myInputGroup.add ("statictext", undefined, "Zeile:");
var myText02 = myInputGroup.add ("edittext", undefined, "6");
myText02.characters = 3;
var myButtonGroup = myWindow.add ("group");
myButtonGroup.alignment = "right";
myButtonGroup.add ("button", undefined, "OK");
myButtonGroup.add ("button", undefined, "Cancel");
if (myWindow.show () == 1) {
var inputArray = new Array ()
inputArray.push(myText.text);
inputArray.push(myText02.text);
return inputArray;
}
else {
exit ();
}
}