Copy link to clipboard
Copied
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.
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
...Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now