PathItem - suspendHistory issue

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

Moderators: Tom, Kukurykus

Mike Hale

PathItem - suspendHistory issue

Post by Mike Hale »

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

Post by txuku »

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
  // 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

Post by Mike Hale »

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

Post by txuku »