How find strokes with different thicknesses
Is there a way to find and replace all the strokes comprised between different thicknesses, for example between 0.01 pt and 0.09 pt with strokes of 0.1 pt thickness?
Is there a way to find and replace all the strokes comprised between different thicknesses, for example between 0.01 pt and 0.09 pt with strokes of 0.1 pt thickness?
There you go. Save as "fixHairlines.jsx" in your own personal Scripts folder (if this sounds daunting, read https://indesignsecrets.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-post.php ), double-click to run. It presents a simple dialog in which you can fill in the minimum and maximum weights to change (both inclusive) and the weight to change to.
Did only a very small test but I foresee no problems. InDesign pops up an automatic message if you try to find objects on locked layers or in locked stories, and to prevent that, I disable these two options. The other settings – type, master pages, hidden layers – should (theoretically) remain as last set.
It does not seem to work with finding 0 point line weights, but I guess that should be a rarity – this script is to change existing line weights, not to add one to objects that don't have one.
It's undo-able in a single step.
//Find and change line weights between certain values
// A Jongware Script 05-Jun-2019
app.doScript(fixHairlines, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Fix hairlines");
function fixHairlines()
{
var thicknessDialog = app.dialogs.add({name:"Fix hairlines", canCancel:true});
with (thicknessDialog)
{
with(dialogColumns.add())
{
with(dialogRows.add())
{
staticTexts.add({staticLabel:"Minimum weight"});
minweight = measurementEditboxes.add({editUnits:MeasurementUnits.POINTS, editValue:0.01,largeNudge:0.1,smallNudge:0.01,minimumValue:0,maximumValue:999});
}
with(dialogRows.add())
{
staticTexts.add({staticLabel:"Maximum weight"});
maxweight = measurementEditboxes.add({editUnits:MeasurementUnits.POINTS, editValue:1.0,largeNudge:0.1,smallNudge:0.01,minimumValue:0,maximumValue:999});
}
with(dialogRows.add())
{
staticTexts.add({staticLabel:"Change to"});
setweight = measurementEditboxes.add({editUnits:MeasurementUnits.POINTS, editValue:1.0,largeNudge:0.1,smallNudge:0.01,minimumValue:0,maximumValue:999});
}
}
}
if (thicknessDialog.show() == true)
{
app.findObjectPreferences = null;
app.findChangeObjectOptions.includeLockedLayersForFind = false;
app.findChangeObjectOptions.includeLockedStoriesForFind = false;
list = app.documents[0].findObject();
for (i=0; i<list.length; i++)
{
if (list.strokeWeight >= minweight.editValue &&
list.strokeWeight <= maxweight.editValue)
list.strokeWeight = setweight.editValue;
}
}
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.