Copy link to clipboard
Copied
Is there any way to find out which one, between stroke or fill, is active for a particular document using illustrator scripting?
I have to apply color on the selected object accordingly.
If fill is active then i use obj.fill.color = 0xff00ff; and,
if stroke is active then i use obj.stroke.color = 0xff00ff;
But i am not able to find which one is active..
Any help would be appreciated...
Thanx...
Copy link to clipboard
Copied
I think as far as script is concerned the object is selected from that you can access and change either… Only the GUI has the change either fill/stroke by making it foremost… oh and the swapper
Copy link to clipboard
Copied
Thanx for the reply...
I am able to get the selected object but how can i access stroke/fill to find out which one is foremost.
I have to just find out which one is active.
Copy link to clipboard
Copied
You can check the properties filled and stroked to see if the object has either, both or none… No such thing as foremost… If you are talking about the stacking of the appearance palette then you have NO access to that…
Copy link to clipboard
Copied
Thanx Mark...
I had used these properties filled and stroked but it doesnt give me what i want...
Here is the sample code:
pathArt = new PathItem();
if(pathArt.selected)
{
if(pathArt.filled == true)
pathArt.fillColor = colorValue;
else if(pathArt.stroked == true)
pathArt.strokeColor = colorValue;
}
value of both pathArt.filled and pathArt.stroked are true, it didnt tell me which one(stroke/fill) is active.
Anyways thanx for ur help i'll find any work around....
Copy link to clipboard
Copied
I've found this thread in 2024. This is what works in Illustrator 28.4.1:
var isStroke = app.isStrokeActive() ? true : false;
if(isStroke){
var tmpObj = doc.defaultStrokeColor;
}else{
var tmpObj = doc.defaultFillColor;
}
alert([tmpObj.red, tmpObj.green, tmpObj.blue,].join(', '));
Find more inspiration, events, and resources on the new Adobe Community
Explore Now