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

script to change Live Paint object Stroke width?

Participant ,
Nov 12, 2025 Nov 12, 2025

Hello everyone,
I'm trying to write a script that increases or decreases the width of strokes on shapes.
for now, what I came up with (found mostly on the internet a while ago), works fine for most shapes, and it can recurse into containers like groups, read their stroke width, and increase it by a certain percentage.

The problem remains with Live paint objects. I can't figure how to read their stroke width or how to change it. Any help would be appreciated!

TOPICS
Scripting
231
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
Enthusiast ,
Nov 12, 2025 Nov 12, 2025

Because Live Paint, like Compound Shape for scripts, is an "unknown" container of PluginItem. But from the outside, it's a PluginItem, and inside it's a GroupItem, which already has script access if you select one path with the Direct Selection Tool.

I tried this trick (check out video) on Live Paint but discovered another problem:

  1. When creating Live Paint, Illustrator resets the stroke widths of all internal paths to 0.5 pt, and we only see the stroke width (appearance) of the common container.
  2. When changing the stroke widths of the internal Live Paint paths via script, it breaks — the colors disappeared, and the stroke changed to a round cap. This is one of the clearest examples of the limitations and lack of progress in ExtendScript.

 

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 Expert ,
Nov 12, 2025 Nov 12, 2025

this seems to work well, all colors and stroke size are preserved

 

// scale Live Paint Stroke

function main() {
    app.executeMenuCommand("Expand Planet X");

    selection[0].resize (100, 100, true, true, true, true, 200, Transformation.CENTER); // scale strokes

    app.executeMenuCommand("Make Planet X")
}
main();
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 Expert ,
Nov 13, 2025 Nov 13, 2025

Not bad Carlos!

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
Enthusiast ,
Nov 13, 2025 Nov 13, 2025

I admit that the idea is creative 🙂 But the result in layers is not so pleasing

SergeyOsokin_0-1763026738498.png

 

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 Expert ,
Nov 13, 2025 Nov 13, 2025
quote

I admit that the idea is creative 🙂 But the result in layers is not so pleasing

 

By @Sergey Osokin

 

but that's the expected result when one expands a Livepaint group no? something has to give 😕

 

it's far from perfect like most things in illustrator scripting 😕

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
Enthusiast ,
Nov 13, 2025 Nov 13, 2025

This is certainly the expected behavior after an expand. But I think users would like a magic pill so that Live Paint remains the original structure with only a modified stroke weight. This is something Adobe doesn't offer us in ExtendScript 😞

 

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 Expert ,
Nov 12, 2025 Nov 12, 2025

I've been waiting... hoping!... for someone to post an answer here, but I should tell you that as far as I know the scripting API doesn't expose much of the live paint object, if any. 😞

 

Edit: sorry didn't see Sergey's post.

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 Expert ,
Nov 13, 2025 Nov 13, 2025

I haven't tried it yet, but perhaps one may be able to script the following manual steps (possibly assisted by Mark's (m1b) LE_Functions suite):

 

- Select one or several Live Paint objects.

 

- Effect menu > Distort and Transform > Transform:

  • Set a scaling percentage
  • In the Options panel select only the Transform Patterns and the Scale Strokes & Effects option
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 Expert ,
Nov 13, 2025 Nov 13, 2025

That seems like a good approach Kurt. I like that it doesn't interfere with the live paint object itself.

- Mark

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
Enthusiast ,
Nov 13, 2025 Nov 13, 2025
LATEST

Yes, the effect certainly allows us to increase the stroke width in Live Paint. But again, the downside is that once the effect is applied, we can't edit it again via script. It's a one-time automation, and then we have to manually edit the percentages in Appearance > Transform. In an ideal world, scripts should be able to dynamically change the width of strokes repeatedly 😞

(function (){
  if (!app.selection.length || app.selection[0].typename !== 'PluginItem') return;
  var scalePercent = 200;
  var xml = '<LiveEffect name="Adobe Transform"><Dict data="R scaleH_Percent #1 R scaleV_Percent #2 R scaleH_Factor #3 R scaleV_Factor #4 R moveH_Pts 0 R moveV_Pts 0 R rotate_Degrees 0 R rotate_Radians 0 I numCopies 0 I pinPoint 4 B scaleLines 1 B transformPatterns 0 B transformObjects 0 B reflectX 0 B reflectY 0 B randomize 0 "/></LiveEffect>'
            .replace(/#1/, scalePercent)
            .replace(/#2/, scalePercent)
            .replace(/#3/, scalePercent / 100)
            .replace(/#4/, scalePercent / 100)
  app.selection[0].applyEffect(xml);
})();

 

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 Expert ,
Nov 13, 2025 Nov 13, 2025

If you don't mind to use helper graphic styles, you may check this sample Illustrator file:

 

Live Paint - Scale Strokes

 

Using this snippet will scale the strokes of selected Live Paint objects by 200 %:

 

(function () {
    var doc = app.activeDocument;
    var sel = doc.selection;
    var style = doc.graphicStyles.getByName("Scale_Live_Paint_Strokes_By_200_Percent");
    for (var i = 0; i < sel.length; i++) style.applyTo(sel[i]);
})();

 

That would also work with an action or by just applying the graphic style manually (fastest method).

 

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