Skip to main content
Participating Frequently
March 11, 2020
Question

How to apply a brush and keep stroke weights

  • March 11, 2020
  • 4 replies
  • 2608 views

Hallo, 

I want to know if there is a chance to draws paths with different thicknesses and then assign a brush from the libraries that maintains the thickness of each individual stroke. thank you

vagh_studio

 

This topic has been closed for replies.

4 replies

rcraighead
Legend
March 13, 2020

Here's a JSX file ready to use.
brushdialog.jsx 
Install location can vary. For older Mac AI versions it is:
/Applications/Adobe Illustrator CC [version]/Presets.localized/en_US/Scripts

This link may help for PC and later AI CC versions: 
https://community.adobe.com/t5/illustrator/installing-scripts-in-latest-illustrator-cc-release-v-22-0-1/td-p/9669363?page=1

 

 

Participating Frequently
April 14, 2020

dear rCraighead thanks to your script!

I managed to speed up some operations that are useful for my graphic work.

A next step would be to be able to increase a set of tracks with different thickness with an increase in percentage. I mean, increase the thickness but not the length. Do you think it's possible? 

Thank you so much for all

 

vagh_studio

rcraighead
Legend
April 14, 2020

Certainly possible. I'll see if I can find some time today to play with the idea.

Ton Frederiks
Community Expert
Community Expert
March 12, 2020

Just in case vagh_studio was not expecting a script answer and is new to using a script, see: https://helpx.adobe.com/illustrator/using/automation-scripts.html

Participating Frequently
March 12, 2020

Yes Frederiks, you hit the mark. I have never used the script but I'll try to follow the directions. I use Illustrator experimentally and creatively. you see something inherent @vagh_studio IG page

 

Thank you for answering 

 

PS. I'm pretty sure once I apply a brush and keep stroke weights using simply AI C6

Ton Frederiks
Community Expert
Community Expert
March 12, 2020

Scripts are a good way to automate or add functions in Illustrator.

What the help file does not tell is how to save a script as shown above.

Copy the script text.

Open a text editor (TextEdit or Notepad)

Paste the text in a text only document (no formatting).

Save the document with a .jsx extension.

From Illustrator you can just browse to the script using File > Scripts > Other Scripts when you don't need it frequently.

rcraighead
Legend
March 12, 2020

Ok, thanks to some help from a friend, here's a better script with a dropdown menu of current brush names:

brushDialog();

function brushDialog(){
    var aDoc = app.activeDocument;
    var b = [];//Brush Name Array
    var i;
    for ( i = 0; i < aDoc.brushes.length; i++){
        b.push (aDoc.brushes[i].name);
        }
//~     Code for Import https://scriptui.joonas.me
    var brushName = new Window("dialog"); 
    brushName.text = "Choose a Brush"; 
    brushName.preferredSize.width = 350; 
    brushName.orientation = "row"; 
    brushName.alignChildren = ["center","top"]; 
    brushName.spacing = 10; 
    brushName.margins = 12; 
    var dropdown1_array = b;
    var dropdown1 = brushName.add("dropdownlist", undefined, undefined, {name: "dropdown1", items: dropdown1_array}); 
    dropdown1.selection = 0; 
    dropdown1.preferredSize.width = 250; 
    var button1 = brushName.add("button", undefined, undefined, {name: "button1"}); 
        button1.text = "Ok";
    brushName.show();
    var myBrush = aDoc.brushes[dropdown1.selection];
    var sel = app.selection;
    var i;
    for ( i = 0; i < sel.length;  i++){
    var myPath = aDoc.selection[i];
    var pathWidth = myPath.strokeWidth;
    myBrush.applyTo(myPath);
    myPath.strokeWidth = pathWidth;
    }
}


 

Ton Frederiks
Community Expert
Community Expert
March 12, 2020

Perfect!

rcraighead
Legend
March 11, 2020

See if this works for you:

Edit 2: I've added a prompt so you can type the "Brush Name" within the script. I want to learn how to have the user choose from a list of current brush names, but am not quite there yet.

 

 

assignBrush ();

function assignBrush (){
    var aDoc = app.activeDocument;
    var brush = prompt ("Type brush name");
    var myBrush = aDoc.brushes[brush];
    var sel = app.selection;
    var i;
    for ( i = 0; i < sel.length;  i++){
        var myPath = aDoc.selection[i];
        var pathWidth = myPath.strokeWidth;
        myBrush.applyTo(myPath);
        myPath.strokeWidth = pathWidth;
        }
    }