Copy link to clipboard
Copied
Hello to all
I would like to find/modify all the text on my pages and remove it by the findGrep and changeGrep method in a script, but only on one layer...
as if myLayer.ChangeGrep() exists?
Is it possible ?
Thx in advance for your help
My actual script :
var myDocument = app.documents.item(0);
//var myLayer = myDocument.layers.item("FauxTexte");
//Clear the find/change grep preferences.
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
//Set the find options.
app.findChangeGrepOptions.includeFootnotes = false;
app.findChangeGrepOptions.includeHiddenLayers = false;
app.findChangeGrepOptions.includeLockedLayersForFind = false;
app.findChangeGrepOptions.includeLockedStoriesForFind = false;
app.findChangeGrepOptions.includeMasterPages = false;
//Regular expression for finding an email address.
app.findGrepPreferences.findWhat = '(?s)^.+';
app.changeGrepPreferences.changeTo = '';
//app.changeGrepPreferences.underline = true;
myDocument.changeGrep();
//Clear the find/change preferences after the search.
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
Something like this, though it wouldn't work if you have anchored, grouped or otherwise nested frames in the layer. In that case, you'd probably just iterate through myDocuments.layers.itemByName("name").textFrames.everyItem().parentStory and change those.
var myLayerTexts = myDocument.layers.itemByName("your-layer-name").textFrames.everyItem().texts.everyItem();
myLayerTexts.changeGrep();
Hi Franck,
simply lock all layers but the one(s) you are interested in.
myDocument.layers.everItem().locked = true;
myLayer.locked = false;
// PERHAPS ALSO THIS:
myLayer.pageItems.everyItem().locked = false;
Then run your script with the document scope that you already have implemented.
Note:
myDocument.changeGrep()
will also affect texts on the Parent Pages ( formerly called Master Pages ) .
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Something like this, though it wouldn't work if you have anchored, grouped or otherwise nested frames in the layer. In that case, you'd probably just iterate through myDocuments.layers.itemByName("name").textFrames.everyItem().parentStory and change those.
var myLayerTexts = myDocument.layers.itemByName("your-layer-name").textFrames.everyItem().texts.everyItem();
myLayerTexts.changeGrep();
Copy link to clipboard
Copied
Hi Franck,
simply lock all layers but the one(s) you are interested in.
myDocument.layers.everItem().locked = true;
myLayer.locked = false;
// PERHAPS ALSO THIS:
myLayer.pageItems.everyItem().locked = false;
Then run your script with the document scope that you already have implemented.
Note:
myDocument.changeGrep()
will also affect texts on the Parent Pages ( formerly called Master Pages ) .
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Thanks both! This 2 solutions make the job!
Frank