Skip to main content
Inspiring
May 20, 2024
Answered

Access UPPERCASE setting by script in Illustrator

  • May 20, 2024
  • 2 replies
  • 1212 views

 

I need to read that option from TextFrame. Is there a way?
There's FontCapsOption in CharacterAttributes, but it seems it does different thing..

Thanks in advance.

This topic has been closed for replies.
Correct answer RobOctopus

What you're looking for is the capitalization attribute.

 

 

alert(app.activeDocument.textFrames[0].textRange.characterAttributes.capitalization)
app.activeDocument.textFrames[0].textRange.characterAttributes.capitalization = FontCapsOption.ALLCAPS
alert(app.activeDocument.textFrames[0].textRange.characterAttributes.capitalization)

 

 

on a blank document, this sample code just targets the first text frame and changes the capitalization setting to all caps. All of the Font Cap options you mentioned are what are used here

FontCapsOption.ALLCAPS

All Caps

FontCapsOption.ALLSMALLCAPS

All Smallcaps

FontCapsOption.NORMALCAPS

Normal Caps

FontCapsOption.SMALLCAPS

Small Caps

EDIT:

Wanted to also add. The above is a display change to the text. The text may internally be set as "Lorem Ipsum" but changed to display setting as All Caps would display as "LOREM IPSUM" while maintaining the internal text as "Lorem Ipsum". To access the Change case functionality you can either do a heavier coding approach to change the text contents or use the executeMenuCommand to access those commands.

https://ten-artai.com/illustrator-ccver-22-menu-commands-list/

app.executeMenuCommand("UpperCase Change Case Item")
app.executeMenuCommand("LowerCase Change Case Item")
app.executeMenuCommand("Title Case Change Case Item")
app.executeMenuCommand("Sentence case Change Case Item")

2 replies

RobOctopus
RobOctopusCorrect answer
Inspiring
May 20, 2024

What you're looking for is the capitalization attribute.

 

 

alert(app.activeDocument.textFrames[0].textRange.characterAttributes.capitalization)
app.activeDocument.textFrames[0].textRange.characterAttributes.capitalization = FontCapsOption.ALLCAPS
alert(app.activeDocument.textFrames[0].textRange.characterAttributes.capitalization)

 

 

on a blank document, this sample code just targets the first text frame and changes the capitalization setting to all caps. All of the Font Cap options you mentioned are what are used here

FontCapsOption.ALLCAPS

All Caps

FontCapsOption.ALLSMALLCAPS

All Smallcaps

FontCapsOption.NORMALCAPS

Normal Caps

FontCapsOption.SMALLCAPS

Small Caps

EDIT:

Wanted to also add. The above is a display change to the text. The text may internally be set as "Lorem Ipsum" but changed to display setting as All Caps would display as "LOREM IPSUM" while maintaining the internal text as "Lorem Ipsum". To access the Change case functionality you can either do a heavier coding approach to change the text contents or use the executeMenuCommand to access those commands.

https://ten-artai.com/illustrator-ccver-22-menu-commands-list/

app.executeMenuCommand("UpperCase Change Case Item")
app.executeMenuCommand("LowerCase Change Case Item")
app.executeMenuCommand("Title Case Change Case Item")
app.executeMenuCommand("Sentence case Change Case Item")
dolce5EC2Author
Inspiring
May 20, 2024

thanks for a detailed answer, RobOctobus it cleared my confusion between menu command and that setting - I was clicking menu command and reading setting to no avail, never tried to set set the setting by code. ..meanwhile menu command was modifyng actual text

dolce5EC2Author
Inspiring
May 20, 2024

Thanks for your answer and sorry for being unclear, I have updated the description now - but I need it in Illustrator...
Unfortuantely, illustrator's CharacterAttributes does not seem to to have this key. 

pixxxelschubser
Community Expert
Community Expert
May 20, 2024

@dolce5EC2 

Unfortunately, the last reply appears to be from an Ai bot. They've been flooding the forum lately with only marginally correct (but generally incorrect) answers.

 

Back to the topic:
What exactly do you want to find (capitalise letters or words or sentences or whole paragraphs? and what exactly do you want to do with the result?

 

Personally, I usually use REGEX (regular expressions) in Javascript for such cases. However, to set up a suitable rule for REGEX, you need to know exactly what you want to search for (and ideally also what you want to do with the result afterwards).