2

I have a bunch of lineworks with different stroke weights. Is there a direct way to reduce/increase all stroke weights proportionally without changing the size of the objects?

Thanks, Newton

3 Answers 3

3

You may use the following script. It changes the widths of all strokes in document accordingly to the percentile value.

//here you can change the stroke percentual
var myA = prompt("Choose your %","80","Change width stroke");
var myPercentile = myA/100;

if(myA!=null){

    // choose all page elements
    for (var i=0;i<app.activeDocument.pageItems.length;i++){
        var myLayer = app.activeDocument.pageItems[i];

        //if element is compound make a new loop for pathItems
        if(myLayer.typename=="CompoundPathItem"){
            for(var u=0;u<myLayer.pathItems.length;u++){

                //take actual stroke size
                var myPath = myLayer.pathItems[u];
                var myMeasure = myPath.strokeWidth;

                //transform the stroke width into % choose at start
                myPath.strokeWidth = myMeasure*myPercentile;
                }

            }

        if(myLayer.typename=="PathItem"){
                var myMeasure = myLayer.strokeWidth;
                myLayer.strokeWidth = myMeasure*myPercentile;
            }
        }
    }
3
  • 1
    How to make it only aply for selected items Nov 20, 2015 at 6:34
  • Using strokeWidth is not adequate if an object has multiple strokes. Jul 14, 2021 at 3:38
  • @bisketashwin this script doesn't let you do that because it doesn't target selected items, but the entire page's items. Nov 21, 2021 at 15:10
2

Choose transform → scale scale down (or up to increase) with scale strokes and effects enabled. Then yet again scale with opposite scale value, this time disable scale strokes and effects. Done.

This is not very good approach if your using pixel snapping as it introduces jitter (instead of a matrix concatenation). In this case i would consider scripting this.

2
  • here we can scale stroke along object scaling. But what is required is scaling just strokes without scaling object Nov 20, 2015 at 7:21
  • 1
    @bisketashwin That is exactly what im describing. Step 1 You scale object with scale strokes enabled. step2 then you disable the scale strokes option and scale in reverse. End result strokes scale object stays the same. So my answer accomplishes what is required. Try it works, it is a standard affine transformation trick that is so common it even has a scientific name.
    – joojaa
    Nov 20, 2015 at 10:54
0

Simply run this script:

if (documents.length) {
    sel = activeDocument.selection;
    if (sel[0]) {
        dial = new Window("dialog", "Scale Stroke Width");

        gr = dial.add("group");
        gr.add("statictext", undefined, "Scale Stroke Width by:");
        perc = gr.add("edittext");
        perc.characters = 5;
        perc.onChanging = function () {ok.enabled = !isNaN(perc.text)}
        gr.add("statictext", undefined, "%");

        ok = dial.add("button", undefined, "OK");

        if (dial.show() == 1) for (i = 0; i < sel.length; i++)
        sel[i].resize(100, 100, undefined, undefined, undefined, undefined, perc.text);
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.