Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
The skill of scripting in Illustrator is to (due to necessity) find the most difficult way to achieve the simplest of tasks...
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
Just like you said earlier
imagecollection Apr 7, 2015 6:01 PM (in response to Silly-V) 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
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now