Photoshop create selection from a Text Layer query...

Hi everyone,

I’m trying to create a selection from a text layer in Photoshop but as yet haven’t cracked it.
Imagine you have a PS doc with some text on a text layer. You hold the Cmd key down and click on the text layer, this loads a selection for the text.
It can also be done by selecting the text layer and then choosing Load Selection… from the Select menu. You can then load a Transparency Channel as a ‘new selection’.

Here’s the code I’ve been playing with so far but as yet no luck and I’ve tried a few variations on a theme.

tell application "Adobe Photoshop CS6"
	activate
	set doc to make new document
	set textLayer to make new art layer of doc with properties {kind:text layer}
	set properties of text object of textLayer to ¬
		{contents:"Fred Bloggs", position:{4 as inches, 1 as inches}, justification:center, stroke color:{class:RGB color, red:255, green:0, blue:0}, size:40, tracking:140, font:"Helvetica"} ¬
			
	set Doc_Ref to the current document
	tell Doc_Ref
		load selection from channel "Fred Bloggs"
	end tell
	
end tell

I’ve managed to achieve what I’d like by creating an action, to load the selection, and running that but that’s a bit of a workround.

Please can someone point me in the right direction.

Thanks in advance,

Nick

I don’t think that having an action is too much of a “work around”. I’ve made that a script requirement before. You could also use GUI to select the menu items.

If its recordable with an action then add the scriptlistener plug-in and use the output code.

It’s action manger syntax but you call it through the do javascript command.

There is documentation in the guides.

Hi guys,

Thanks for the help with this query.
Went down the SuperMacGuy route in the end. Created an action and triggered that.

Thank you once again,

Nick

This worked here using CS5

set loadTrans to "function loadLayerTransparancy() {
function cTID(s) { return app.charIDToTypeID(s); };
var desc73 = new ActionDescriptor();
var ref42 = new ActionReference();
ref42.putProperty( cTID('Chnl'), cTID('fsel') );
desc73.putReference( cTID('null'), ref42 );
var ref43 = new ActionReference();
ref43.putEnumerated( cTID('Chnl'), cTID('Chnl'), cTID('Trsp') );
desc73.putReference( cTID('T   '), ref43 );
executeAction( cTID('setd'), desc73, DialogModes.NO );
};
loadLayerTransparancy();"

tell application "Adobe Photoshop CS5"
	activate
	set doc to make new document
	tell doc
		set textLayer to make new art layer with properties {kind:text layer}
		set properties of text object of textLayer to ¬
			{contents:"Fred Bloggs", position:{4 as inches, 1 as inches}, justification:center, stroke color:{class:RGB color, red:255, green:0, blue:0}, size:40, tracking:140, font:"Helvetica"}
		
		do javascript loadTrans
	end tell
end tell