Photoshop CS6 running untabbed

Discussion of actual or possible Photoshop Scripting Bugs, Anomalies and Documentation Errors

Moderators: Tom, Kukurykus

Paul MR

Photoshop CS6 running untabbed

Post by Paul MR »

It seems that there is a magor problem if you are running with:
"Open Documents as Tabs" unticked
Script will stop/give an error.
I am running Windows 7 64bit but it affects both PC and Mac users.
For a workaround on the pc I set this value, process then restore the value back using the following functions..

Code: Select allfunction tabInterface(onOff) {
if(onOff == undefined) onOff=true;
    var desc19 = new ActionDescriptor();
        var ref8 = new ActionReference();
        ref8.putProperty( charIDToTypeID('Prpr'), stringIDToTypeID('interfacePrefs') );
        ref8.putEnumerated( charIDToTypeID('capp'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
    desc19.putReference( charIDToTypeID('null'), ref8 );
        var desc20 = new ActionDescriptor();
        desc20.putBoolean( charIDToTypeID('EGst'), true );
        desc20.putBoolean( stringIDToTypeID('openNewDocsAsTabs'), onOff );
    desc19.putObject( charIDToTypeID('T   '), stringIDToTypeID('interfacePrefs'), desc20 );
    executeAction( charIDToTypeID('setd'), desc19, DialogModes.NO );
};

function isTabInterface(){
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
return executeActionGet(ref).getObjectValue(stringIDToTypeID('interfacePrefs')).getBoolean(stringIDToTypeID( 'openNewDocsAsTabs'));
};
jacobolus

Photoshop CS6 running untabbed

Post by jacobolus »

What’s the major problem, exactly? I have "open documents as tabs" unticked, and everything seems to work okay...
Paul MR

Photoshop CS6 running untabbed

Post by Paul MR »

Try running "Export Layers to Files" and you will find that it will fail unless you are running tabbed (you might get the first layer to save). This applies to several other scripts as well.
xbytor

Photoshop CS6 running untabbed

Post by xbytor »

Paul MR wrote:Try running "Export Layers to Files" and you will find that it will fail unless you are running tabbed.

What is the error?
Paul MR

Photoshop CS6 running untabbed

Post by Paul MR »

This is what you get if running untabbed.

Error: General Photoshop error occurred. This functionality may not be available in the version of Photoshop.
- The object " current document" is not currently available.
jacobolus

Photoshop CS6 running untabbed

Post by jacobolus »

Worked completely fine, no errors (“Export Layers To Files was successful.”). Photoshop CS6, Mac OS X 10.6.8.
Paul MR

Photoshop CS6 running untabbed

Post by Paul MR »

Thanks for testing this on a Mac, Jacob. It look as if I was misinformed and this is a Windows/Photoshop CS6 problem.
xbytor

Photoshop CS6 running untabbed

Post by xbytor »

Paul MR wrote:This is what you get if running untabbed.

Error: General Photoshop error occurred. This functionality may not be available in the version of Photoshop.
- The object " current document" is not currently available.

This is happening probably because of a concurrency issue in PS and it also happens with 'current layer'.

The only workaround is to modify the script at the point or points where the problem is occurring.

Code: Select allfunction getActiveDocument() {
  var doc;
  try {
      doc = app.activeDocument;

   } catch (e) {
      // this seems to be the shortest pause that works
      $.sleep(500);

      // the follow code does a "wait for refresh"
      var desc = new ActionDescriptor();
      desc.putEnumerated(cTID("Stte"), cTID("Stte"), cTID("RdCm"));
      executeAction(cTID("Wait"), desc, DialogModes.NO);

      doc = app.activeDocument;
   }
}

var doc = getActiveDocument();


There are other ways of organizing this code, but the important thing is the sleep and waitForRefresh.
Mike Hale

Photoshop CS6 running untabbed

Post by Mike Hale »

I don't have CS6 yet to test, but would forcing a redraw with app.refresh() work instead of sleep and waitForRedraw?
Paul MR

Photoshop CS6 running untabbed

Post by Paul MR »

Thanks X, but it doesn't work for me even with a sleep of 5000, I only get the first layer, then the script stops.
Changeing the preferences to tabbed works ok but sometimes I get "Initializing Video", it would be nice if this could be avoided. It must get triggered by the descripter?