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…

Muppet_Mark-QAl63s
Inspiring
September 3, 2010

Thank you for your response Muppet Mark.

While in Illustrator CS3 when I attempt to record Live Trace in an Action via File > Scripts > Live Trace I am prompted to batch Trace files in Bridge which is why I was attempting to accomplish my script using Bridge. However, conceptually, I can see how the script I am trying to create could be Scripted using Illustrator CS3 wihtout the need for Bridge at all. Practically, though, creating the script is where I need help.  I have seen the Extendscript program but I am at a loss with what the code in a script like this would look like. I would be very grateful if you or anyone can help me write the script.

Thank you for your help.


Hello, the 'Illustrator Tools' Live Trace Utility that you are wanting to 'run' is a script that was created by someone at Adobe using the ESTK. You can't access the clicking of checkboxes or entering of values into the the supplied scripts dialog from another script. The work flow in the stages that you originally posted would not be doable as a single script process because of this. What you actually require is a script that uses your 'values' and 'presets' then processes the files. There would be no need for any dialog and depending on how you wanted the process to run then there is no need for any app interaction. It would be easier to script it to run straight out of Illustrators scripts presets folder…

Illustrator can't play out actions from ExtendScript either. So what your action does later to add the borders would need to be done via script too. Actions in script can only be done when using VB or AppleScript.