Skip to main content
Known Participant
November 3, 2022
Answered

random stroke weight/thickness script

  • November 3, 2022
  • 2 replies
  • 3174 views

Hello everyone, do you know if there is a free script to vary the thickness of the strokes randomly or in a parametric way? so far not found ... Thank you very much

Correct answer Sergey Osokin

You're right, Kurt also works like this ... I hadn't thought about it.
In any case, the Femkeblanco scripts are very useful.

Thank you all


Maybe you will also find this script useful. https://github.com/creold/illustrator-scripts/blob/master/md/Style.md#randomstrokewidth

2 replies

Kurt Gold
Brainiac
November 3, 2022

You may try Object menu > Transform > Transform Each with appropriate random settings.

 

Known Participant
November 3, 2022

thank you, but so I would transform and change the size and length of the strokes while I just want to change the weight / thickness of the lines

Kurt Gold
Brainiac
November 3, 2022

That should work as well if you enable the "Scale Strokes and Effects" option and disable the "Transform Objects" option at the bottom of the Transform Each dialog.

 

femkeblanco
Brainiac
November 3, 2022

Do you mean vary the thickness of the strokes from item to item? 

Known Participant
November 3, 2022

Hi, I mean that I have a series of strokes and I would like each one to have different thicknesses ... either randomly or by setting some range (min -max), thanks

femkeblanco
Brainiac
November 3, 2022

Select items.  You can change min and max in the first line.

var min = 1, max = 5;
var array = [];
function push(items) {
    for (var i = 0; i < items.length; i++) {
        if (items[i].typename == "PathItem") {
            array.push(items[i]);
        } else if (items[i].typename == "GroupItem") {
            push(items[i].pageItems);
        } else if (items[i].typename == "CompoundPathItem") {
            push(items[i].pathItems);
        }
    }
}
push(app.selection);
for (var i = 0; i < array.length; i++) {
    if (array[i].stroked)
    var x = Math.floor(Math.random() * (max - min + 1)) + min;
    array[i].strokeWidth = x;
}