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???
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");
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!
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.
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.
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.
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");
Copy link to clipboard
Copied
Or easy
app.executeMenuCommand('selectall');
app.executeMenuCommand('noCompoundPath');
Copy link to clipboard
Copied
true, but compoundPaths need to be re-made, many times they have "holes" in them.
Copy link to clipboard
Copied
You are right, absolutely.
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.
Copy link to clipboard
Copied
you're welcome
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.
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.
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:
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.
Seems the plugin works correctly, but I have not tested it much.
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?
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).
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?
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.
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.
Copy link to clipboard
Copied
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
}