• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Random brush stroke

Community Beginner ,
Jan 16, 2019 Jan 16, 2019

Copy link to clipboard

Copied

I download this script that randomly fill all selected paths with the selected swatches:

mySelection = app.activeDocument.selection;

myDoc = app.activeDocument;

if (mySelection instanceof Array)

{

selSwatches = myDoc.swatches.getSelected();

if(selSwatches.length != 0)

for (i=0; i<mySelection.length; i++)

{

if(mySelection.typename == "PathItem" || mySelection.typename == "CompoundPathItem")

{

selItem = mySelection;

selItem.filled = true;

swatchIndex = Math.round( Math.random() * (selSwatches.length - 1 ));

if(selItem.typename == "PathItem")

selItem.fillColor = selSwatches[swatchIndex].color;

else

selItem.pathItems[0].fillColor = selSwatches[swatchIndex].color;

}

}

}

I would like to adapt it to stroke randomly with all selected brushes

TOPICS
Scripting

Views

800

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
New Here ,
Aug 23, 2020 Aug 23, 2020

Copy link to clipboard

Copied

This would be amazingly useful!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 24, 2020 Aug 24, 2020

Copy link to clipboard

Copied

LATEST

There is no function to "get" selected brushes, but you can still choose which brushes to randomly apply.  In the snippet below, you choose a list of brushes based on a first and last.  (Brushes are numbered starting with 1 from the panel's upper left .)

 

firstBrushNo = 2; // <- enter number
lastBrushNo = 4; // <- enter number
theBrushes = app.activeDocument.brushes;
for (i = 0; i < app.selection.length; i++){
  brushIndex = Math.floor(Math.random()*((lastBrushNo - 1) - (firstBrushNo - 1) + 1)) + (firstBrushNo - 1);
  theBrushes[brushIndex].applyTo(app.selection[i]);
}

 

For example, you can choose to randomly apply the brushes between the second and fourth (inclusive). 

 

Untitled2000.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines