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

Unable to work with this Compound Shape

Community Beginner ,
Jan 28, 2014 Jan 28, 2014

Copy link to clipboard

Copied

Good people of the forums,

I am working on a script that simplifies/consolidates art objects in documents that we eventually convert into FXG files.  I have run into a strange problem with a compound shape in one document. 

Normally upon encountering a "plugin item," the script selects the item and then runs an Expand Appearance so that it can begin to break it down to easier items.  In this case, Expand Appearance will not run, because the script seems to be unable to select the plugin item plus all of its children.  If I use the Layers palette to select the compound shape manually, outside of the script, Illustrator will select the compound shape and everything contained within it, like normal:

manual select.PNG

Yet, if I set the 'selected' property to true within the script, it selects the compound shape and any first-level children, but leaves any second level children (children of children) unselected, which makes Expand Appearance disabled:

script select.PNG

selection/expansion code looks like this:

    doc.pageItems.selected = true

    app.executeMenuCommand('expandStyle')

I thought of putting together a quick function that would accept a page item as an argument and select it along with all of its children, but in the case of plugin items I have been unable to access its children directly since there doesn't appear to be any such thing as [pluginItem].pageItems or [pluginItem].pathItems. 

I then figured maybe I could encapsulate the whole mess into a group so that I would have access to the groupObject.pageItems list and could select everything that way, but without selecting all the sub-children objects, Illustrator won't allow me to group them. 

I'm starting to feel like Yossarian with this thing.

TOPICS
Scripting

Views

1.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 , Jan 30, 2014 Jan 30, 2014

hmm...interesting, no can do

ok, doing the opposite seems to work, start with everything selected, then in your script check each pageItem, if it is NOT a pluginItem, deselect it.

Votes

Translate

Translate
Adobe
Community Expert ,
Jan 28, 2014 Jan 28, 2014

Copy link to clipboard

Copied

how did you create that pluginItem?

and just to make sure, select your pluginItem and run this script, you do get a "pluginItem", right?

var idoc = app.activeDocument;

var sel = idoc.selection[0];

alert(sel.typename);

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 28, 2014 Jan 28, 2014

Copy link to clipboard

Copied

I was able to replicate your problem,

try this

// select compound shapes with groups and loose items in it

// carlos canto

// http://forums.adobe.com/thread/1392150?tstart=0

var idoc = app.activeDocument;

idoc.pluginItems[0].selected = true;

var temp = idoc.selection[0];

temp.selected = true;

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 Beginner ,
Jan 29, 2014 Jan 29, 2014

Copy link to clipboard

Copied

Thanks for the reply, Carlos.

I tried selecting the plugin Item via doc.pluginItems[0], and then the temp variable like you wrote.  Even with all of that, Illustrator still only selects the 1st and 2nd-level objects, ignoring everything further down.

Part of what makes this script tricky is that it has to process hundreds of old and new artworks by several different artists, so standard practices are difficult to enforce and the script must be able to process all kinds of unexpected art setups.  Some of these setups are inefficient, messy, and poorly constructed, but we still have to try to break them down and process them.

In this particular case, we're looking now at having the script run a custom action we wrote that uses the pathfinder to release the compound shape.  Problem is, the artist set up this art so that the fill and stroke attributes were assigned to the compound shape, but not the elements contained within it.  When we run the release action, we lose all of the fill and stroke information.  I'd try to store those values first and then re-apply them later, but with plugin items being as....  well supported... as they are, [pluginItem].fillColor returns undefined.

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 29, 2014 Jan 29, 2014

Copy link to clipboard

Copied

can you share a file with such compound shape to play with? if yes, CS5 please.

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 Beginner ,
Jan 30, 2014 Jan 30, 2014

Copy link to clipboard

Copied

Sure thing.  Here is the difficult shape from the artwork just as it is in the original file, but saved for CS5 (instead of 6).

http://www.highrevproductions.com/CShape.ai

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 30, 2014 Jan 30, 2014

Copy link to clipboard

Copied

hmm...interesting, no can do

ok, doing the opposite seems to work, start with everything selected, then in your script check each pageItem, if it is NOT a pluginItem, deselect it.

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 Beginner ,
Jan 30, 2014 Jan 30, 2014

Copy link to clipboard

Copied

Carlos!   Thanks so much for your creative thinking.  That approach has allowed us to solve the problem.  It's still a little annoying that we have to go about it in such a backward fashion, but at least it does the job.

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 31, 2014 Jan 31, 2014

Copy link to clipboard

Copied

you're welcome, glad to help

here's another way,

- create a tempLayer

- create a tempGroup in tempLayer

- move your pluginItem to tempGroup; // to easily move back after expand

- tempLayer.hasSelectedArtwork = true; // this works!!

- expand

to maintain stacking order, you can move a duplicate() of the pluginItem to tempLayer, then after expand, move back to position, and delete original item.

depending on how many items your art has this may be more efficient than looping thru all items, try it with real files and let us know how it goes.

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
Advocate ,
Jul 13, 2023 Jul 13, 2023

Copy link to clipboard

Copied

LATEST

Is there caffeine de to access items for beide a pluginItrm. I've noticed when I use pathfinder subtract while holding option on Mac. You create a sort of live subtract. Meaning you can still edit ir.

 

When I run a script to return the type name, it returns pluginItem. I can't seem to find code to see if there are children. This original thrra was almost 10 years ago. But still couldn't find anything in recent scripting documentation 

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