Page 1 of 2

Photoshop CS6 running untabbed

Posted: Sat Jun 23, 2012 8:49 am
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'));
};

Photoshop CS6 running untabbed

Posted: Sun Jun 24, 2012 11:16 am
by jacobolus
What’s the major problem, exactly? I have "open documents as tabs" unticked, and everything seems to work okay...

Photoshop CS6 running untabbed

Posted: Sun Jun 24, 2012 11:53 am
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.

Photoshop CS6 running untabbed

Posted: Sun Jun 24, 2012 8:07 pm
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?

Photoshop CS6 running untabbed

Posted: Sun Jun 24, 2012 9:28 pm
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.

Photoshop CS6 running untabbed

Posted: Sun Jun 24, 2012 10:08 pm
by jacobolus
Worked completely fine, no errors (“Export Layers To Files was successful.”). Photoshop CS6, Mac OS X 10.6.8.

Photoshop CS6 running untabbed

Posted: Mon Jun 25, 2012 8:24 am
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.

Photoshop CS6 running untabbed

Posted: Mon Jun 25, 2012 5:27 pm
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.

Photoshop CS6 running untabbed

Posted: Mon Jun 25, 2012 5:33 pm
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?

Photoshop CS6 running untabbed

Posted: Mon Jun 25, 2012 6:10 pm
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?