I've been working on a script with a lot of help from the community here. Very thankful for all of it. I have run into a bug. This is a script that I only run on text layers. The script will perform some tasks that some of it depends on whether or not Leading is set to (Auto) or a user defined setting. It worked great until this morning when I came across an instance where it told me that there was an error in the code (line marked in red) and that there was no such attribute to the layer. This particular text layer was set to Auto Leading. If I converted it to a specific leading and then back to Auto the script would work, but of course I don't want to do that every time I come across this. Any ideas, o' Scripting Community? A snippet of my script: var doc = activeDocument var lay = doc.activeLayer var textSize = lay.textItem.size var textLayer = doc.activeLayer var myFont = app.fonts.getByName(textLayer.textItem.font).name; var textHeight = textLayer.bounds[3]-textLayer.bounds[1] var textWidth = textLayer.bounds[2]-textLayer.bounds[0] var docHeight = doc.height docHeight = docHeight.toString().replace(' px', ''); var docWidth = doc.width docWidth = docWidth.toString().replace(' px', ''); var specLayName = lay.name var docName = doc.name var tempDoc = """Temp File For Script""" // Set leading offset var ogHeight = getBoundingBox(textSize, multiplier); var leadOffset = ogHeight; // Convert to Auto Leading? {// ======================================== if (lay.textItem.useAutoLeading == false){ var leadOffset = activeDocument.activeLayer.textItem.leading {if (confirm('Can I convert this to Auto Leading for you?')) { // Make Snapshot====================== var idMk = charIDToTypeID( "Mk " ); var desc61 = new ActionDescriptor(); var idnull = charIDToTypeID( "null" ); var ref28 = new ActionReference(); var idSnpS = charIDToTypeID( "SnpS" ); ref28.putClass( idSnpS ); desc61.putReference( idnull, ref28 ); var idFrom = charIDToTypeID( "From" ); var ref29 = new ActionReference(); var idHstS = charIDToTypeID( "HstS" ); var idCrnH = charIDToTypeID( "CrnH" ); ref29.putProperty( idHstS, idCrnH ); desc61.putReference( idFrom, ref29 ); executeAction( idMk, desc61, DialogModes.NO ); alert ("I created a History Snapshot if you need to revert back to your custom "+(activeDocument.activeLayer.textItem.leading) +" leading."); lay.textItem.useAutoLeading = true var leadOffset = ogHeight} }} }
... View more