AppleScript - Move Layers

Discuss and share Pixelmator Pro resources such as templates, mockups, and tutorials.
User avatar

2022-02-21 11:40:27

Hey,

I thought I'd share a quick script I wrote for myself to move layers with precision (in other words, adjust layers position by the precise number of pixels).
tell application "Pixelmator Pro"
	activate
	tell its front document
		
		set x_adj to text returned of ¬
			(display dialog "Move left/right:" default answer "0" buttons {"Cancel", "OK"} default button "OK")
		set x_adj to x_adj as number
		
		set y_adj to text returned of ¬
			(display dialog "Move top/bottom:" default answer "0" buttons {"Cancel", "OK"} default button "OK")
		set y_adj to y_adj as number
		
		
		set selected_layers to selected layers
		repeat with l in selected_layers
			set {x_old, y_old} to position of l
			set position of l to {(x_old + x_adj), (y_old + y_adj)}
		end repeat
	end tell
end tell
User avatar

2023-11-08 14:39:04

Looks good, thank you! I am currently trying to move layers up and down with applescript and found this post