Skip to main content
Inspiring
May 9, 2012
Question

Get to know which one is active Stroke or Fill for the document.

  • May 9, 2012
  • 2 replies
  • 1173 views

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...

This topic has been closed for replies.

2 replies

Known Participant
May 4, 2024

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(', '));
Inspiring
May 9, 2012

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

Inspiring
May 10, 2012

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.

Inspiring
May 10, 2012

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…