Photoshop CS6 running untabbed

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

Moderators: xbytor, DavideBarranca, Paul MR

Paul MR

Photoshop CS6 running untabbed

Postby Paul MR » Sat Jun 23, 2012 8:49 am

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 all
function 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

Postby jacobolus » Sun Jun 24, 2012 11:16 am

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

Postby Paul MR » Sun Jun 24, 2012 11:53 am

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

Postby xbytor » Sun Jun 24, 2012 8:07 pm

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

Postby Paul MR » Sun Jun 24, 2012 9:28 pm

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

Postby jacobolus » Sun Jun 24, 2012 10:08 pm

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

Postby Paul MR » Mon Jun 25, 2012 8:24 am

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

Postby xbytor » Mon Jun 25, 2012 5:27 pm

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 all
function 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

Postby Mike Hale » Mon Jun 25, 2012 5:33 pm

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

Postby Paul MR » Mon Jun 25, 2012 6:10 pm

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?


Return to “Photoshop Scripting Bugs and Anomalies”

Who is online

Users browsing this forum: No registered users and 1 guest