Skip to main content
JJMack
Community Expert
Community Expert
July 22, 2016

P: Script Metadata assignment error

  • July 22, 2016
  • 23 replies
  • 721 views

The  following statement in my script below works in Photoshop version Prior to CC 2015.5 but not in  CC 2015.5 Scripting. 

app.activeDocument.info.instructions = before + after;


The full simple toggle script is here

/* ======================================================================================// 2015  John J. McAssey (JJMack)  http://www.mouseprints.net/
//  
// This script is supplied as is. It is provided as freeware. 
// The author accepts no liability for any problems arising from its use.
//
// This script is designed to Toggle centering guides 
//
// ===================================================================================== */
/*

$$$/JavaScripts/AddRemoveCenterGuides/About=JJMack's AddRemoveCenterGuides.^r^rCopyright 2009 Mouseprints.^r^rRun twice script utility for action.^r^rFirst Run Set Guides on camvas bounds and center.^rSecond Run clears the set guides.
JJMackJJMack's Action Run Twice Utility

*/
if (app.documents.length > 0) app.activeDocument.suspendHistory('ToggleCenterGuides','main()' );
else alert("You must have at least one open document to run this script!"); 
/////////////////////////////////////////////////////////////////////////////////////////// 
function main() {
if (app.activeDocument.info.instructions.indexOf("") == -1 ){ // no footprint fisrt useage 
var orig_ruler_units = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS; // Set the ruler units to PIXELS
try { 
activeDocument.guides.add(Direction.VERTICAL, 0);
activeDocument.guides.add(Direction.VERTICAL, activeDocument.width/4);
activeDocument.guides.add(Direction.VERTICAL, activeDocument.width/2);
activeDocument.guides.add(Direction.VERTICAL, activeDocument.width*3/4);
activeDocument.guides.add(Direction.VERTICAL, activeDocument.width);
activeDocument.guides.add(Direction.HORIZONTAL, 0);
activeDocument.guides.add(Direction.HORIZONTAL, activeDocument.height/4);
activeDocument.guides.add(Direction.HORIZONTAL, activeDocument.height/2);
activeDocument.guides.add(Direction.HORIZONTAL, activeDocument.height*3/4);
activeDocument.guides.add(Direction.HORIZONTAL, activeDocument.height);
  }
// display error message if something goes wrong
catch(e) { alert(e + ': on line ' + e.line, 'Script Error', true); }
app.preferences.rulerUnits = orig_ruler_units; // Reset units to original settings
// put footprint in metadata info instructions
app.activeDocument.info.instructions = app.activeDocument.info.instructions + "" + " Show" + ""; 

else { 
clearGuides();
// Remove footprint from metadata info instructions
before = app.activeDocument.info.instructions.substr(0,app.activeDocument.info.instructions.indexOf(""));
afterOffset = app.activeDocument.info.instructions.indexOf("") + "".length;
after = app.activeDocument.info.instructions.substr(afterOffset, app.activeDocument.info.instructions.length - afterOffset);
//alert ("before = " + before + " after = " + after);
app.activeDocument.info.instructions = before + after;


//////////////////////////////////////////// Action Manager Code to Clear all Guides ///////////////////////////////////
function clearGuides() { 
   var id556 = charIDToTypeID( "Dlt " ); 
       var desc102 = new ActionDescriptor(); 
       var id557 = charIDToTypeID( "null" ); 
           var ref70 = new ActionReference(); 
           var id558 = charIDToTypeID( "Gd  " ); 
           var id559 = charIDToTypeID( "Ordn" ); 
           var id560 = charIDToTypeID( "Al  " ); 
           ref70.putEnumerated( id558, id559, id560 ); 
       desc102.putReference( id557, ref70 ); 
   executeAction( id556, desc102, DialogModes.NO ); 
};
This topic has been closed for replies.

23 replies

JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
December 15, 2016
Bug is still in CC 2017.0.1
JJMack
JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
November 2, 2016
Bug still in CC 2017
JJMack
JJMack
Community Expert
JJMackCommunity ExpertAuthor
Community Expert
August 9, 2016
CC 2015.5.1 the bug is still present
JJMack