I found this script from a post 2 years ago from Qwertyfly. Being so old I though I would post my issue in a new thread. It appears to be exactly what want however when I run the script I always get the following error message "cannot find tracing preset that has been set in the script". I have tried several of the default trace presets but always the same message.
What I am doing is using a VBscript to load a TIFF file, I make sure the document is selected then call the myTrace script. I also tried the script by having it in the Illustrator's File/Scripts folder and running it directly. Same error message. FYI, I am using Illustrator CS6.
If Qwertyfly happens to see this or if someone can chime in that would be great.
Here's the script. I commented out the lines of code that play an action. Just want to trace for now.
function myTrace(){
//-----User Set Variables-------
var Tracing_Preset = '16 colors';
//var My_Action_Name = 'Rotate .5';
//var From_Set_Name = 'MyActions';
//--------------------------------------
if(app.tracingPresetsList.indexOf(Tracing_Preset)<0){
alert('cannot find tracing preset that has been set in the script');
return;
}
var doc = app.activeDocument;
var sel = doc.selection;
for(var i = 0; i<sel.length; i++){
//if(sel[i] == '[RasterItem ]'){ //This line was quoted as a mistake and new line is below it.
if(sel[i].typename == 'RasterItem'){
var pic = sel[i].trace();
pic.tracing.tracingOptions.loadFromPreset(Tracing_Preset);
pic.tracing.expandTracing().selected = true;
}
}
// no test to confirm the action is present. make sure action name and set name are correct. they are case sensitive.
//app.doScript(My_Action_Name, From_Set_Name); // don't want this Action to happen so commented out.
}
// add indexOf prototype to Array's
Array.prototype.indexOf = function(needle) {
for(var i = 0; i < this.length; i++) {
if(this[i] === needle) {
return i;
}
}
return -1;
};
myTrace();