Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Applescript can't change font of text layer

Explorer ,
Oct 12, 2015 Oct 12, 2015

I used Applescript to create a text layer and specify its properties, but when I specify the font I get a compile error:

Can’t set «class cFnt» to "TradeGothic-Bold". Access not allowed.

Which sounds like some kind of permission error.

Here's a simplified bit of the script:

tell application "Adobe Photoshop CS4"

tell current document

make new art layer with properties {name:"File Name", kind:text layer}

tell text object of art layer 1

set {contents, size, stroke color, position, kind} to {"thefilename", 12, {class:RGB hex color, hex value:"CC0000"}, {2, 12}, paragraph text}

set font to "TradeGothic-Bold"

end tell

end tell

end tell

If I set the font manually and use "get properties of text object of art layer 1" , the Script Editor returns (along with a long list of other properties):

font:"TradeGothic-Bold"

so I think I've specified the name of the font correctly at least. In the list of properties returned by Script Editor, font is blue as above, but all the other properties names are purple. That's gotta mean something.

TOPICS
Actions and scripting
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Oct 12, 2015 Oct 12, 2015

Okay, after some trial and error, I've answered my own question. Here's what worked:

tell application "Adobe Photoshop CS4"

tell current document

make new art layer with properties {name:"File Name", kind:text layer}

tell text object of art layer 1

set {contents, size, stroke color, position, kind} to {"thefilename", 12, {class:RGB hex color, hex value:"CC0000"}, {2, 12}, paragraph text}

end tell

set font of text object of art layer 1 to "TradeGothic-Bold"

end tell

end tell

Maybe someone who understands O

...
Translate
Adobe
Explorer ,
Oct 12, 2015 Oct 12, 2015
LATEST

Okay, after some trial and error, I've answered my own question. Here's what worked:

tell application "Adobe Photoshop CS4"

tell current document

make new art layer with properties {name:"File Name", kind:text layer}

tell text object of art layer 1

set {contents, size, stroke color, position, kind} to {"thefilename", 12, {class:RGB hex color, hex value:"CC0000"}, {2, 12}, paragraph text}

end tell

set font of text object of art layer 1 to "TradeGothic-Bold"

end tell

end tell

Maybe someone who understands OOP and/or AS better than I do, can explain why that worked and my first try did not.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines