tell application "Pixelmator Pro"
activate
tell its front document
-- prompt for settings
set _r to text returned of ¬
(display dialog "Roundness? (0..100):" default answer "50" buttons {"Cancel", "OK"} default button "OK")
set _r to _r as number
set _s to text returned of ¬
(display dialog "Softness? (0..100):" default answer "50" buttons {"Cancel", "OK"} default button "OK")
set _s to _s as number
set _e to text returned of ¬
(display dialog "Expand? (-100..100):" default answer "-20" buttons {"Cancel", "OK"} default button "OK")
set _e to _e as number
-- cache selected layers
set selected_layers to selected layers
-- Process each layer
repeat with l in selected_layers
deselect
unmask l
load selection of the l mode add selection
refine selection roundness _r softness _s expand _e
mask l
end repeat
-- restore selected layers
set selected layers to selected_layers
end tell
end tell