AppleScript Error?

A place to talk about anything else with other Pixelmator users.
User avatar

2020-11-25 16:01:00

I have the following code which I want to simply add a basic vignette to an open image - however, the script throws an error saying it cannot set vignette to true??

Can anyone help?
tell application "Pixelmator Pro"
	activate
	tell the front document
		if not (count selected layers) = 1 then
			display alert "Make sure a single layer is selected."
		end if
		
		
		enhance
		
		tell its color adjustments
			
			set its vignette to true
			
			set its exposure to 60
			set its softness to 100
			
		end tell
		
	end tell
	
end tell
User avatar

2020-11-27 09:19:49

I commented on this in your other thread, but the reason it's throwing an error here is that color adjustments is a property of layers rather than documents. The enhance command defaults to the currently selected layer, but that won't always be the case, so it's best to be specific about which layer you'd like to edit. If you have one layer in your document and you were to use the following basic format, you should be OK:
tell application "Pixelmator Pro"
	tell the front document
		tell layer 1
			-- Your code goes here
		end tell
	end tell
end tell
Of course, when exporting you need to make sure you're telling the document object to export rather than layer objects. But most of the time, you'll be telling layers to do stuff.
User avatar

2020-11-27 17:53:10

Thank you Andrius - much appreciated.