Copy link to clipboard
Copied
Hi All,
I have checked the Photoshop Object model for apply "World_ready layout " to all text layers in the .psd files, but I can't find any possibilites over there. Is it possible via Action manager code or scripting and also I want to apply Horizontal and Vertical Diacritics to be set to 0.
Copy link to clipboard
Copied
Hi All,
Is there any way to enable the world-ready layout in the photoshop document via any scripting language
Copy link to clipboard
Copied
Try setting up a Text Tool Preset with that option set and select that preset in your script after activating the text tool it should work.
Script and actions can do very little when it come to setting Photoshop UI options.
Copy link to clipboard
Copied
Thanks Mack. Could you please explain in detail how to append the "world-ready layout" option in tool preset? and this new approach for me.
Copy link to clipboard
Copied
Activate the text tool in Photoshop set the font the paragraph options etc etc you want to be used with the text tool. Once All is like you want to use the text tool. Create a new text tool preset.
Copy link to clipboard
Copied
I have tried, but I can't able to apply the preset for texts in the psd files. It's applied for newly created text after selecting the customized presets. Is it right?
Is it possible to apply the above via Action Manager Code?
Copy link to clipboard
Copied
I have tried the same with photoshop actions, it will apply the "World-Ready layout", but it will change all other properties into text which is used for recorded the action. Is it possible in Photo action to change the only one property as I want?
Copy link to clipboard
Copied
Script do not have an easy way to change Photoshop UI tools options with Adobe DOM code. However someone recently in the past few days posted a script that can toggle some tool sampling mode options. What you want to do may be possible from reading that script code there seems to be a current tool option object. So you may be able to retrieve the text tool current options set the world in the object the commit the change to the current text layer you are editing. You need to know how Action Manager code works. That is above my pay grade. I just hack a little at Photoshop scripting. I do not actually know javascript....
// get current tool options object
function getCTO(){
var ref = new ActionReference();
ref.putProperty(stringIDToTypeID("property"), stringIDToTypeID("currentToolOptions"));
ref.putEnumerated(stringIDToTypeID("application"), stringIDToTypeID("ordinal"), stringIDToTypeID("targetEnum"));
return executeActionGet(ref).getObjectValue(stringIDToTypeID("currentToolOptions"));
}
// setting currentToolOptions with options array
function setCTO( options, isIdTypeString ){
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( stringIDToTypeID( app.currentTool ) );
desc.putReference( stringIDToTypeID( "target" ), ref );
// getting current tool options so that they do not get reset
var ctoObj = getCTO();
// check if we are setting the eyedropper tool
if ( app.currentTool=="eyedropperTool" ){
ctoObj.putInteger( stringIDToTypeID( options[0][0] ), options[0][1] );
} else {
// iteration through options array and putting booleans into cto descriptor
for (var i=0; i < options.length; i++){
if (isIdTypeString==true){
ctoObj.putBoolean( stringIDToTypeID( options[i][0] ), options[i][1] );
} else {
ctoObj.putBoolean( charIDToTypeID( options[i][0] ), options[i][1] );
}
}
}
desc.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "currentToolOptions" ), ctoObj );
executeAction( stringIDToTypeID( "set" ), desc, DialogModes.NO );
}
Copy link to clipboard
Copied
Now I have change my approach and created the Photoshop actions to apply "World Ready layout" and Diacritcs for specific Thai langauge. Now I'm trying to integrate the actions with the below javascript code. It apply the actions for first layer only and not apply for remaining text layers. Could you help me how to get rid out of this?
#target photoshop
loadActions();
digitalStyling()
unLoadActionSet("TH_Styling")
function digitalStyling() {
var Psd_Doc = app.activeDocument;
for (var i=0; i<Psd_Doc.layers.length;i++) {
var theLayer = Psd_Doc.layers[i];
if (theLayer.typename == 'LayerSet') {
var mySub_Layer = theLayer.layers;
for (var j=0; j<mySub_Layer.length;j++) {
if(mySub_Layer[j].kind == LayerKind.TEXT ) {
if(mySub_Layer[j].textItem) {
playAction("TH_Styling", "World-Ready-Layout")
}
}
}
}
else if (theLayer.typename == 'ArtLayer'){
if(theLayer.kind == LayerKind.TEXT ) {
if(theLayer.textItem) {
playAction("TH_Styling", "World-Ready-Layout")
}
}
}
}
}
function playAction(actionSet, actionName){
var idPly = charIDToTypeID( "Ply " );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idActn = charIDToTypeID( "Actn" );
ref1.putName( idActn, actionName );
var idASet = charIDToTypeID( "ASet" );
ref1.putName( idASet, actionSet );
desc2.putReference( idnull, ref1 );
executeAction( idPly, desc2, DialogModes.NO );
}
function loadActions () {
var actionFile = File("~/Documents/Adobe Scripts/TH_Styling/TH_Styling.atn");
if(!actionFile.exists){
alert("Action file does not exist!");
return;
}else{
app.load(actionFile);
}
};
function unLoadActionSet(actionSet){
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putName( charIDToTypeID( "ASet" ), decodeURI(actionSet));
desc.putReference( charIDToTypeID( "null" ), ref );
executeAction( charIDToTypeID( "Dlt " ), desc, DialogModes.NO );
};
For action file
TH_Styling.zip
Copy link to clipboard
Copied
I as able to get the code functions via ScriptingListener. Here is code for applying "World Ready Layout" & "Latin and East-Asian Layout":
setWorldReadyLayout();
function setWorldReadyLayout() {
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty( stringIDToTypeID( "property" ), stringIDToTypeID( "paragraphStyle" ));
reference.putEnumerated( stringIDToTypeID( "textLayer" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ));
descriptor.putReference( stringIDToTypeID( "null" ), reference );
descriptor2.putEnumerated( stringIDToTypeID( "textComposerEngine" ), stringIDToTypeID( "textComposerEngine" ), stringIDToTypeID( "textOptycaComposer" )); // World-Ready Layout code
descriptor.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "paragraphStyle" ), descriptor2 );
executeAction( stringIDToTypeID( "set" ), descriptor, DialogModes.NO );
}
setLEALayout();
function setLEALayout() {
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
var reference = new ActionReference();
reference.putProperty( stringIDToTypeID( "property" ), stringIDToTypeID( "paragraphStyle" ));
reference.putEnumerated( stringIDToTypeID( "textLayer" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ));
descriptor.putReference( stringIDToTypeID( "null" ), reference );
descriptor2.putEnumerated( stringIDToTypeID( "textComposerEngine" ), stringIDToTypeID( "textComposerEngine" ), stringIDToTypeID( "textLatinCJKComposer" )); // Latin and East-Asian Layout code
descriptor.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "paragraphStyle" ), descriptor2 );
executeAction( stringIDToTypeID( "set" ), descriptor, DialogModes.NO );
}
Copy link to clipboard
Copied
how to use this code