I am relatively new to scripting for illustrator and I am having a hard time wrapping my head around it.
I would like to select some text (the whole range) and set some attributes to it.
I have named the text object in the layers panel and if possible, I would like to select it by name. (or any other easy/direct way you may suggest)
This is how I reference my objects by name.
doc = app.activeDocument;
doc.pageItems.getByName('myname');
I was hoping I could do keep it simple like so....
doc.pageItems.getByName('myname').characterAttributes.size = 30;
Needless to say, this doesn't seem to work. I was looking into making characterStyles
as well but that is much more complex so setting individual attributes would be my first step.
Any help would be greatly appreciated!
Ok, so I figured it out.... I was missing the .textRange
selector.
doc.pageItems.getByName('myname').textRange.characterAttributes.size = 500;
This works great for most all of the attributes, I still can't seem to set the .textFont
attribute by the font name. I can set it using the index, but that's no good as I update my fonts quite often.
doc.pageItems.getByName('myname').textRange.characterAttributes.textFont = app.textFonts[7];
Even after retrieving the name of the font, I can't set it... I assumed the way would be something like...
doc.pageItems.getByName('myname').textRange.characterAttributes.textFont = "Arial";
No Luck Though...