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

How can I quickly add an identical stroke color to a filled shape for hundreds of selected objects at the same time

Community Beginner ,
Feb 21, 2016 Feb 21, 2016

I have an illustration with hundreds of small shapes thet are exactly adjacent. However Illustrator seems to show a small seem nonetheless.

Is there a way to select all my objects and have a script stroke them with the same color as theri individual fill?

Albert

TOPICS
Scripting
875
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

correct answers 1 Correct answer

Community Expert , Feb 21, 2016 Feb 21, 2016

Why don't you try just using Object>Path>Offset path and use a small number (>0.005 or so).

Translate
Adobe
Community Expert ,
Feb 21, 2016 Feb 21, 2016

Why don't you try just using Object>Path>Offset path and use a small number (>0.005 or so).

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 ,
Feb 21, 2016 Feb 21, 2016

‌hi Larry,

thanks for this suggestion. This way it would generate a lot of extra 'hard' geometry (running in the thousands of extra paths) so that would be a problem.

Albert

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
Valorous Hero ,
Feb 22, 2016 Feb 22, 2016

It may be possible to achieve the offset suggestion via a live effect which may save on the extra paths. This could theoretically be applied via script in CS6+, it could probably be done by using both the live effect and the action-play workaround to make a new graphic style, selecting all and applying that style to the entire selection. Or, if there is a way to 'click' the graphic style button or apply the live effect to an entire selection, it could be done without having to use the action within the script.

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 ,
Feb 22, 2016 Feb 22, 2016

I'm not talking about an using an effect. The Object>Path>Offset path will enlarge the objects by the amount specified and can be used to overlap slightly the paths to get rid of the visual edges. You can do it by creating an Action and assigning it an F-key for one click application.

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
Valorous Hero ,
Feb 22, 2016 Feb 22, 2016

Well he doesn't want to use the Path > Offset Path menu item due to creation of extra paths, so he may as well do the same thing with an effect.

As for the graphic style, it's possible to create a 'generic' offset path style which has no fill & stroke, just the offset path effect, from a temporary dummy object and save the custom graphic style from it. If applied to a filled shape with a click, it will of course completely override all appearance, making it a clear path - however, alt-clicking it will add it onto the appearance of the filled shape, offsetting it as expected. I think if this was to be scripted in its entirety, actions will need to be used to apply the graphic style to the selection without resorting to looping.

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 ,
Feb 22, 2016 Feb 22, 2016

How is this going to create extra paths? I don't understand the reluctance to use the UI. I did a whole series of modeling maps at my old jobs using this method and it worked great. No extra paths were created and I was able to use the Add pathfinder to create significant savings on the total anchor point count.

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
Valorous Hero ,
Feb 22, 2016 Feb 22, 2016

The offset path menu item creates one offset path for every selected object, so perhaps while you simply added the shapes, this user wants to keep all their fill colors different from each other. Also there's little difference in using the UI to apply this menu item or the live effect version, but inserting the live version into an action will only produce a dialog box. However, I do believe it would be possible to use the menu item and a series of note-setting & selecting to remove the original path and only leave the new one to do this automatically with an action.

2016-02-22 12_43_27-.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
Guide ,
Feb 21, 2016 Feb 21, 2016

if you really want to do this with a script, (as it may be part of a larger process)

var doc = app.activeDocument;

var pths = doc.pathItems;

for(var i=0; i<pths.length; i++){

    var pth = pths;

    pth.stroked = true;

    pth.strokeWidth = .5;

    pth.strokeColor.cyan = pth.fillColor.cyan;

    pth.strokeColor.magenta = pth.fillColor.magenta;

    pth.strokeColor.yellow = pth.fillColor.yellow;

    pth.strokeColor.black = pth.fillColor.black;

}

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 ,
Feb 21, 2016 Feb 21, 2016

‌HI qwertyfly,

I'll test out your script and see if that's the option I was looking for. I am curious about what you mean with 'part of a larger process'?

Albert

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 ,
Feb 22, 2016 Feb 22, 2016

Qwertyfly‌

Maybe stupid question but how do I get this script to run? I tried saving with an extension of .scpt but Illustrator just flashes a simple warning dialog box...

Albert

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 ,
Feb 22, 2016 Feb 22, 2016

‌hi all,

In light of my having to solve this fast the option with offset path at least gets rid of the lines.

that way I can get them rasterized properly (Photoshop minimum filter does not get lower than a whole pixel)

Thanks for all your input!

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
Guide ,
Feb 22, 2016 Feb 22, 2016
LATEST

as for running the script it should be saved as .jsx

then go to File>Scripts>Other Script... and choose the .jsx file you just saved

as for larger process, if this was just one stage in a larger script.

you may have a situation where you want to process 30 files.

along with this snippet you may want to fit to a set page size, export a low res PNG, save as a PDF, and log the number of pathitems per file to a textfile.

so now this snippet is just part of a larger process...

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