Applescripting in Pixelmator Pro 2?

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

2020-11-25 16:35:30

I have been looking to create some example scripts which would do simple things like rotate a selected object, but the AppleScript dictionary for Pixelmator Pro 2 seems to be limited to rotating the entire document??

Is it really not possible to rotate an object via AppleScript??

I created another script to add a basic vignette to a selected layer, but that also failed :cry:

Are there any example scripts for rotating objects and adding vignettes which anyone knows of - it would be much appreciated.

Thank you all in advance.
User avatar

2020-11-27 09:12:10

Hey Richard, to rotate objects, you don't need a special command, you set the layer's rotation property. Like so:
tell application "Pixelmator Pro"
	tell the front document
		set the rotation of layer 1 to 45
	end tell
end tell
As for adding a vignette, that's one of the properties of the color adjustments of a layer and there are four in total: the vignette itself which is a boolean (true or false), and three properties which take integer values, i.e. vignette exposure, vignette black point, and vignette softness. So to simply enable the default vignette, you'd use:
tell application "Pixelmator Pro"
	tell the front document
		set the vignette of the color adjustments of layer 1 to true
	end tell
end tell
If you wanted to set all the options, the code would look something like this:
tell application "Pixelmator Pro"
	tell the front document
		set the vignette of the color adjustments of layer 1 to true
		set the vignette exposure of the color adjustments of layer 1 to 60
		set the vignette black point of the color adjustments of layer 1 to 10
		set the vignette softness of the color adjustments of layer 1 to 90
	end tell
end tell
And if you were to tidy that up a little to remove some repetition, it would look like this:
tell application "Pixelmator Pro"
	tell the front document
		tell the color adjustments of layer 1
			set its vignette to true
			set its vignette exposure to 60
			set its vignette black point to 10
			set its vignette softness to 90
		end tell
	end tell
end tell
User avatar

2020-11-27 17:52:26

Thank you so much Andrius - I appreciate you taking the time to help - now it makes more sense.
User avatar

2020-11-27 21:00:43

I created the script below, expecting it to rotate counter-clockwise, but it rotates clockwise?
tell application "Pixelmator Pro"
	tell the front document
		set the rotation of layer 1 to -90
	end tell
end tell

I also have this code which I expected to rotate clockwise, but it rotates counter clockwise?
tell application "Pixelmator Pro"
	tell the front document
		set the rotation of layer 1 to 90
	end tell
end tell
Unless I'm very much mistaken - this seems to be completely unintuitive, and illogical??

UPDATE:
This also happens when the arrange tool is selected, and you change the rotation from there!
Positive numbers rotate counter-clockwise, and negative numbers rotate clockwise!

Please tell me this is a bug, and not intentional???