FORUMS: list search recent posts

Imagetrace Script / doesn't recognize options / wtf preset number

COW Forums : Adobe Illustrator

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Roland Schneider
Imagetrace Script / doesn't recognize options / wtf preset number
on Nov 22, 2013 at 2:56:24 pm

Hello,

I'm totally desperate because I need to get an imagetracing script to work and it somehow just won't.
Here's the deal. I need to adjust the options for the trace command. There are 2 ways:

1) adjust the preset number and load it from the Application.tracingPresetList
array:
Well I tried presetnumber 1 to 25 and they load the default imagetrace presets but there is no way I could figure out to load my custom made presets. Since I don't know where to find the presets or don't know how to display what presets there are, it kinda sucks bigtime. Maybe there is a way to write a custom preset in the array and then simply load it with my script?

2) set the tracingoptions right in the script:
and here is where my lack of java knowledge bugs me. I spent hours and hours browsing through code and read the javascript object reference but somehow illustrator just ignores my code. I guess it's a pretty simple job for someone who knows java. Here is the link to the reference guide. Tracing is starting at page 230 http://www.adobe.com/content/dam/Adobe/en/devnet/pdf/illustrator/scripting/...

Here comes the code. The bold part is where the options are set (or not..) and the commentary line is the preset part from option 1.
If someone could help me out. It's a biggie to me I will gladly buy you a case of beer, make you a video or whatever suits you. I'm realy loosing it, so please help!

Best Regards
rold
digitaldopamine.com

// Main Code [Execution of script begins here]

// uncomment to suppress Illustrator warning dialogs
// app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

// Collectable files
var COLLECTABLE_EXTENSIONS = ["bmp", "gif", "giff", "jpeg", "jpg", "pct", "pic", "psd", "png", "tif", "tiff"];

var destFolder, sourceFolder;

// Select the source folder
sourceFolder = Folder.selectDialog( 'Select the SOURCE folder...', '~' );
//sourceFolder = new Folder("C:/Users//Desktop/1");

if(sourceFolder != null)
{
// Select the destination folder
destFolder = Folder.selectDialog( 'Select the DESTINATION folder...', '~' );
//destFolder = new Folder("C:/Users//Desktop/2");
}

if(sourceFolder != null && destFolder != null)
{
//getting the list of the files from the input folder
var fileList = sourceFolder.getFiles();
var errorList;
var tracingPresets = app.tracingPresetsList;

for (var i=0; i {
if (fileList[i] instanceof File)
{
try
{
var fileExt = String(fileList[i]).split (".").pop();
if(isTraceable(fileExt) != true)
continue;

// Trace the files by placing them in the document.

// Add a document in the app
var doc = app.documents.add(DocumentColorSpace.RGB,640,360);

// Add a placed item
var p = doc.placedItems.add();
p.file = new File(fileList[i]);

// Trace the placed item
var t = p.trace();
myOpts = t.tracing.tracingOptions;
myOpts.cornerAngle = 180;
myOpts.fills = true;
myOpts.ignoreWhite = true;
myOpts.minArea = 0;
myOpts.pathFitting = 0;
myOpts.tracingModeType = 'TRACINGMODEBLACKANDWHITE';



// t.tracing.tracingOptions.loadFromPreset(tracingPresets[3]);

app.redraw();

var destFileName = fileList[i].name.substring(0, fileList[i].name.length - fileExt.length-1) + "_" +fileExt;
var outfile = new File(destFolder+"/"+destFileName);
doc.saveAs(outfile);
doc.close();
}
catch (err)
{
errorStr = ("Error while tracing "+ fileList[i].name +".n" + (err.number & 0xFFFF) + ", " + err.description);
// alert(errorStr);
errorList += fileList[i].name + " ";
}
}
}
fileList = null;
alert("Batch process complete.");
}
else
{
alert("Batch process aborted.");
}

sourceFolder = null;
destFolder = null;

function isTraceable(ext)
{
var result = false;
for (var i=0; i {
if(ext == COLLECTABLE_EXTENSIONS[i])
{
result = true;
break;
}
}
return result;
}


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]