cheaking each word may be a bit faster.
What if single word have different styles like "ABCD"?
im not near a computer so only tossing ideas.
if you duplicated a text frame in a new doc. Would it bring with it the styles used?
then you might be able to cycle through the new documents styles.
All I need to get the different styles in a single textframe. No one stop you to apply different styles in a single word, it's just a case (although even I wonder why people need this ).. If you see in Indesign, there is a property "textStyleRanges" which gives the array of different text style ranges, we don't have to iterate through character by character or word by word.
So All I am looking for some better script to get the character styles I did try something like this,
var textRangeLength = textFrame.textRanges.length;
for (var i = 0; i < textRangeLength; i++)
var noOfCharacterStyles = textFrame.textRanges[i].characterStyles.length;
By executing above code, what happening is as follows,
Suppose we have a textFrame with content "ABCD EFGH CD"..
then textRangeLength becomes 12.. and its calculating character attributes applied on each character.
And what I am looking for, it should return the characterStyle as,
First style object will be "A"
Second style object will be "B"
then third will be "C"
then fourth will be "D EFGH "
and then "C" again...
I hope it makes sense. Thanks for any help..
another Hack workaround, but it might help...
if you copy a text frame and paste in a new doc, it brings with it the used CharStyles.
from there you can just get the documents CharStyles then close the new doc without saving.
var doc = app.activeDocument; app.executeMenuCommand ('copy'); var newDoc = app.documents.add(); newDoc.activate(); app.executeMenuCommand ('paste');
I got the idea from your previous reply. But I dont want to open a new doc, the reason is all open/close new doc process will be visible. Is there any other work around so that I don't have to open a new doc and all the things will be done in the same doc?
again I'm not at a computer so only tossing ideas.
without any visible happening I would be back to cycling through each char.
the only other thing that may be worth exploring is maybe minamizing illustrator all together.
never even thought about it so not sure if it's even possible.
But it should be quite fast to create new doc grab info and close that you should only get a bit of a flicker.
i'll have a play tomorrow and see what I can come up with.
if its for use on a PC I may be able to get a different hack working. But mac would be out of luck.