2 Replies Latest reply on Feb 3, 2016 7:42 AM by Michael Witherell

    Find Change Object cannot delete the object

    Michael Witherell Adobe Community Professional

      Hello everyone,

       

      The Find/Change dialog box can be set to Object, and I can search successfully for open path line objects that are .5pt and stroked with the color Black. But, I cannot delete them.

       

      Suppose I need to go through hundreds of pages to delete a stray open path line. Find/Change won't do it! Is there a javascriptable solution?

        • 1. Re: Find Change Object cannot delete the object
          Jump_Over Level 5

          Hi,

           

          The answer is: yes.

          You can

          set app.findObjectPreferences with needed values - collect found objects into array - iterate through - remove().

           

          Jarek

          • 2. Re: Find Change Object cannot delete the object
            Michael Witherell Adobe Community Professional

            After further experimenting, I cut down an existing script that came with InDesign, and came up with this variant:

             

            //SelectPathObjects.jsx for InDesign JavaScript
            /* 
            2015_02_02
            */
            main();
            function main(){
              //Make certain that user interaction (display of dialogs, etc.) is turned on.
              app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
              if (app.documents.length != 0){
              if (app.activeWindow.activeSpread.pageItems.length != 0){
              myDisplayDialog();
              }
              else {
              alert("The active spread does not contain any page items.");
              }
              }
              else{
              alert("No documents are open. Please open a document and try again.");
              }
            }
            function myDisplayDialog(){
              var myDialog;
              //Create the SelectObjects dialog box.
              with(myDialog = app.dialogs.add({name:"SelectObjects"})){
              with(dialogColumns.add()){
              with(borderPanels.add()){
              staticTexts.add({staticLabel:"Select:"});
              with(dialogColumns.add()){
              var myGraphicLinesCheckbox = checkboxControls.add({staticLabel:"&Graphic Lines", checkedState:true});
              }
              }
              }
              }
              myResult = myDialog.show();
              if (myResult == true){
              var myObjectTypes = new Array;
              //Gather control settings from the dialog box and build
              //an array containing the object types to select.
              if(myGraphicLinesCheckbox.checkedState==true){
              myObjectTypes.push("graphicLines");
              }
              //Remove the dialog from memory.
              myDialog.destroy();
              mySelectObjects(myObjectTypes);
              }
              else{
              //Remove the dialog from memory.
              myDialog.destroy();
              }
            }
            function mySelectObjects(myObjectTypes){
              var myCounter;
              var myObjectsToSelect = new Array;
              with(app.activeWindow.activeSpread){
              for(myCounter = 0; myCounter < myObjectTypes.length; myCounter++){
              if((myObjectTypes[myCounter] != "images")&&(myObjectTypes[myCounter] != "epss")&&(myObjectTypes[myCounter] != "pdfs")){
              myPageItems = eval(myObjectTypes[myCounter]);
              if (myPageItems.length != 0){
              for(myPageItemCounter = 0; myPageItemCounter < myPageItems.length; myPageItemCounter ++){
              myObjectsToSelect.push(myPageItems[myPageItemCounter]);
              }
              }
              }
              }
              for(myCounter = 0; myCounter < pageItems.length; myCounter++){
              myPageItem = pageItems.item(myCounter);
              try{
              if(((myIsInArray("images", myObjectTypes) == true) && (myPageItem.images.length == 1))||
              ((myIsInArray("epss", myObjectTypes) == true) && (myPageItem.epss.length == 1))||
              ((myIsInArray("pdfs", myObjectTypes) == true) && (myPageItem.pdfs.length == 1))){
              //Is the page item already in the list of items to select?
              myID = myPageItem.id;
              myAlreadyAdded = false;
              for(myPageItemCounter = 0; myPageItemCounter<myObjectsToSelect.length; myPageItemCounter++){
              if(myObjectsToSelect[myPageItemCounter].id == myID){
              myAlreadyAdded = true;
              break;
              }
              }
              //If the page item was not already in the list of items to select, add it to the list.
              if (myAlreadyAdded == false){
              myObjectsToSelect.push(myPageItem);
              }
              }
              }
              catch(myError){
              }
              }
              parent.select(myObjectsToSelect, SelectionOptions.replaceWith);
              }
            }
            function myIsInArray(myString, myArray){
              var myResult = false;
              for (myCounter = 0; myCounter < myArray.length; myCounter ++){
              if (myArray[myCounter] == myString){
              myResult = true;
              break;
              }
              }
              return myResult;
            }