Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to Create a LiveTrace Options Script

Explorer ,
Jan 19, 2009 Jan 19, 2009
Hello everyone!

I am using Illustrator CS3 on WinXP Pro.

Let me begin by saying that this is my first attempt at scripting anything and any help would be truly appreciated. I have written a script:

var myDocument = app.activeDocument;
var mySelection = myDocument.rasterItems[0];
mySelection.selected = true;

app.selection[0].trace();

app.selection[0].cornerAngle = 180;
app.selection[0].fills = true;
app.selection[0].ignoreWhite = true;
app.selection[0].minArea = 0;
app.selection[0].pathFitting = 0;
app.selection[0].threshold = 256;
app.selection[0].tracingModeType = 'TRACINGMODEBLACKANDWHITE';

app.redraw();

This script is tracing the raster image (barcode). However, it doesn't appear that it is using any of the tracing options.

Does anyone know how to properly script this in order to utilize the tracing options and then expand at the end?

Any help would be truly appreciated.

Many Thanks!
TOPICS
Scripting
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Beginner ,
Jan 19, 2009 Jan 19, 2009
I didn't hack this out, so I may be off - but from what i gathered from the JS guide :

the trace() method returns an object.

-- From the Guide --
A tracing object, which associates source raster art item with a vector-art plugin group created by tracing.
Scripts can initiate tracing using PlacedItem.trace or RasterItem.trace. The resulting PluginItem object represents the vector art group, and has this object in its tracing property.
--

ie:

myTrace = app.selection[0].trace();
myTrace.cornerAngle = 180;
myTrace.fills = true;
...
app.redraw();
myTrace.expandTracing();

---
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2009 Jan 19, 2009
John,

Thanks for your help!

I tried your suggestions and am not noticing any difference in the resulting graphics from the script. It is almost like Illy is processing the initial app.selection[0].trace(), then either not applying the tracing options or applying them to the already traced graphics.

I created a preset using all of the settings I am trying to apply from my script and it traces perfectly. However, I need to disseminate this information to everyone else in my group; so, I wanted to make it a script for ease.

Any other suggestions would be sure welcomed.

Thanks!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 20, 2009 Jan 20, 2009
The object was nested much deeper than I thought (selection[0].tracing.tracingOptions)

- the following should work - adjust your settings as needed :

myDoc = app.activeDocument;
sel = myDoc.selection[0];
myTrace = sel.trace();
myOpts = myTrace.tracing.tracingOptions;
myOpts.cornerAngle = 180;
myOpts.fills = true;
myOpts.ignoreWhite = true;
myOpts.minArea = 0;
myOpts.pathFitting = 0;
myOpts.tracingModeType = 'TRACINGMODEBLACKANDWHITE';
app.redraw();
myTrace.tracing.expandTracing();
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 20, 2009 Jan 20, 2009
LATEST
John,

Thank you so much for your help! It worked like a charm.

-jD
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines