Photoshop CS and Layer Masks

Hey Guys,

I’m trying to write a script that can loop through all the layers of a Photoshop CS Document and if a layer mask exists either apply it or remove it (based on a dialogue)…

I’ve spent all day looking through the dictionary and the various scripting guide pdfs… but can’t find anything to do with layer masks!

Has any one else noticed this? Or am I being dense and looking for the wrong thing? Could it be possible to work round this using actions or something?

Any help would be gratefully appreciated!

Thanks,

Tom

Hey,

I’ve got a VERY DIRTY work around… that sort of works… can any one think of a better way?


tell application "Adobe Photoshop CS"
	tell document 1
		activate
		set x to count of layers
		repeat with i from 1 to x
			set current layer to layer i
			ignoring application responses
				do action "Remove_Layer_Mask" from "Default Actions.atn"
			end ignoring
			tell application "System Events" to tell process "Adobe Photoshop CS"
				repeat 2 times --if no layer mask is present then two alerts open
					delay 3 --wait for alerts to open
					keystroke return --press OK
				end repeat
			end tell
			delay 2 --wait for action to finish
		end repeat
	end tell
end tell

Any ideas?

Thanks,

Tom