Skip to main content
bebez71
Known Participant
June 5, 2019
Answered

How find strokes with different thicknesses

  • June 5, 2019
  • 5 replies
  • 2651 views

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?

Correct answer Jongware

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;

        }

    }

}

5 replies

Participating Frequently
September 23, 2025

No, InDesign does not support finding and replacing stroke weights within a range using built-in tools. You need a script to do that.

bebez71
bebez71Author
Known Participant
June 6, 2019

Great script [Jongware], compliments it works perfectly

bebez71
bebez71Author
Known Participant
June 5, 2019

Thanks wintermI did not know (or did not remember) this function in Acrobat.

And thanks to [Jongware], I found this workaround by reading his answer.

The strokes that are ok, are 100% black and are 1, 0.2 and 0.5 pt thick.

The wrong ones are thinner than 0.2 pt.

So I created a spot color and with the find/change, I applied it to that strokes (1, 0.2 and 0,5 pt), then I searched for all the strokes that were left black and replaced them with a thickness of 0.2 pt, then I deleted the color spot color, replacing it with black.

It worked!

Jongware
Community Expert
Community Expert
June 5, 2019

That is some excellent out-of-the-box thinking! It's how I'd also look for text which may have a different formatting – mark all 'correct' ones with a color and then look for what's left without the marker.

Just for fun, I'm going to go ahead and try if my idea works as well – it still may be handy to have around. Will report back if successful.

winterm
Legend
June 5, 2019

[Jongware]  wrote

I'm going to go ahead […] Will report back if successful.

Sounds very promising. I'm holding my breath already . We really need some functionality of this kind in ID.

Barb Binder
Community Expert
Community Expert
June 5, 2019

For others reading this thread who just want to update one variation—and not a range of variations—you can use an Object Find/Change.

~Barb

~Barb at Rocky Mountain Training
bebez71
bebez71Author
Known Participant
June 5, 2019

Let me explain better, I have a catalog of 64 pages, some strokes have been scaled in percentage and have a thickness that is 0.08 pt, but this thickness is not real because it is rounded by indesign (the actual measurement would be 0.07953 pt), so if I look for all tracks with a thickness of 0.08 pt I can't find anything.

Frans v.d. Geest
Community Expert
Community Expert
June 5, 2019

Leave the value blank in Search, and set 0.08 in Replace.

And if you need to change again, you now can Find value 0.08 and change that. But, big But, it will change AL lines to 0.08 when left blank, I don't know if that presents a problem of course f you need other line values NOT to change...

Anyway, a 'find 00.8 or any maller value' (a conditional search) is not possible...

Jongware
Community Expert
Community Expert
June 5, 2019

Not really; but isn't it easy enough to select all of your objects and then apply your new stroke weight?