Skip navigation
maxrus2012
Currently Being Moderated

How to move layers to separate pages

May 31, 2012 4:24 AM

I have an Indesign CS5.5 document with one page and multiple artworks on separate layers. I need to move each layer to a separate page and then to separate documents.

Is there any quick way of doing this, or script that has been written?

Thanks, in advance.

 
Replies
  • Currently Being Moderated
    Jun 1, 2012 1:38 AM   in reply to maxrus2012

    @ maxrus2012 – layers are document properties, NOT page properties. So you cannot move a layer to a different page.
    Instead what I guess you want is that you like to move all page items on page one of a specific layer to a different page.

     

    The following script will duplicate all page items per layer to new pages in the same document. You can undo the script.

     

    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
     
    app.doScript(_DistributeAllPageItemsOnCurrentPageToNewPages, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Distribute all page items on current page to new pages");
     
    function _DistributeAllPageItemsOnCurrentPageToNewPages(){
     
    var d = app.documents[0];
    var allLayers = d.layers;
     
    allLayers.everyItem().visible = true;
    allLayers.everyItem().locked = false;
     
    for(var n=0;n<allLayers.length;n++){
     
        if(allLayers[n].pageItems.length>0){
            var pageItemsOnLayer = allLayers[n].pageItems.everyItem();
            //Unlock every page item on the layer:
            pageItemsOnLayer.locked = false;
            //Make all page items visible on the layer:
            pageItemsOnLayer.visible = true;
            var myGroup = d.groups.add(pageItemsOnLayer);
            var newPage = d.pages.add();
            var myDupOfGroup = myGroup.duplicate(newPage);
            myDupOfGroup.ungroup();
            myGroup.ungroup();
            };
     
        };
     
    }; //END function "_DistributeAllContentsOnCurrentPageToNewPages()"
    

     

     

    Uwe

     

    Message was edited by: Laubender Used advanced editor get syntax highlighting after posting

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2012 2:40 AM   in reply to maxrus2012

    @Max – can you provide a simple example of your source document, exported as IDML, that I can download?

     

    Uwe

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2012 2:46 AM   in reply to Laubender

    .. or change the script slightly, so it zooms in on the actual error line.

     

    Put comment slashes before the line that starts with app.doScript:

     

    // app.doScript ..
    

     

    so it will be ignored, and add this line

     

    _DistributeAllPageItemsOnCurrentPageToNewPages();
    

     

    directly below it. Then re-run and see what it tells you.

     

    (The doScript construction allows an easy One Step Undo of the entire script, but unfortunately it has the side effect that any errors "inside" the script will be reported as an error from the command that executed the script. Calling the function directly will hopefully show where it fails inside the function.)

     

    Message was edited by: [Jongware] Gosh, still no way of adding Syntax Hi-lite without post-editing. "Knock knock, anyone there?"

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2012 2:49 AM   in reply to [Jongware]

    Hi Jongware,

     

    OT: The only way is to go to "Use advance editor"....

     

    Green4ever

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2012 3:19 AM   in reply to maxrus2012

    groups.add([Array of pageItems is Expected Here]);

     

    In your example only one page item is present so it throws an invalid parameter error.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2012 3:21 AM   in reply to maxrus2012

    @Max – ok. I think I made the mistake to assume that there are more than one page items on a single layer. If there is only one page item, my script will fail because I cannot make a group object out of one single page item.

     

    But we can correct that, if we ommit the grouping if there is only one page item in the layer:

     

    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
     
    app.doScript(_DistributeAllPageItemsOnCurrentPageToNewPages, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Distribute all page items on current page to new pages");
     
    function _DistributeAllPageItemsOnCurrentPageToNewPages(){
     
    var d = app.documents[0];
    var allLayers = d.layers;
     
    allLayers.everyItem().visible = true;
    allLayers.everyItem().locked = false;
     
    for(var n=0;n<allLayers.length;n++){
     
        if(allLayers[n].pageItems.length>1){
            var pageItemsOnLayer = allLayers[n].pageItems.everyItem();
            //Unlock every page item on the layer:
            pageItemsOnLayer.locked = false;
            //Make all page items visible on the layer:
            pageItemsOnLayer.visible = true;
            var myGroup = d.groups.add(pageItemsOnLayer);
            var newPage = d.pages.add();
            var myDupOfGroup = myGroup.duplicate(newPage);
            myDupOfGroup.ungroup();
            myGroup.ungroup();
            };
     
        if(allLayers[n].pageItems.length===1){
            var myPageItem = allLayers[n].pageItems[0];
            myPageItem.locked = false;
            myPageItem.visible = true;
            var newPage = d.pages.add();
            myPageItem.duplicate(newPage);    
            };
     
        };
     
    }; //END function "_DistributeAllContentsOnCurrentPageToNewPages()"
    

     

     

    Uwe

     

    Message was edited by: Laubender Did syntax highlighting by advanced editor

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2012 4:24 AM   in reply to maxrus2012

    @Max

     

    For that we need a naming scheme for the different single page documents you want to save.

    But I fear currently I have no time to implement that.

     

    There are several scripts floating around in the web which can do that for you.

    See for example the following script by Hans Haesler (split document):

     

    DokumentAufsplitten_512d.jsx

     

    at (Mac version in German):

    http://www.fachhefte.ch/downloads.php?groupIDX=&orderby=name&sort=ASC& search_query=&itemIDX=&begin=&limit=&read_category=16&page=0&downloadI DX=651

     

    or (Windows version in German):

    http://www.fachhefte.ch/downloads.php?groupIDX=&orderby=name&sort=ASC& search_query=&itemIDX=&begin=&limit=&read_category=16&page=0&downloadI DX=655

     

    In case you do not understand the German settings here is a two-step-guide to your single page documents:

     

    1. Check the proper feature for splitting pages (every page should become a document of its own):

     

    Step1_DokumentAufsplitten_EveryPageOneSingleDocument.png

     

    2. Start page numbering with:

     

    Step2_DokumentAufsplitten_StartPageNumber.png

     

    If you want every single document in its own directory check: "Artikel-Ordner erzeugen".

     

    Uwe

     
    |
    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