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

help with a script to break apart simple designs

Explorer ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

I've been trying to write a script that essentially breaks up the selection (no opacities/gradients/clippingmasks/etc - just solid vector shapes) and results in a single group of compound paths; one for each spot fill color. I thought it was within my abilities but after numerous do-overs, apparently not.

 

Ideally, I want it to do the following:

1. go through each item within the current selection (inluding recursively through groups and groups within groups) and:

  • if it finds live text, convert it to outlines
  • if it finds an item with a stroke, convert that stroke to a path

2. perform pathfinder divide on the selection
       note: ive been using the following approach to pathfinder operations which im not sure is the best:

                app.executeMenuCommand("group");
                app.executeMenuCommand("Live Pathfinder Divide");
                app.executeMenuCommand("expandStyle");
                app.executeMenuCommand("ungroup");

3. perform pathfinder trim on the selection (I'm not entirely certain this one is necessary - it's just something I've always done when doing it manually)

4. perform pathfinder merge on the selection.

5. go back through the "new" items within the selection (recursively through groups) and delete any "invisible shapes" (no fill color as well as no stroke) that result from the pathfinder functions, and delete them.
6. go back through the items within the selection (recursively through groups) for each item, find all other items within the selection that have the same spot fill color make them all into a single compound path.

7. group the selection

The issue I think I'm running into is not "rechecking/refreshing" the selection to properly update what the script sees to be in it before the script moves on to the the next function. I may be wrong - I'm at a bit of a loss. But it does feel like things stop making sense around the point when it should be uniting/merging shapes of the same fill color before ultimately making them compound paths. I've tried throwing in redraw(); in between steps and that didn't seem to help much. Also, when i got it to somewhat work, it was only "working" on particular item types rather than all. Can anyone help me out?

Thanks in advance.

TOPICS
Scripting

Views

343

Translate

Translate

Report

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 Expert ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

Thanks for the detailed description.

However, I think it would be much easier to understand your request if you could provide a sample Illustrator file that shows the initial situation as well as the desired result.

Votes

Translate

Translate

Report

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 ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

That's a good idea. Thank you. Here's one. It's not letting me attach the ai file for some reason. I didnt want to deal with having missing fonts in the file so I converted all the text to outlines for simplicity- just pretend the Initial Design's lettering was live/editable text and the resulting design isn't. haha. This is all for the sake of making screens for screenprinting if that helps clear anything up. It's easier to do the separations when the design is broken up into clean "what you see is all there is" pieces like a puzzle - rather than worrying something is hidden behind something else somewhere that will show up on a screen it doesnt belong. That becomes more of a likelihood with more complicated designs.  I've always been kind of shocked that such a function isn't in Illustrator natively honestly.

Votes

Translate

Translate

Report

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 ,
Apr 12, 2024 Apr 12, 2024

Copy link to clipboard

Copied

Thanks for the sample file.

One question: Is it really necessary to create separate compound paths for the objects with the same spot fill colour? Or is this just a nice to have thing?

Votes

Translate

Translate

Report

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 ,
Apr 13, 2024 Apr 13, 2024

Copy link to clipboard

Copied

I opt for a single compound path per spot fill color because compound paths seem to be the consistent least-problematic type for further boolean operations later in the separation/screen-making process. In screenprinting, screens are typically printed in the order of lightest color to darkest color (darker the inks = more coverage). To make the registration of the screens on-press less tedious, I manually create "traps" for each color screen where the shapes of the current screen are "extended" slightly but only into the areas that will be covered by the screen that follows. Creating these traps just provides a little wiggle room in lining up the screens on the printpress; it compensates for things like slightly warped screens etc. I make these traps by:
-duplicating the current screen's compound path in place
-applying a 1pt stroke of the same color and rounded corners to that duplicated shape
-flattening transparency to convert the stroke to a path ("expand" or "path>outlinestroke" options also work but occasionally fail for reasons I dont fully understand; so i just go for whats more consistent)
-pathfinder unite the duplicate and its new outlined path. and make the result another compound path. 
- merging all colors that will come after the current screen and making that a compound path
- using the merged shape to pathfinder intersect; resulting in a shape that only exists where it will be covered by the screens that follow. 

Similarly, having everything in the design as compound paths is also useful for creating underbase screens where white is being printed beneath the subsequent screens for the sake of brighter colors on dark garments. The white that is printed underneath the other colors has to be choked back and the easiest way ive found to do this is to duplicate everything, pathfinder unite, make compound path, apply a stroke of the same color but at a 0% tint stroke, and send that shape behind the original white shape - the RIP software ignores the stroked area but the choke remains "live" on file and is easily increased/decreased later if need be. 

Keeping everything as compound paths ensures that any individual shapes (like what might be present if the spot color shapes are just left in a group) dont get deleted when pathfinder is used later on making the traps. 

attaching a video of that process because I realize it's a fairly niche workflow and doesnt translate to a text breakdown well. Note: i use a light blue for the white screens just for the sake of visibility against the artboard.

Votes

Translate

Translate

Report

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 ,
Apr 14, 2024 Apr 14, 2024

Copy link to clipboard

Copied

Thanks for the clarification.

 

I will have to think about the task again.

Votes

Translate

Translate

Report

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 ,
Apr 16, 2024 Apr 16, 2024

Copy link to clipboard

Copied

LATEST

I appreciate the consideration and the feedback. I can't seem to figure out how to perform the pathfinder operations and other commands on certain objects within the selection as they tend to alter the number and type of items in the selection. It seems like it's either "do X to the entire selection" or the script just breaks. I thought about trying to select specific objects by assigning notes to them and selecting via those. but then id need to have a generic note on every item selection in order to select it again afterwards or something. It seemed so doable in my head because I've seen a CAD-cutter plugin for illustrator that had a button that did nearly this exact thing (the plugin stopped working circa CS6 sadly). Though maybe that was a difference in capabilities in the languages.

Votes

Translate

Translate

Report

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 ,
Apr 13, 2024 Apr 13, 2024

Copy link to clipboard

Copied

I'm aware of the trap option in pathfinder itself, but i've never been able to get the results I'm looking for from it - the RIP software at my company doesn't handle "overprint" attributes so I'm assuming thats the issue. I'm open to an alternative approach that utilizes that option if that simplifies the script - assuming it can yield the same outcome as my current process for the traps. It's likely that I just haven't been using it correctly or something.

Votes

Translate

Translate

Report

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