Hello all,
I saw the Appleshortcuts from PMP and was immediately enthusiastic. I have now also created images and automatically changed the content with AppleScript. Great. Thank you. But i am an Beginner.
I now have an Apple Numbers spreadsheet and each row represents an image (to be build with PMP) record. With different texts and images that I want to send automatically to PMP to create about 400 rows of different images. The script would have to read each line into variables and pass them to PMP.
Table Columns: Name, Text, Twitter, Picture 1, Picture 2, Age, email etc.
The stupid thing with AppleScript is that the script always looks simpler afterwards. I can read, but not able to develop
Maybe someone has already done something like this and can help me with such a script. I would also be happy to send a few virtual coffees.
Thanks for the help.
Holger
How to automatic create 400 different Pictures with Data from Apple Numbers and Templates in PMP
2022-03-22 10:33:06
2022-03-22 13:23:37
Hey Holger. This article here describes something pretty close: https://macosxautomation.com/pixelmator ... mbers.html
I think you should be able to adapt this script to your own workflow. Hope it helps!
I think you should be able to adapt this script to your own workflow. Hope it helps!
2022-03-22 23:46:42
Thank you very much Aurelija!
Great Support!
I will look now!
Thanks Holger
Great Support!
I will look now!
Thanks Holger
2022-04-07 07:04:09
Hi Aurelija,
i solved it with your example script works fine.
I am an Beginner of Apple Script my Code is not fine, but it works, will do a lot of finetuning and do more variables.
I have a Numbers Table with 7 Columns (5 Text und 2 Pictures) and a Pixelmator File.
Thanks for help!
i solved it with your example script works fine.
I am an Beginner of Apple Script my Code is not fine, but it works, will do a lot of finetuning and do more variables.
I have a Numbers Table with 7 Columns (5 Text und 2 Pictures) and a Pixelmator File.
Thanks for help!
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
-- Property definieren
property nameLayerName : "Name2"
property bildLayerName : "Bild"
property headlineLayerName : "Headline2"
property twitterLayerName : "Twitter"
property text1LayerName : "Text1"
property text2LayerName : "Text2"
property bild2LayerName : "Bild2"
try
activate
tell application id "com.apple.iWork.Numbers"
if not (exists document 1) then error number -128
tell front document
tell active sheet
if not (exists table 1) then error "The current spreadsheet does not include a table."
tell table 1
set Name2 to the value of cells 2 thru -1 of column 1
set the Bild to the value of cells 2 thru -1 of column 2
set the Headline2 to the value of cells 2 thru -1 of column 3
set the Tweet to the value of cells 2 thru -1 of column 4
set the Text1 to the value of cells 2 thru -1 of column 5
set the Text2 to the value of cells 2 thru -1 of column 6
set the Bild2 to the value of cells 2 thru -1 of column 7
end tell
end tell
end tell
-- set destinationDirectory to (choose folder with prompt "Select the folder in which to place the exported images:")
end tell
tell application "Pixelmator Pro"
activate
if not (exists document 1) then error "No document is open in Pixelmator Pro."
tell front document
if not (exists text layer headlineLayerName) then
error "The text layer “" & headlineLayerName & "” is not in the Pixelmator Pro document."
end if
-- ITERATE THE SPREADSHEET ROWS
set imageCount to the count of Name2
repeat with i from 1 to the imageCount
-- Textlayer
set thisnameLayerName to item i of Name2
set thisHeadline to item i of Headline2
set thistwitterLayerName to item i of Tweet
set thisbildLayerName to item i of Bild
set thisText1 to item i of Text1
set thisText2 to item i of Text2
set thisbildLayerName2 to item i of Bild2
-- Bildlayer
set bildpfad to thisbildLayerName
set bildpfad2 to thisbildLayerName2
-- Textlayer austauschen
set the text content of text layer nameLayerName to thisnameLayerName
set the text content of text layer headlineLayerName to thisHeadline
set the text content of text layer twitterLayerName to thistwitterLayerName
set the text content of text layer text1LayerName to thisText1
set the text content of text layer text2LayerName to thisText2
-- Bilder austauschen
tell application "Pixelmator Pro"
replace image the first layer of the front document with bildpfad scale mode scale to fit
replace image the second layer of the front document with bildpfad2 scale mode scale to fit
end tell
-- Export the image
set imageBaseName to "Macintosh HD:Users:holgergelhausen:Desktop:"
export it to (imageBaseName & thisHeadline & "777788899.png") as PNG with properties {compression factor:100}
end repeat
end tell
end tell
on error errorMessage number errorNumber
if errorNumber is not -128 then
activate
tell current application
display alert "ERROR" message errorMessage buttons {"Cancel"} default button 1
end tell
end if
end try