AppleScript Question

Talk about Pixelmator Pro, share tips & tricks, tutorials, and other resources.
User avatar

2021-12-07 19:58:56

I am trying to iterate through the layers, select a color, clear that selection, and then save. I can get everything to work except the clear part. Any suggestions?

Thanks

tell application "Pixelmator Pro"
set exportLocation to choose folder with prompt "Please choose where you'd like to export the images:"
tell the front document
set visible of every layer to false
repeat with currentLayer in every layer

set visible of currentLayer to true
trim canvas
select color range color {0, 0, 65535} range 80
clear currentLayer. -- layer doesn't understand clear message
export for web to ((exportLocation as text) & name of currentLayer & ".png") as PNG with properties {compression factor:100}
reveal canvas
set visible of currentLayer to false
end repeat
end tell
end tell
User avatar

2021-12-15 10:08:48

Hey there, sorry for the late reply! You've probably figured this one out by this time but if you're still having issues (or in case anyone else comes across this thread with a similar one), try dropping the "currentLayer" after Clear. It's a document-wide command, so you don't need to specify a layer to be cleared.
User avatar

2021-12-15 19:19:52

Thank you
User avatar

2021-12-22 14:39:50

by dick rick 2021-12-15 17:19:52 Thank you
:pray: