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

Is there any way to find out what brush is applied to a path?

Community Expert ,
Apr 04, 2015 Apr 04, 2015

I'm trying to write a script: select some paths, run the script, then each path that has a brush applied to it is changed to use a random brush whose name is sufficiently similar to its current brush. The application is pretty obvious - draw a bunch of lines in, say, 'ragged marker 1', then give it some extra liveliness by having five or six 'ragged marker' brushes that get randomly chosen.

The problem I'm running against is that as far as I can tell, Illustrator only lets Javascript set what brush an object is using with brush.applyTo (artItem), but I can't seem to find any way to find out what path a brush is currently using via JS.

Am I just not looking in the right place of the Javascript reference, or is this really a thing that only has a setter, with no corresponding getter?

TOPICS
Scripting
1.1K
Translate
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
Guide ,
Apr 04, 2015 Apr 04, 2015

I can't see any way you can do this directly.

JS can be quite limiting.

If you are applying the brush to the path with JS initially then you could tag it with the brush name at the same time,

then when you call the pathItem.name you would get its applied brush

Translate
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
Valorous Hero ,
Apr 07, 2015 Apr 07, 2015
or is this really a thing that only has a setter, with no corresponding getter?

One of many!

You could have a very convoluted workaround, though, if you assign a specific spot color to every brush in your palette. Then, you can have a system where you can determine the 'brush' by the color which remains on an ink plate when others are in some way hidden. It's silliness, thank you thank you.

Translate
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 ,
Apr 07, 2015 Apr 07, 2015

The skill of scripting in Illustrator is to (due to necessity) find the most difficult way to achieve the simplest of tasks...

Translate
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
Participant ,
Apr 07, 2015 Apr 07, 2015

I'm surprised you can't do something similar to;

//Created by Zantcor

//used to find the brush that is applied

var mydoc = app.activeDocument;

var allBrushes = mydoc.brushes;

var usedbrushcount = mydoc.brushes.length;

var selecteditem = mydoc.selected

for (i=0;i<usedbrushcount;i++)

{

    if (selecteditem = PathItem && selecteditem.BrushType == allBrushes)

    {

    

        alert ("The brush type is [ " + allBrushes.name + " ]")

    

        }//end if

}//end for

The above doesn't work but it does list the brushes that are being used in the document if you want to use it like this;

//Created by Zantcor

//used to find the brush that is applied

var mydoc = app.activeDocument;

var allBrushes = mydoc.brushes;

var usedbrushcount = mydoc.brushes.length;

for (i=0;i<usedbrushcount;i++)

{

        alert ("The brush type is [ " + allBrushes.name + " ]")

}//end for

Translate
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 ,
Apr 07, 2015 Apr 07, 2015

Lets hand write a Phone Book...

what if you take each path item,

duplicate in a new document,

then list used brush.

Iv'e not tried this, but even if it works it would be slow...

Translate
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
Participant ,
Apr 08, 2015 Apr 08, 2015

Just like you said earlier

3.  Re: Is there any way to find out what brush is applied to a path?

  imagecollection    Community Member

 

The skill of scripting in Illustrator is to (due to necessity) find the most difficult way to achieve the simplest of tasks...

so to retort I say this;

“I suppose it is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail.”

  ― Abraham Maslow, Toward a Psychology of Being

Translate
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
Community Expert ,
Apr 08, 2015 Apr 08, 2015
LATEST

Well, at least I'm pretty sure it's not just that I'm missing something obvious in the JS reference. Illustrator's JS API really is that stupid.

Guess I'll write another feature request to add to my collection of things I keep asking for every release. I've been asking for some of them for multiple years but everyone needs an impossible dream or two.

Translate
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