Skip navigation
caseyctg
Currently Being Moderated

Looking to do something like this...

Sep 19, 2012 1:04 PM

newDoc.layers.item("GraphBars").pageItems.everyItem().move([ x,y ]);

 

 

Basically what I am trying to do is grab everything from a layer and move it using x,y coordinates. This doesn't seem to be working... am I missing something?

 
Replies
  • Currently Being Moderated
    Sep 19, 2012 2:50 PM   in reply to caseyctg

    Works fine here (in CS6). Are you targetting the correct layer? Are there any page items on that layer? If there are, are they unlocked?

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 20, 2012 6:52 AM   in reply to caseyctg

    This cannot work in a document with more than one spread, because a Group object cannot transcend spread boundaries. If you want to group items by layers, you have to do it spread by spread.


    And for that you first have to sort out which item belongs to what layer (spread by spread).

     

    Uwe

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 20, 2012 7:17 AM   in reply to caseyctg

    But "myGraphBarItems" are page items throughout the **whole** document.

     

    Uwe

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 20, 2012 8:07 AM   in reply to caseyctg

    No, there isn't. As Uwe mentioned, you have to work page by page, and on each page, layer by layer.

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 20, 2012 12:59 PM   in reply to caseyctg

    Layers aren't connected to pages. You look for page items on certain layers on certain pages.

     

    > Would I be better off scraping the page for page items and then check to see if they are on that layer, and if they are then group them?

     

    This is the way to go.

     

    Peter

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 20, 2012 11:43 PM   in reply to caseyctg

    Hi,

     

    you may  use your array from the start, may be faster as ... ¿:

     

     

    var theDoc = app.activeDocument;
    var getGraphs = theDoc.layers.item('Ebene 1').pageItems.everyItem().getElements();
     
    var pageItemsAndParentPages = [];
     
    l = getGraphs.length;
     
    while(l--){
        tmp = [];
        tmp.push(getGraphs[l], getGraphs[l].parentPage.documentOffset);
        pageItemsAndParentPages.push(tmp)
        }
     
     pageItemsAndParentPages.sort(function(a, b){return a[1] -  b[1]})
     
     l = pageItemsAndParentPages.length;
          tmp = [];
     for(var i = 0; i < l; i++){
        theItem = pageItemsAndParentPages[i];
        if(i === l-1){tmp.push(theItem[0]);       theDoc.groups.add(tmp).move([0,0]); continue}
       if(theItem[1] === pageItemsAndParentPages[i+1][1]){
           tmp.push(theItem[0]);
           }else{
                      tmp.push(theItem[0]);
          theDoc.groups.add(tmp).move([0,0]);
                tmp = [];
    }
            }
    

    Hope it'll work

     

    Hans-Gerd Claßen

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 21, 2012 2:22 AM   in reply to caseyctg

    caseyctg: Any luck with your latest approach? It looks good to me.

     

    Peter

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points