PathItem - suspendHistory issue
Posted: 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')
}
}
}
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')
}
}
}