Copy link to clipboard
Copied
My department has recently finished converting to Frame 2017, updating tags/formats/layouts, and many other activities to bring some old Frame files into the modern world. We're at the point where we can realistically begin automating and simplifying various processes, which is leading us to the land of extendscript.
I'd like to script the complete removal of individual character tags from text. Adobe has provided the very useful SuperFindChange script, which can swap one tag for another. I'm wondering if there is some easy way for a complete novice, like myself, to modify the script to simply remove the tag rather than swap it. I can manually copy a character format, use Find to locate the tag I want to strip, and then replace the tag with the copied format. I can also do the classic, Default Font and then reapply the paragraph tag (for paragraphs that are completely character tagged). It seems like I should be able to script it without too much fuss, but I'm probably oversimplifying.
Maybe someone has already done this or there is something out there on the interwebz, but my Google-fu is failing me. Can someone point me in the right direction or suggest a starting point? Maybe even take pity me on me and give me a snippet of code I can plug into the SuperFindChange script?
Hi David, This is part of the functionality of my FindChangeFormatsBatch script. Here is a function that applies the default paragraph format to a text range. You pass in the TextRange, the parent text object (for example, the paragraph) and the document object. I am not sure if you can just plug this into Adobe's code, but you should be able to retrofit it so that it works. -Rick
...function applyDefaultParaFont (textRange, textObj, doc) {
var pgfFmt, prop, textLoc;
if (textObj.constr
Copy link to clipboard
Copied
Hi David, This is part of the functionality of my FindChangeFormatsBatch script. Here is a function that applies the default paragraph format to a text range. You pass in the TextRange, the parent text object (for example, the paragraph) and the document object. I am not sure if you can just plug this into Adobe's code, but you should be able to retrofit it so that it works. -Rick
function applyDefaultParaFont (textRange, textObj, doc) {
var pgfFmt, prop, textLoc;
if (textObj.constructor.name === "Pgf") {
// Get the properties of the paragraph's format.
pgfFmt = doc.GetNamedPgfFmt (textObj.Name);
if (pgfFmt.ObjectValid () === 1) {
doc.SetTextProps (textRange, pgfFmt.GetProps ());
}
}
else { // Text line; get the properties at the beginning of the text line.
textLoc = new TextLoc (textObj, 0);
prop = doc.GetProps (textLoc);
doc.SetTextProps (textRange, prop);
}
// The old Character Format's name will still be attached to the text,
// so remove it.
prop = new PropVal ();
prop.propIdent.num = Constants.FP_CharTag;
prop.propVal.valType = Constants.FT_String;
prop.propVal.sval = "";
doc.SetTextPropVal (textRange, prop);
}
Copy link to clipboard
Copied
Wow! What a great place you've given me to start from. I confess my last experience with javascript was several years ago, so I'll have to bring myself up to speed so that I can squeeze the most out of extendscript. Thank you so much for your contribution.
Copy link to clipboard
Copied
My pleasure. Please mark my answer as Correct. Thank you very much.