PathItem - suspendHistory issue

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

Moderators: xbytor, DavideBarranca, Paul MR

Mike Hale

PathItem - suspendHistory issue

Postby Mike Hale » Wed Feb 22, 2012 2:40 pm

This gave me trouble in the last few days. The makeWorkPath method of pathItem throws an error if used in suspendhistory.

Code: Select all
// needs an document at least 10,10 pixels
app.activeDocument.selection.select([[0,0],[10,0],[10,10],[0,10]]);
app.activeDocument.selection.makeWorkPath (0);
try{
   var wp = app.activeDocument.pathItems.getByName('Work Path');
   alert('Work Path created from selection');
   wp.remove();
}catch(e){
   alert('Path not creted');
}
app.activeDocument.suspendHistory ('historyString', 'javaScriptString()');

function javaScriptString(){
   app.activeDocument.selection.select([[0,0],[100,0],[100,100],[0,100]]);
   try{
      app.activeDocument.selection.makeWorkPath (0);
      var wp = app.activeDocument.pathItems.getByName('Work Path');
      alert('Work Path created from selection');
      wp.remove();
   }catch(e){
      try{
         var wp = app.activeDocument.pathItems.getByName('Work Path');
         alert('Work Path created from selection.\rBut error thorwn???');
      }catch(e){
         alert('This alert should show because\n the path should not exists')
      }
   }
}



txuku

PathItem - suspendHistory issue

Postby txuku » Thu Feb 23, 2012 8:30 am

Bonjour Mike Hale

By using the function makeWorkPath () of xbytor - HERE - instead of the method makeWorkPath () I think it works :

Code: Select all
    // needs an document at least 10,10 pixels
    app.activeDocument.selection.select([[0,0],[10,0],[10,10],[0,10]]);
    //app.activeDocument.selection.makeWorkPath (0);
    makeWorkPath(0);
    try{
       var wp = app.activeDocument.pathItems.getByName('Work Path'); //'Tracé de travail') en francais
       alert('Work Path created from selection');
       wp.remove();
    }catch(e){
       alert('Path not creted');
    }
    app.activeDocument.suspendHistory ('historyString', 'javaScriptString()');

    function javaScriptString(){
       app.activeDocument.selection.select([[0,0],[100,0],[100,100],[0,100]]);
       try{
          //app.activeDocument.selection.makeWorkPath (0);
          makeWorkPath(0);
          var wp = app.activeDocument.pathItems.getByName('Work Path'); //'Tracé de travail') en francais
          alert('Work Path created from selection');
          wp.remove();
       }catch(e){
          try{
             var wp = app.activeDocument.pathItems.getByName('Work Path'); //'Tracé de travail') en francais
             alert('Work Path created from selection.\rBut error thorwn???');
          }catch(e){
             alert('This alert should show because\n the path should not exists')
          }
       }
    }
   
 
  // fonction  de xbytor
  // http://www.ps-scripts.com/bb/viewtopic.php?f=2&t=2904
 
        function makeWorkPath() {
        //alert();
      function cTID(s) { return app.charIDToTypeID(s); };
      function sTID(s) { return app.stringIDToTypeID(s); };

        var desc266 = new ActionDescriptor();
            var ref174 = new ActionReference();
            ref174.putClass( cTID('Path') );
        desc266.putReference( cTID('null'), ref174 );
            var ref175 = new ActionReference();
            ref175.putProperty( cTID('csel'), cTID('fsel') );
        desc266.putReference( cTID('From'), ref175 );
        desc266.putUnitDouble( cTID('Tlrn'), cTID('#Pxl'), 1.000000 );
        executeAction( cTID('Mk  '), desc266, DialogModes.NO );
    };


Mike Hale

PathItem - suspendHistory issue

Postby Mike Hale » Thu Feb 23, 2012 4:42 pm

Yes, Action Manager does work in this case. But I would have thought that it did the same think as the DOM method. I run into this problem trying to clean up a script by removing Action Manager where there was a DOM method. I ended up leaving the Action Manager code in because of the DOM bug.

txuku

PathItem - suspendHistory issue

Postby txuku » Thu Feb 23, 2012 5:03 pm

:) :!:


Return to “Photoshop Scripting Bugs and Anomalies”

Who is online

Users browsing this forum: No registered users and 1 guest