Skip to main content
Participating Frequently
September 2, 2010
Answered

Script to Perform Live Trace then in Illustrator Run Action... Please Help

  • September 2, 2010
  • 2 replies
  • 11714 views

Hello Everyone, I am brand new to scripting and need some help... I would like to create an inter-application javascript (.jsx) file that will perform the following steps in sequence:

1) Target Bridge CS3 and:


a) Automatically select files (thumbnails) (the names of, and path to these files never change so scripting them is no problem). Path & Files are: C:\files\1.psd, C:\files\2.psd and C:\files\3.psd.

b) Run Tools > Illustrator > Live Trace [Live Trace Dialogue Box Settings (Tracing Preset: Color 16, Save & Close Results (checked), Document Profile: "Basic RGB", Width: "576", Height: "720", Units: Pixels, Destination: "C:\files\, File Naming: Document Name + .ai)].

After Live Trace finishes, C:\files\1.ai, C:\files\2.ai and C:\files\3.ai are created.

and then....

2) Target Illustrator CS3 and:

Run my Illustrator precreated Action: "Add Border". This action adds a precreated border to the files. The action is coded with the paths and file names of the .ai files as well as saving instructions.

----------------------------------------------

To summarize:

1) In Bridge, run Live Trace on precreated .psd files

2) In Illustrator run an action on the files that were live traced

That's it. It seems straight forward when I write it out but trying to figure out how to script it is boggling my mind.

Thank you for your help!

This topic has been closed for replies.
Correct answer Muppet_Mark-QAl63s

I have posted in that forum once before about scripting 'Live Trace' meantime I will take a look at what I think you are wanting… I will need to get back to you about the borders thing…


OK, I've had a little time this morning to take a look at this for you and here is what I have… It is working just fine for me but you will be required to make 1 or 2 little typo changes yourself…

In line 7… You need to change the folders path string…

var traceFolder = new Folder ('~/Desktop/Live Trace/');

In line 71… You may want to change the save options to 13 for CS3 compatibility…

compatibility = Compatibility.ILLUSTRATOR13;

#target illustrator while (app.documents.length) {   app.activeDocument.close(SaveOptions.PROMPTTOSAVECHANGES); } var traceFolder = new Folder ('~/Desktop/Live Trace/'); var fileList = traceFolder.getFiles(/\.psd$/i); if (fileList.length > 0) {      main(fileList); } else {      alert('This Folder contained NO Photoshop PSD files!');      return; }     function main(fileObjs) {      with (app) {                var orginalUIL = userInteractionLevel;                     userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;                     for (var i = 0; i < fileObjs.length; i++) {                          if (fileList instanceof File) {                                    var fileName = fileList.name.slice(0, -4);                                         var docRef = documents.add(DocumentColorSpace.RGB, 576, 720);                                         with (docRef) {                                              var thisPlace = placedItems.add();                                                   thisPlace.file = fileObjs;                                                   var thisImage = placedItems[0].trace();                                                   redraw();                                                                                 thisImage.tracing.tracingOptions.loadFromPreset('Color 16');                          thisImage.tracing.expandTracing();                                                   redraw();                                                   /*///////////////////////////////////                          We need to add your border here…                          *////////////////////////////////////                                                   var aiOptions = saveAsAiFile();                                                   newFilePath = new File(traceFolder.fsName.toString() + '/' + fileName + '.ai');                                                   saveAs(newFilePath, aiOptions);                                                   close(SaveOptions.DONOTSAVECHANGES);                                             }                }           }           userInteractionLevel = orginalUIL;      } } function saveAsAiFile() {      var aiOptions = new IllustratorSaveOptions();      with (aiOptions) {           compatibility = Compatibility.ILLUSTRATOR12;           compressed = true;           embedICCProfile = true;           embedLinkedFiles = true;           flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;           fontSubsetThreshold = 0;           overprint = PDFOverprint.PRESERVEPDFOVERPRINT;           pdfCompatible = true      }      return aiOptions; }

As is, the script is looking for all files in the target folder that have the '.psd' file extension…

If this works for you then get back and I will see what can be done about the border thing…

2 replies

Participating Frequently
April 16, 2012

it goes like this but the names(A,J,R....) are different:

~/Desktop/Live Trace/A/A 000.png

~/Desktop/Live Trace/A/A 001.png

~/Desktop/Live Trace/A/A 002.png

~/Desktop/Live Trace/J/J 000.png

~/Desktop/Live Trace/J/J 001.png

~/Desktop/Live Trace/J/J 002.png

~/Desktop/Live Trace/R/R 000.png

~/Desktop/Live Trace/R/R 001.png

~/Desktop/Live Trace/R/R 002.png


and the number of files wouldn't be always equal in all directories, Is it a problem?


Inspiring
April 16, 2012

Oh now I may need a rethink…

Participating Frequently
April 16, 2012

Oh no...

1000fx4uAuthor
Participating Frequently
September 2, 2010

Also, I wanted to mention that I am using Bridge CS3  to Live Trace the files because Illustrator CS3 does not support processing Live Trace on a batch of files.

Muppet_Mark-QAl63s
Inspiring
September 2, 2010

In what way does scripting Illustrator NOT support this? The menu item of which you are talking is extendscript all it does is pass the thumbnail file objects from Bridge to Illustrator to work with. You could batch a list of file objects just the same direct in Illustrator…

Inspiring
April 16, 2012

Hello Muppet Mark,

Thank you for the quick response!

Well, I've been using the Bridge Illustrator Trace tool to mass trace these PNG's into one layered AI. (Like you said, 360 rotation of a rendered C4D )

Its working but it gets really slow and inefficient as it reaches the hundreds.

Now I'm working with thousands of PNG's in one file ,so dividing it to sub directories , something that the Bridge script doesn't do, I think will make it much faster.

I was thinking if there is a way to create a loop that expands the trace before it imports the next PNG file, maybe it will make it less heavy.

As for the simplify, I can do it manually, it's the really the easier part.

And if there is a way to take all the saved AI files and combine them to one AI divided to artboards it will make even better.

Thank you again!



A better AI placer n tracer has been on my todo list for some time… I would certainly want to be expanding the trace result on each itteration… This could be done with script from either Bridge or straight out of AI…