Skip to main content
Inspiring
September 26, 2014
Answered

Rounding stroke thickness to nearest decimal?

  • September 26, 2014
  • 2 replies
  • 713 views

I have a project where many objects have been scaled up and down during the creation of the artwork. And I'm left with some lines that are .9581 pts and some that are 1.039 pts.

Just because I'm a neat freak, is there a script that would round the stroke thickness to the nearest .1 decimal? Or whole number? Or user selectable amount of decimals?

This topic has been closed for replies.
Correct answer pixxxelschubser

Navarro Parker,

loop through your path items of selection. This is simple, if only path items in your selection exists:

// StrokeThicknessRoundingNearestDecimal.jsx

// required: one or more selected stroked pathItem(s)

// Rounding stroke thickness to nearest decimal

// https://forums.adobe.com/message/6764907#6764907

// regards pixxxelschubser

var sel = app.activeDocument.selection;

for (i=0; i < sel.length; i++) {

if (sel.stroked == true) {

    sel.strokeWidth = Math.round(sel.strokeWidth*10)/10;

    }

}

But much more complicated, if there are compound paths or e.g. grouped paths or nested grouped grouped … paths and not possible for strokes which are added in the appearance palette.

Have fun

2 replies

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
Community Expert
September 26, 2014

Navarro Parker,

loop through your path items of selection. This is simple, if only path items in your selection exists:

// StrokeThicknessRoundingNearestDecimal.jsx

// required: one or more selected stroked pathItem(s)

// Rounding stroke thickness to nearest decimal

// https://forums.adobe.com/message/6764907#6764907

// regards pixxxelschubser

var sel = app.activeDocument.selection;

for (i=0; i < sel.length; i++) {

if (sel.stroked == true) {

    sel.strokeWidth = Math.round(sel.strokeWidth*10)/10;

    }

}

But much more complicated, if there are compound paths or e.g. grouped paths or nested grouped grouped … paths and not possible for strokes which are added in the appearance palette.

Have fun

pixxxelschubser
Community Expert
Community Expert
September 26, 2014

Hi Navarro Parker,

you can try something like this:

// required: one selected stroked pathItem

// Rounding stroke thickness to nearest decimal

// https://forums.adobe.com/message/6764907#6764907

// regards pixxxelschubser

var sel = app.activeDocument.selection[0];

if (sel.stroked == true) {

    sel.strokeWidth = Math.round(sel.strokeWidth*10)/10;

    }

Have fun

Inspiring
September 26, 2014

Works like a charm! Thank you!

Any way to get it to work on multiple selected paths?