Skip to main content
brian_p_dts
Community Expert
Community Expert
August 7, 2023
Answered

JSX - how to fill a compound path with a color if it has no child path items/page items

  • August 7, 2023
  • 2 replies
  • 674 views

Hi all, not the first time I've considered this problem. I've followed along with the following discussion. 

 

https://community.adobe.com/t5/illustrator-discussions/illustrator-script-to-get-compoundpathitem-pathitem-filled-colors-on-few-layers/m-p/11208204

 

My problem is the compound path item I have selected alerts as having 0 path items and undefined group items and page items. Thus, my attempts to recurse through sub-path/group/pageitems is not working. Any thoughts of how I can get this color changed without releasing the path, which distorts the image. Thanks.  

Edit: Looks like this "bug" or "oversight" is discussed at length here. Will do some digging: https://community.adobe.com/t5/illustrator-discussions/dealing-with-compound-paths-made-of-groups/td-p/8826626

This topic has been closed for replies.
Correct answer CarlosCanto

there's an easier way I didn't think of back when executeMenuCommand was newish

 

applying default color actually colors all selected items including compoundPathItems. So you would select your compoundPath before changing the document's default fill color, see an example here

https://community.adobe.com/t5/illustrator-discussions/change-fill-color-to-selection-path-and-compound-path/m-p/13551114#M354504

2 replies

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
August 7, 2023

there's an easier way I didn't think of back when executeMenuCommand was newish

 

applying default color actually colors all selected items including compoundPathItems. So you would select your compoundPath before changing the document's default fill color, see an example here

https://community.adobe.com/t5/illustrator-discussions/change-fill-color-to-selection-path-and-compound-path/m-p/13551114#M354504

brian_p_dts
Community Expert
Community Expert
August 14, 2023

Thanks Carlos. Works a treat. Cheers.

m1b
Community Expert
Community Expert
August 7, 2023

Hi @brian_p_dts, I strongly doubt there is much you can do without releasing/fixing/compounding. However, it may help to post a samnple file showing the issue.

- Mark

brian_p_dts
Community Expert
Community Expert
August 7, 2023

Thanks @m1b I ended up using the trick @Silly-V posted in my edited thread to iterate through selected document group items and seeing if their parent was a compound path. I already had a recursive function to change group pathItems, so I just use that. Seems to have worked. 

m1b
Community Expert
Community Expert
August 7, 2023

That's a good approach! I didn't think of doing that. Nice!