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

Dealing with Compound Paths made of Groups

Community Expert ,
Dec 30, 2016 Dec 30, 2016

Copy link to clipboard

Copied

I've had some errors reported by my art team recently and i've traced the issue down to compoundPathItems being composed of groupItems instead of pathItems.

I'm attempting to verify the fill/stroke color of these items which seems to be impossible if the compoundPathItem is made of groups. It seems the only relevant property of compoundPathItem is pathItems (but the length of this property is zero because it only contains groupItems, which is not available).

Does anyone know of a way to access the groupItems nested inside a compoundPathItem???

TOPICS
Scripting

Views

2.3K

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

correct answers 1 Correct answer

Community Expert , Dec 30, 2016 Dec 30, 2016

true, whatever is less but I don't think he has 100k compoundPaths, he could set up a function to "treat" all compoundPathItems, it shouldn't add a big overhead.

app.executeMenuCommand("noCompoundPath"); // release

app.executeMenuCommand("compoundPath"); // make

app.executeMenuCommand("group");

app.executeMenuCommand("ungroup");

Votes

Translate

Translate
Adobe
Valorous Hero ,
Dec 30, 2016 Dec 30, 2016

Copy link to clipboard

Copied

Ugh there are some ways - here is one: you select the compound path and then go through doc.pathItems and look only at the selected ones - then see each one's .parent property to see if it's a [GroupItem].

#target illustrator

function test(){

  var doc = app.activeDocument;

  var a = doc.compoundPathItems["A"];

  alert("A Path Items: " + a.pathItems.length); // does not reveal true pathItems contents as some are hidden inside a group!

  a.selected = true;

  var thisPath;

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

    thisPath = doc.pathItems;

    if(thisPath.selected){

      alert(thisPath.parent);

    }

  };

};

test();

I always thought this was a bug, so I tried to use Flatten Transparency whenever possible to eradicate such groups!

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 ,
Dec 30, 2016 Dec 30, 2016

Copy link to clipboard

Copied

thumbs up for a possible solution, but unfortunately it's not one that will work for me..

My artists are running this script on 20-30 files per day and each file routinely has 100k+ pathItems in it. Checking every pathItem in the document is not feasible i'm afraid.

I may actually just abandon support for this script and tell them that they can use it when it works and figure it out themselves when it doesn't. It's merely a single step in the preflight process that can be done relatively easily manually. I think i've already sunk enough time into supporting this minimally important convenience feature.

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
Valorous Hero ,
Dec 30, 2016 Dec 30, 2016

Copy link to clipboard

Copied

Hmm but what if you looked through every groupItem and just saw if its parent is a compound path? Maybe there's less groups in the documents to make it a bit faster.

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 ,
Dec 30, 2016 Dec 30, 2016

Copy link to clipboard

Copied

Definitely a possibility.. however the number of group items is also quite high, typically. I essentially need the script to work in less than a second to make it viable. And like i said, it's ultimately not that important in the grand scheme of things, so it's not high on my priority list. I was just hoping there'd be something i was missing so I could just make a quick fix and move on.

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 ,
Dec 30, 2016 Dec 30, 2016

Copy link to clipboard

Copied

true, whatever is less but I don't think he has 100k compoundPaths, he could set up a function to "treat" all compoundPathItems, it shouldn't add a big overhead.

app.executeMenuCommand("noCompoundPath"); // release

app.executeMenuCommand("compoundPath"); // make

app.executeMenuCommand("group");

app.executeMenuCommand("ungroup");

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 ,
Dec 30, 2016 Dec 30, 2016

Copy link to clipboard

Copied

Or easy

app.executeMenuCommand('selectall');

app.executeMenuCommand('noCompoundPath'); 

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 ,
Dec 30, 2016 Dec 30, 2016

Copy link to clipboard

Copied

true, but compoundPaths need to be re-made, many times they have "holes" in them.

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 ,
Dec 30, 2016 Dec 30, 2016

Copy link to clipboard

Copied

You are right, absolutely.

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 ,
Jan 03, 2017 Jan 03, 2017

Copy link to clipboard

Copied

This turned out to be the best (though not ideal) answer. Though i ended up just forgetting about the initial reason i posted this question and used this technique for another task i've been meaning to do (cleaning up the grouping structure of existing files in order to make easier batch fixes to the files later if need be).

Thanks again, Carlos, as well as everyone else who contributed to this topic. You guys are all awesome.

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 ,
Jan 04, 2017 Jan 04, 2017

Copy link to clipboard

Copied

you're welcome

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
Participant ,
Jan 05, 2017 Jan 05, 2017

Copy link to clipboard

Copied

The ideal answer is to look at Illustrator SDK cause JS cant hold 100k objects (seems it cant hold even 1k objects).

The check condition is "if (myArtType ==kGroupArt &&  (myAttributes&kArtPartOfCompound) )" which means the object is a group and part of Compound Path at the same time.

It takes  0,1 sec to process and fix 93k objects.

normalizeCompound.png

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 ,
Dec 30, 2016 Dec 30, 2016

Copy link to clipboard

Copied

pesky compoundpath groups, you should Release CompoundPath, Ungroup, keep ungrouping until group count reaches zero, re-Make CompountPath...these days it's easy with ExecuteMenuCommand.

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 ,
Dec 30, 2016 Dec 30, 2016

Copy link to clipboard

Copied

I actually had that thought as i was replying to Silly-V's suggestion. However I didn't see any options for releasing compound paths in the executeMenuCommand documentation.. Am i just missing that part??

Here's where i was looking:

Illustrator CC2014 Menu Commands Reference - 手抜きLab@DTPの現場

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
Participant ,
Jan 06, 2017 Jan 06, 2017

Copy link to clipboard

Copied

Hope you know how to install aip files.

Win only, 64 bit, CC-CC2015. Works with selection. Look at Objects menu.

Here it is.

Seems the plugin works correctly, but I have not tested it much.

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
Valorous Hero ,
Jan 06, 2017 Jan 06, 2017

Copy link to clipboard

Copied

Wow cool I'm going to try this out!

So when creating .aip plugins do you always have to create different code for Windows and Mac?

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
Participant ,
Jan 06, 2017 Jan 06, 2017

Copy link to clipboard

Copied

The code is basically the same except of GUI (Win32API for Windows). I mean some dialog windows with lots of buttons, input fileds etc. Alerts and warnings can be done with common SDK functions.

But you need Mac to compile plugins for Mac (which I don't have).

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
Valorous Hero ,
Jan 07, 2017 Jan 07, 2017

Copy link to clipboard

Copied

Okay yea, I have tried to set up my Xcode on my mac, but have been too busy to make it work properly as of yet.

So, in order to develop cross-platform .aip plugins, one needs to just have different code for the UI but also needs to have both operating systems to compile the plugin for each one's use. Or do people make a couple of versions of a plugin and have the users download the one that's right for their OS?

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
Participant ,
Jan 07, 2017 Jan 07, 2017

Copy link to clipboard

Copied

The 1st assumption is correct. One needs to have Visual studio and Xcode installed to make plugins for both platforms.

The point is aip file is dll. Dll is kind of separate platform-dependent program with its own entry point. It can be compiled on native platform only afaik.

I see you're a Mac guy.  I'll try to build mac plugin in a couple of days.

Update. I wrote "visual sudio and xcode installed". To make it more obvious: you should have two independent systems.

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
Valorous Hero ,
Jan 07, 2017 Jan 07, 2017

Copy link to clipboard

Copied

Mac or PC, I am really both, just want to go the Mac route because I have never done anything yet in Xcode.

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

Copy link to clipboard

Copied

LATEST

It's been years since I had to deal with this, and I'm surprised there isn't a working function posted here.

 

Anyway, here's what I came up with. Replace the argument in the function call to however you've defined your compound path (or group) item.

var i = {}, doc = activeDocument

firstPathInContainer( doc.selection[0] )



function firstPathInContainer( item ) {

  if( item.pathItems.length ) return item.pathItems[0]

  var path, sel, type

  doc.selection = item

  type = item.typename
  if( type == 'CompoundPathItem' ) 
    app.executeMenuCommand('noCompoundPath')
  else if( type == 'GroupItem' )
    app.executeMenuCommand('ungroup')

  sel = activeDocument.selection
  for( i.sel=0; i.sel<sel.length; i.sel++ ) {
    if( path = firstPathInContainer( sel[i.sel] ) ) break;
  }

  doc.selection = sel
  if( type == 'CompoundPathItem')
    app.executeMenuCommand('compoundPath')
  else if( type == 'GroupItem' )
    app.executeMenuCommand('group')

  return path
}

 

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