Skip to main content
Participant
May 23, 2023
Answered

Extendscript: Unexpected compound shape / path results from expanding image trace

  • May 23, 2023
  • 1 reply
  • 751 views

I am writing a script in Extendscript for adobe illustrator that would automate these steps for an ink like effect: 1)Expand the selected object 2)convert to a compound shape 3)apply gaussian blur 4)rasterize 5)image trace. Here is how this looks when done manually:

 

Before doing the steps manually:

after doing the steps manually ( you can see a slight rounding effect, that is what is intended):

However, when running these steps from my script, i get a different result:

after result from script:

it seems like the compound shape is being released.

The rounded effect applied as was expected, but the empty spaces in paths always turn out filled. As if the script was releasing the compound path.

I am wondering where in the script this could be happening, and how to prevent that ?

Here is the code for the function where the effect is being applied:

function mainFunction(){
        inkifyScript.selection = app.activeDocument.selection;
        
        if (inkifyScript.selection.length > 0){
    
            app.executeMenuCommand('group');
            inkifyScript.xmlString = '<LiveEffect name="Adobe PSL Gaussian Blur"><Dict data="R blur '+ 20 +'"/></LiveEffect>';
            for (var i = 0; i < inkifyScript.selection.length; i++){
                inkifyScript.selection[i].applyEffect(inkifyScript.xmlString);
            }
            
            inkifyScript.raster = app.activeDocument.rasterize(selection[0]);
            inkifyScript.raster.selected = true;

            inkifyScript.pluginItem = inkifyScript.raster.trace();

            inkifyScript.tracingOptions = inkifyScript.pluginItem.tracing.tracingOptions;
            inkifyScript.tracingOptions.tracingMode = TracingModeType.TRACINGMODEBLACKANDWHITE;
            inkifyScript.tracingOptions.ignoreWhite = true;
            inkifyScript.tracingOptions.fills = true;
            inkifyScript.tracingOptions.maxColors = 2;
            inkifyScript.tracingOptions.threshold = 142;
            inkifyScript.tracingOptions.pathFitting = 10;
            app.redraw();
            inkifyScript.pluginItem.tracing.expandTracing();    
        }
        
    }`
This topic has been closed for replies.
Correct answer Sergey Osokin

To correctly ignore white, you must use tracingMethod attribute.

 

tracingOptions.tracingMethod = TracingMethodType.TRACINGMETHODABUTTING;
tracingOptions.ignoreWhite = true;

 

 

1 reply

Sergey Osokin
Sergey OsokinCorrect answer
Inspiring
May 23, 2023

To correctly ignore white, you must use tracingMethod attribute.

 

tracingOptions.tracingMethod = TracingMethodType.TRACINGMETHODABUTTING;
tracingOptions.ignoreWhite = true;

 

 

Participant
May 24, 2023

This solved the issue, thank you !