2 Replies Latest reply on Mar 28, 2013 4:18 PM by PeterPow

    Graphic layer options

    PeterPow Level 1

      Hi guys,

       

      I'm experimenting with imported pages and the possibility to hide specific layers of an placed indesign document. To achieve this I am using the following code:

       

      var oDoc = app.documents[0]; // this is an empty document in the indesign client

       

      var oPlacedObjects = oDoc.pages.firstItem().place(File('{PATH_TO_FILE}'));

      var oImportedPage = oPlacedObjects[0];

      oImportedPage.graphicLayerOptions.graphicLayers.item(0).currentVisibility = false;

      oImportedPage.graphicLayerOptions.graphicLayers.item(1).currentVisibility = false;

       

      The placed file has 3 different layers, the first two I would like to hide. My problem now is that the second call to the currentVisibility-property always fails with the error message "The requested action could not be completed because the object no longer exists". When I extend my code to the following block

       

       

      var oDoc = app.documents[0];

       

      var oPlacedObjects = oDoc.pages.firstItem().place(File('{PATH_TO_FILE}'));

      var oImportedPage = oPlacedObjects[0];

      oImportedPage.graphicLayerOptions.graphicLayers.item(0).currentVisibility = false;

      // THIS LINE HAS BEEN ADDED

      var oImportedPage = oDoc.pageItems.firstItem().importedPages.firstItem();

      // -----------------------------------------

      oImportedPage.graphicLayerOptions.graphicLayers.item(1).currentVisibility = false;

       

      the script works as expected. My question now is if I'm doing something wrong in handling imported pages or if it is a bug, that the first script block does not work.

       

      Thanks for your support guys!