I have a layers action manager index and now I'd like to query if it's a "textLayer" so I can then get a bunch of font information. Unfortunately I've stumbled just out of the gate and can't resolve how to check if a layer is text using aciton manager code. I was trying something like this, but I think my ref.put is just defining a new class so it will always return true. I couldn't solve how to use desc.getClass() or ref.getDesiredClass():
Code: Select allfunction isTextLayer(idx)
{
var ref = new ActionReference();
ref.putIndex(charIDToTypeID("TxLr"),idx);
return typeIDToStringID(ref.getDesiredClass()) == "textLayer" ? true:false;
}
Any help on this first part is much appreciated! Thanks,
Russ
Action Manager - isTextLayer()
-
Mike Hale
Action Manager - isTextLayer()
I suggest you check the layer's descriptor for a key that only a text layer would have. Something like this.
Code: Select allfunction isTextLayer(amIndex){
var ref = new ActionReference();
ref.putProperty( charIDToTypeID( "Prpr" ), charIDToTypeID( "Txt " ) );
ref.putIndex( charIDToTypeID("Lyr "), amIndex );
try{
var desc = executeActionGet(ref);
}catch(e){ return; }// return undefined on error( bad index )
return Boolean(desc.count);// return true or false depending on if property exists
};
Code: Select allfunction isTextLayer(amIndex){
var ref = new ActionReference();
ref.putProperty( charIDToTypeID( "Prpr" ), charIDToTypeID( "Txt " ) );
ref.putIndex( charIDToTypeID("Lyr "), amIndex );
try{
var desc = executeActionGet(ref);
}catch(e){ return; }// return undefined on error( bad index )
return Boolean(desc.count);// return true or false depending on if property exists
};
-
russ_c
Action Manager - isTextLayer()
Cheers, thanks Mike. Is there documentation on property charIDs like "Txt " etc? I've read through the PS scripting guide and the explanations of ActionReference() and ActionDescriptor() methods is a bit lacking. I wish there was more then scriptlistener to reference charIDs.
Thanks again,
Russ
Thanks again,
Russ
-
Mike Hale
Action Manager - isTextLayer()
You can find a list of char and string IDs in the Photoshop SDK. Xbytor's xtools also has a list in 'PSConstants.js'. But neither of those explain much and will not tell you where or when to use an ID.
Xtools 'GetterDemo.jsx' or a similar script can be useful in determining what keys are in an Action Descriptor.
Xtools 'GetterDemo.jsx' or a similar script can be useful in determining what keys are in an Action Descriptor.