Moving grid/array of squares all toward center of document??

Hi all.
We're working on a file which consists of a large array of small squares.
Wondering if there is a way to move all the squares toward the center of the document... either a script or just a method.
Any ideas or suggestions would be greatly appreciated.
Thanks!
Best,
Don

Hi Don, I just realized that the first script is only set up to handle 20 rows, so I have amended it to handle 120 rows, hope that should be enough.
function main(){
if(!documents.length) return;
var win = new Window('dialog','Space Layers');
g = win.graphics;
var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);
g.backgroundColor = myBrush;
win.p1= win.add("panel", undefined, undefined, {borderStyle:"black"});
win.g1 = win.p1.add('group');
win.g1.orientation = "row";
win.title = win.g1.add('statictext',undefined,'Space Layers');
win.title.alignment="fill";
var g = win.title.graphics;
g.font = ScriptUI.newFont("Georgia","BOLDITALIC",22);
win.g5 =win.p1.add('group');
win.g5.orientation = "row";
win.g5.alignment='fill';
win.g5.spacing=3;
win.g5.st1 = win.g5.add('statictext',undefined,'Horizontal');
win.g5.et1 = win.g5.add('edittext',undefined,'20');
win.g5.et1.preferredSize=[50,20];
win.g5.st1a = win.g5.add('statictext',undefined,'px');
win.g5.st10 = win.g5.add('statictext',undefined,'');
win.g5.st10.preferredSize=[55,20];
win.g5.st2 = win.g5.add('statictext',undefined,'Vertical');
win.g5.et2 = win.g5.add('edittext',undefined,'20');
win.g5.et2.preferredSize=[50,20];
win.g5.st2a = win.g5.add('statictext',undefined,'px');
win.g15 =win.p1.add('group');
win.g15.orientation = "row";
win.g15.alignment='fill';
win.g15.spacing=10;
win.g15.bu1 = win.g15.add('button',undefined,'Space Layers');
win.g15.bu1.preferredSize=[150,30];
win.g15.bu2 = win.g15.add('button',undefined,'Cancel');
win.g15.bu2.preferredSize=[150,30];
if(version.substr(0,version.indexOf('.'))<10){
alert("Sorry this script is only valid for Photoshop CS3 or higher");
return;
win.g5.et1.onChanging = function() {
  if (this.text.match(/[^\-\.\d]/)) {
    this.text = this.text.replace(/[^\-\.\d]/g, '');
win.g5.et2.onChanging = function() {
  if (this.text.match(/[^\-\.\d]/)) {
    this.text = this.text.replace(/[^\-\.\d]/g, '');
win.g15.bu1.onClick=function(){
if(win.g5.et1.text== ''){
    alert("No horizontal pixels entered");
    return;
if(win.g5.et2.text== ''){
    alert("No vertical pixels entered");
    return;
win.close(1);
spaceMasks(Number(win.g5.et1.text),Number(win.g5.et2.text))
win.center();
win.show()
function spaceMasks(spacingA,spacingD){
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var selectedLayers = getSelectedLayersIdx();
if(selectedLayers.length <2){
    alert("Not enough layers selected!");
    return;
var boundsList=[];
var tempbnds=[];
showFX(false);
for(var a=0;a<selectedLayers.length;a++){
var LB =getLayerBoundsByIndex(selectedLayers[a] );
boundsList.push([[selectedLayers[a]],[LB[0]],[LB[1]],[LB[2]],[LB[3]]]);
tempbnds=[];
showFX(true);
boundsList.sort(function(a,b){return a[2]-b[2];});
var row1=[]; var row2=[]; var row3=[]; var row4=[]; var row5=[];
var row6=[]; var row7=[]; var row8=[]; var row9=[]; var row10=[];
var row11=[]; var row12=[]; var row13=[]; var row14=[]; var row15=[];
var row16=[]; var row17=[]; var row18=[]; var row19=[]; var row20=[];
var row21=[]; var row22=[]; var row23=[]; var row24=[]; var row25=[];
var row26=[]; var row27=[]; var row28=[]; var row29=[]; var row30=[];
var row31=[]; var row32=[]; var row33=[]; var row34=[]; var row35=[];
var row36=[]; var row37=[]; var row38=[]; var row39=[]; var row40=[];
var row41=[]; var row42=[]; var row43=[]; var row44=[]; var row45=[];
var row46=[]; var row47=[]; var row48=[]; var row49=[]; var row50=[];
var row51=[]; var row52=[]; var row53=[]; var row54=[]; var row55=[];
var row56=[]; var row57=[]; var row58=[]; var row59=[]; var row60=[];
var row61=[]; var row62=[]; var row63=[]; var row64=[]; var row65=[];
var row66=[]; var row67=[]; var row68=[]; var row69=[]; var row70=[];
var row71=[]; var row72=[]; var row73=[]; var row74=[]; var row75=[];
var row76=[]; var row77=[]; var row78=[]; var row79=[]; var row80=[];
var row81=[]; var row82=[]; var row83=[]; var row84=[]; var row85=[];
var row86=[]; var row87=[]; var row88=[]; var row89=[]; var row90=[];
var row91=[]; var row92=[]; var row93=[]; var row94=[]; var row95=[];
var row96=[]; var row97=[]; var row98=[]; var row99=[]; var row100=[];
var row101=[]; var row102=[]; var row103=[]; var row104=[]; var row105=[];
var row106=[]; var row107=[]; var row108=[]; var row109=[]; var row110=[];
var row111=[]; var row112=[]; var row113=[]; var row114=[]; var row115=[];
var row116=[]; var row117=[]; var row118=[]; var row119=[]; var row120=[];
var arrayNumber =1;
var TOP =Number(boundsList[0][2]);
for(var f =0;f<boundsList.length;f++){
if(TOP > (boundsList[f][2]-50) && boundsList[f][2] < (boundsList[f][2]+50)){
  eval("row" +arrayNumber).push(boundsList[f]);
  }else{
            TOP =Number(boundsList[f][2]);
   arrayNumber++;
   eval("row" +arrayNumber).push(boundsList[f]);
for(var d=0;d<arrayNumber;d++){
eval("row" +(d+1)).sort(function(a,b){return a[1]-b[1];});
if((row1.length*arrayNumber) != boundsList.length){
alert("Unable to distribute this selection of layers!");
return;
for(var l=0;l<arrayNumber;l++){
var leftAnchor =Number(eval("row"+(l+1))[0][3]);
for(var a = 1;a<eval("row"+(l+1)).length;a++){
makeActiveByIndex(Number(eval("row"+(l+1))[a][0]),false);
var Width = Number(eval("row"+(l+1))[a][3]) - Number(eval("row"+(l+1))[a][1]);
var shiftPixels = (leftAnchor+spacingA) - Number(eval("row"+(l+1))[a][1]);
activeDocument.activeLayer.translate(shiftPixels,0);
leftAnchor +=(Width+spacingA);
for(var l=0;l<row1.length;l++){
var topAnchor =Number(row1[l][4]);
for(var a = 1;a<arrayNumber;a++){
makeActiveByIndex(Number(eval("row"+(a+1))[l][0]),false);
var Height = Number(eval("row"+(a+1))[l][4]) - Number(eval("row"+(a+1))[l][2]);
var shiftPixels = (topAnchor+spacingD) - Number(eval("row"+(a+1))[l][2]);
activeDocument.activeLayer.translate(0,shiftPixels);
topAnchor +=(Height+spacingD);
for(var a in selectedLayers){
    makeActiveByIndex(Number(selectedLayers[a]),false,true);
app.preferences.rulerUnits = startRulerUnits;
main();
function selectLayerByIdx(idx, add) {
var ref = new ActionReference();
ref.putIndex(charIDToTypeID('Lyr '), idx);
var desc = new ActionDescriptor();
desc.putReference(charIDToTypeID('null'), ref);
if(add) desc.putEnumerated(stringIDToTypeID('selectionModifier'), stringIDToTypeID('selectionModifierType'), stringIDToTypeID('addToSelection'));
    desc.putBoolean(charIDToTypeID('MkVs'), false);
executeAction(charIDToTypeID('slct'), desc, DialogModes.NO);
function makeActiveByIndex( idx, visible,add ){
    if(add == undefined) add=false;
    var desc = new ActionDescriptor();
      var ref = new ActionReference();
      ref.putIndex(charIDToTypeID( "Lyr " ), idx)
      desc.putReference( charIDToTypeID( "null" ), ref );
      if(add) desc.putEnumerated(stringIDToTypeID('selectionModifier'), stringIDToTypeID('selectionModifierType'), stringIDToTypeID('addToSelection'));
      desc.putBoolean( charIDToTypeID( "MkVs" ), visible );
   executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );
function getSelectedLayersIdx(){
      var selectedLayers = new Array;
      var ref = new ActionReference();
      ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
      var desc = executeActionGet(ref);
      if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
         desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
          var c = desc.count
          var selectedLayers = new Array();
          for(var i=0;i<c;i++){
            try{
               activeDocument.backgroundLayer;
               selectedLayers.push(  desc.getReference( i ).getIndex() );
            }catch(e){
               selectedLayers.push(  desc.getReference( i ).getIndex()+1 );
       }else{
         var ref = new ActionReference();
         ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
         ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
         try{
            activeDocument.backgroundLayer;
            selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1);
         }catch(e){
            selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" )));
      return selectedLayers;
function getLayerBoundsByIndex( idx ) {
    var ref = new ActionReference();
    ref.putProperty( charIDToTypeID("Prpr") , stringIDToTypeID( "bounds" ));
    ref.putIndex( charIDToTypeID( "Lyr " ), idx );
    var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID( "bounds" ));
    var bounds = [];
    bounds.push(desc.getUnitDoubleValue(stringIDToTypeID('left')));
    bounds.push(desc.getUnitDoubleValue(stringIDToTypeID('top')));
    bounds.push(desc.getUnitDoubleValue(stringIDToTypeID('right')));
    bounds.push(desc.getUnitDoubleValue(stringIDToTypeID('bottom')));
    return bounds;
function showFX(FX) {
    var desc48 = new ActionDescriptor();
        var ref34 = new ActionReference();
        ref34.putProperty( charIDToTypeID('Prpr'), charIDToTypeID('lfxv') );
        ref34.putEnumerated( charIDToTypeID('Dcmn'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    desc48.putReference( charIDToTypeID('null'), ref34 );
        var desc49 = new ActionDescriptor();
        desc49.putBoolean( charIDToTypeID('lfxv'), FX );
    desc48.putObject( charIDToTypeID('T   '), charIDToTypeID('lfxv'), desc49 );
    try{
    executeAction( charIDToTypeID('setd'), desc48, DialogModes.NO );
    }catch(e){}

Similar Messages

  • Issue is happening on a Mac. I cannot log into creative cloud all I get is for squares in the center of the screen that a blinking

    issue is happening on a Mac. I cannot log into creative cloud all I get is for squares in the center of the screen that a blinking

    Creative Cloud chat support (all Creative Cloud customer service issues)
    http://helpx.adobe.com/x-productkb/global/service-ccm.html

  • How do I set a variable within a 'for' loop grid array

    I'm afraid I'm stuck again!
    The next stage in the animation that I'm working on,  is to set up a boolean, 'drilled = false', so that all instances of the attachMovie ('openCircle') have a boolean 'drilled = false' associated with them. Then when someone clicks on one of the instances of the attachMovie ('openCircle'), the boolean becomes 'drilled = true', but only for that instance that has been clicked.
    What I've done is to set the variable (boolean)(highlighted in bold below) within both 'for' loops within the grid array, but it just returns an undefined value. Do I need to setup a separate array? (see code below):-
    //set up grid for solid array
    var spacing:Number = 5.75;
    var cols:Number = 20; // number of columns in grid
    var rows:Number = 20; // number of rows in grid
    var leftMargin:Number = 154;
    var topMargin:Number = 169;
    var depth:Number = 100; // starting point for depth
    var drilled:Boolean;
    for (i=1; i<=rows; i++) {                                                                                                         
    for (j=1; j<=cols; j++) {                                                                                                                              
              drilled[rows,cols]=false;
                        trace(drilled);
              current = attachMovie("openCircle_mc", "openCircle_mc"+i+"_"+j, depth++);
              current._x = leftMargin + ((i-1) * (spacing + current._width));
              current._y = topMargin + ((j-1) * (spacing + current._height));
              current.row=i;
              current.col=j;
    //          current.oil = Math.floor(Math.random()*1.1);  // about 1/10 objects have oil=1, 9/10 oil=0
              //open circle initially invisible, visible on rollOver
              current._alpha = 0;
              current.onRelease=function(){
                        trace(this.row+" "+this.col);
       current.drilled = true;
              current.onRollOver = function() {
                                     this._alpha = 100;
              current.onRollOut = function() {
                                     this._alpha = 0;
    I'd be grateful for any help. Thanks.

    I'm sorry for asking this question again, but I really need to have the 'drilled' variable to be available at all times outside the openCircle_mc, so if I can set up the 'drilled' variable as an array that would be good. Below is the code that isn't working:
    /*  set all values of 'drilled' to false  */
    var col:Number = 20; // number of columns in grid
    var row:Number = 20; // number of rows in grid
    for (g=1; g<=row; g++) {
              for (h=1; h<=col; h++){
                          drilled[g,h] = false;
    Very many thanks

  • Sort Grid array and find the 4 corner dots.

    What I am trying to do is this:  I am using NI Visions find circles vi on a grid array or dots which gives me a 1D array of clusters.  In these clusters is the x,y coordinates of the grid dots that have been found.  I need to figure out which ones are the 4 corner dots and the 4 center dots along the edges.  The problem is the 1D array the find circle routine outputs is not in a logical order.  My grid could possibly change in size too.  Right now it is 14x12 but could be 13x12 or 14x13 or something like that. 
    I have found that if I send the 1D array of clusters though the sort 1D array it will sort it from top to bottom left to right, which I will then know that teh 1st element is the top left corner and the last element is the bottom right corner, but I am not sure what the easiest way is to figure out the rest of them. 
    Any help would be appreciated.
    I am using labview 7.1 and NI Vision 8.0
    Thanks
    Brad
    Brad Remenak
    Certified LabVIEW Architect

    Hi Brad,
    If you want to get the coordinates of specific dots on the image, you
    can search for the dots using different ROIs that only focus on certain
    areas of the image (ex: use an ROI that only searches in the
    upper-right corner so that you know the 1 match that shows up is
    definitely there).  Without knowing how consistent the dot
    locations are, I would suggest dividing up the ROI dimensions based on
    the variable size of the grid.
    Hope this helps,
    Irene Chow
    National Instruments

  • I moved iTunes folder location, now all my personal song ratings and playlists are gone.  How can I get them back?  All the iTunes files are intact, just in a new location.  Running iTunes 11.1.5.5

    I moved iTunes folder location, now all my personal song ratings and playlists are gone.  How can I get them back?  All the iTunes files are intact, just in a new location.  Running iTunes 11.1.5.5 on Windows 7

    Put everything back the way it was.
    Them move the folder correctly.
    http://support.apple.com/kb/ht1364

  • The grid array of my photo library has disappeared

    iLife 08, iPhoto 6.0.6, Snow Leopard 10.6.8, iMac Intel Core 2 Duo
    I loaded my 4th of July pictures and began editing them, but in the afternoon of July 5th the screen changed from the scrollable grid array of my entire iPhoto Library to just one big photo at a time, no editing tools available.
    This has me completely stuck as this mode eliminates any means I have of seeing my photos (except one by one) and editing, saving, sending...
    Aaaaargh!

    Look at the scroll bar at the bottom and move it to the left to get the thumbnail size you want.
    OT

  • Red/Blue squares all over...

    Just put together a new system last night..  Everything installed fine, worked great.. Came home today and the PC was in sleep mode, woke it up to find hundreds of blue/red squares all over the screen.. They are blue in a white background, red on everything else.   Even on the windows splash screen, they are there, as there on the post screen.  Installed newest drivers for vid card, same problem..
    K9n SLI platinum
    AMD x2 4600
    2 gig ram
    vista ultimate 64
    thermaltake 750w psu
    ATI 1950pro pci-e
    I have no other pci-e card to test out, might try to return this one tomorrow to swap for another.
    Thanks!
    -John

    sound like VGA is overheating or damaged somehow. check cable monitor as well ensure its plugged well into VGA.
    test VGA somewhere else.

  • Delete all cost center

    Hi all,
    I use LSMW to create all cost center for system. However, all cost center have codename wrong, so I want to delete all cost center and create again. Can I? How by? I have many cost centers so I cant use KS04. Please help me, thanks very much!
    P/S: some cost centers have data posting on it.
    Regards

    Hello Tran,
    For cost centers that have data in them you can not delete them. There are two options
    1. Block those cost centers : Go to the control tab in the cost center master data and check all the boxes there.
    2. In case its a non live system and if you do not have much data then you may delete the transaction data with transaction OKC3 but the problem is that it would delete each and every data posted in CO. After this you can delete the cost centers using OCK4 or KS14.  This is not a recomended approach and you should only use it only when you can do away with the data posted if that is very less. In this process you may loose important test data in you need them.
    Kind Regards // Shaubhik

  • The pointer won't move on the screen - it just makes a trail of black squares all over the screen

    the pointer won't move on the screen - it just makes a trail of black squares all over the screen  . what's going on???

    I've tried all those things it says to do, and nothing works.

  • We are unable to open a Pages 5.0.1 document in Pages 4.2 and retain ability to edit all aspects of the document. I have tried saving the 5.0.1 version as Pages '09 and am still unable to open it in the earlier version of pages. Help?

    We are unable to open a Pages 5.0.1 document in Pages 4.2 and retain ability to edit all aspects of the document. I have tried saving the 5.0.1 version in Pages '09 but am still unable to open it in the earlier version of pages. Help?

    No, it isn't. Pages 5 isn't compatible with Pages 4.3 as it is lacking more than 90 features that Pages 4 has. So when you open a Pages 4 document in Pages 5 only the simplest documents will look the same in Pages 5.
    Pages 4 can't open Pages 5 documents at all!! You have to export back to Pages 09 as I said above.
    You probably will be more happy if you just use Pages 4 (Pages 09). There are many threads in this forum that describes the lack of compatibility between the two versions. Pages 5 is in my view not Pages anymore.
    If you don't desperately need Pages 5 for moving documents over iCloud to new iOs devices don't use it.

  • ExtendScript: Get all text from a document

    Hi all.
    I have the following task: I need to translate a document into another language using ExtendScript. So, as "input" I have a document with a text/graphics/tables/etc. in Language_1 and a "somehow-separated file", which will contain data about translation into the Language_2. E.g.:
    Some_text_in_language_1     Some_text_in_language_2
    Some_other_text_in_language_1     Some_other_text_in_language_2
    To get the source text from the document, I've tried to use this:
    var pgf = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
    while(pgf.ObjectValid()){
         var test = pgf.GetText(Constants.FTI_String);
         var text, str;
         text = "";
         for (var i=0; i < test.len ; i +=1)
              var str=test[i] .sdata.replace(/^\s+|\s+$/g, '') ; 
              text = text + str;
              PrintTextItem (test[i]);
         pgf = pgf.NextPgfInFlow;
    But with this, I can only access the regular text in the document (e.g. the text in tables remains untougched). Is there any way I can the all textual data from specified document? Or maybe, the full list of controls, which can contain it, to iterate throught them and extract it one-by-one? Or maybe there's a better way to solve this problem?
    Thanks in advance! Any advice would be greatly appreciated.

    There is another way to loop through ALL paragraphs in a document, regardless whether they are in a table or in the main text flow. You can use the FirstPgfInDoc property of the document and loop through all Pgf objects using the NextPgfInDoc property of the Pgf until you reach an invalid object. Note that this also includes all paragraphs in the master and reference pages, so it might be useful to check where the Pgf is located (on a body page or not). There is a script on this forum that does that - I believe it was created and posted by Rick Quatro.
    Working your way through the main text flow does not guarantee that you have all the visible text in the doc. There may be multiple flows and there may also be text frames that are placed inside anchored frames. Those text frames are not contained directly in the main flow of the document.
    Good luck with your scripting
    Jang

  • Pages 5.2 opens all kinds of other document formats (even old .doc  Versions), but cannot open Pages 08 etc. of its own kind? I have to use NeoOffice to open my documents of many years of work. Is there an option to organize a corporate com

    Pages 5.2 opens all kinds of other document formats (even old .doc  Versions), but cannot open Pages 08 etc. of its own kind?
    I have to use NeoOffice to open my documents of many years of work.
    Is there an option to organize a corporate complain to Apple to be heard?

    We have been doing nothing but for 10 months.
    Here is the response:

  • Why does mountain lion "bunch up" all my microsoft office documents that I have open when I hit f3? When I had snow leopard for example, if i had 4 or 5 different microsoft office documents open at the same time I could hit f3 and easily pick one of them

    Why does mountain lion "bunch up" all my microsoft office documents that I have open when I hit f3? When I had snow leopard for example, if i had 4 or 5 different microsoft office documents open at the same time I could hit f3 and easily pick one of them.
    Notice how in the photo, I can't identify which MS office document I would like to switch too. Perhaps since the Dashboard and Desktop windows are at the top of my screen now Apple doesn't let you have all the applications take up the full screen and be sized individually so that you can have a better idea on what to pick.
    I like the idea of grouping to an extent... If you have a bunch of random things it was hard for me to decifer between what was safari, chrome, or word. But now that they grouped them like this, if you have multiple pages of one program running, you can't switch between those pages easily like before.

    If I wanted to open any of my Applework documents I had to open them one at a time and resave them with pages. This could take weeks.I have 1000s of apple work documents.
    You don't have to open and re-save every AppleWorks document you have right now. Just wait till you need one, then do it. The documents aren't going anywhere.
    Am I dealing with Microsoft? This was a BIG surprise to me that Apple would release an OS without testing all programs.
    Frankly, it is not Apple's responsibility to ensure compatibiltiy with every piece of software available for OS X. That is the responsibility of the software vendor. Lion has been available to developers for several months before it's release, so Microtek had plenty of time to update their software. Yet they did not. How is that Apple's fault? I think Apple was very generous to give you a refund for Lion.
    I'm not trying to belittle your frustration but I do think your ire is misplaced.

  • HT201301 How do I "Select All" in a Pages document? I would like to copy and past more than one paragraph at a time.

    How do I "Select All" in a Pages document. I would like to copy and paste more than one paragraph at a time.

    I just tab and hold untill the loop shows then let go and I get the menu with select all in it

  • How can I get my Indesign script to apply to all pages in the document?

    My script (java) shown below will only apply to the first page of the document. How can i get it to apply to all pages of my document? What am I missing? Thanks.
    scirpt:
    myDocument = app.activeDocument
    with (myDocument.pages.item(0).marginPreferences){
    columnCount = 1;
    //columnGutter can be a number or a measurement string.
    columnGutter = "0";
    bottom = "0"
    //When document.documentPreferences.facingPages == true,
    //"left" means inside; "right" means outside.
    left = "0"
    right = "0"
    top = "0"
    inside = "0"

    Hi,
    You have to iterate through all pages.marginPreferences:
    var
      myDocument = app.activeDocument,
      allPagesMaPref = myDocument.pages.everyItem().marginPreferences,
      curPageMaPref;
    while ( curPageMaPref = allPagesMaPref.pop() )
      with (curPageMaPref) {
      columnCount = 1;
      //columnGutter can be a number or a measurement string.
      columnGutter = "0";
      bottom = "0"
      //When document.documentPreferences.facingPages == true,
      //"left" means inside; "right" means outside.
      left = "40"
      right = "0"
      top = "0"
      inside = "0"
    Jarek

Maybe you are looking for