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

adding multiple paths into a compound path

Explorer ,
Jun 30, 2010 Jun 30, 2010

Copy link to clipboard

Copied

If I use the gui to add multiple paths into a compound path all I have to do is select multiple paths and choose Object->Compound Path->Make (or ctrl-8). When I do this then the bottom path which is filled has holes 'punched through' creating a window in the shape of the smaller paths which were on top of the larger one. For example, a large rectangle with a white fill color is the bottom item and two smaller paths are on top. I create a compound path and whatever is below the new compound path shows through in the largest shape of the previous two smaller paths.

If I use JavaScript and create a new compoundPathItem and move 3 paths into it, with the largest being first, then I get a compound path but only the first of the smaller objects creates a transparent space.

Here is a simplified example:

    var grpMask = doc.groupItems['mask group'];
   
    var compound = grpMask.compoundPathItems.add();
    var pathobj = grpMask.pathItems['bigbox'];
    pathobj.move(compound,ElementPlacement.INSIDE);
    pathobj = grpMask.pathItems['PathLeft'];
    pathobj.move(compound,ElementPlacement.INSIDE);


    pathobj = grpMask.pathItems['PathRight'];
    pathobj.move(compound,ElementPlacement.INSIDE);

In the above example the 'bigbox' path has the left and right paths on top of it but only the left path creates a transparent space in the original box.

I also tried using PLACEATEND instead of INSIDE and grouping the two smaller paths together and moving the group to the compound path.

Merging path items together won't work - I want to keep the original path's closed and intact without drawing a line between them so I can't just add their pathpoints together.

Is move() the best way to add existing paths to a new compound path?

Thanks!

TOPICS
Scripting

Views

4.8K

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

Contributor , Jun 30, 2010 Jun 30, 2010

I'm not sure,

have a look at polarity and/or evenodd propertys of pathItems inside the compoundpath.

maybe there is the difference.

?

Chris

Votes

Translate

Translate
Adobe
Guide ,
Jun 30, 2010 Jun 30, 2010

Copy link to clipboard

Copied

This is odd Im sure I have looked at this before and could not work it out, same result as you. However this time I tried in AppleScript and it worked (to my surprise) so I converted the same commands back to JavaScript and it worked too? I must be going mad…

#target illustrator var docRef = app.activeDocument; with (docRef) {      var x = compoundPathItems.add();      pathItems[0].move(x, ElementPlacement.PLACEATEND);      pathItems[1].move(x, ElementPlacement.PLACEATEND);      pathItems[2].move(x, ElementPlacement.PLACEATEND);      pathItems[3].move(x, ElementPlacement.PLACEATEND); }

Any how a straight forward move of 4 path items 1 large 3 smaller did cut all 3 holes in my test…

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
Contributor ,
Jun 30, 2010 Jun 30, 2010

Copy link to clipboard

Copied

I'm not sure,

have a look at polarity and/or evenodd propertys of pathItems inside the compoundpath.

maybe there is the difference.

?

Chris

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
Guide ,
Jul 01, 2010 Jul 01, 2010

Copy link to clipboard

Copied

Chris I looked at the 'polarity' the last time I tried this… I can't remember what is different this time around but the 3 hole paths all do turn negative as expected… Edit what may be different is my CS version my Trial CS5 works as I would have expected but CS2 does not but changing the polarity does get around this… This worked in CS2

#target illustrator var docRef = app.activeDocument; with (docRef) {      var x = compoundPathItems.add();      for (var i = 0; i <= 3; i++) {           pathItems.move(x, ElementPlacement.PLACEATEND);           if (i < 3) {                x.pathItems.polarity = PolarityValues.NEGATIVE;           }      } }

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
Contributor ,
Jul 01, 2010 Jul 01, 2010

Copy link to clipboard

Copied

i tryed your (first) code, Mark (in cs3),

all 4 paths are positive and not "a hole".

I have to set the polarity too.

if i do it manually, polarity will change.

if i release the compoundpath manually,

polarity remains negativ,

and then run the script, all 3 are holes.

Chris

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
Guide ,
Jul 01, 2010 Jul 01, 2010

Copy link to clipboard

Copied

Im at work at the moment so only have access to CS2 where the second script works… The first script worked at home with CS5…

here were my test files… Before

Picture 1.png

and After…

Picture 2.png

As you can see with this I did not change the polarity of the last path as in this test case I knew it was the largest of the shapes not sure if that had any bearing on my results…?

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
Engaged ,
Jul 01, 2010 Jul 01, 2010

Copy link to clipboard

Copied

Hi all,

Just note the second script from Muppet Mark works for CS4.

i had also noticed that KnockoutState was sometime DISABLED or ENABLED, but in fact i didn't understand this property, how to use it. Anyway it seems that this way is wrong.

regards,

art.chrome

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 ,
Jul 01, 2010 Jul 01, 2010

Copy link to clipboard

Copied

I just set evenodd = true for all of the paths and it worked. Changing the artworkKnockout value manually wasn't necessary.

The docs just say that evenodd If true, the even-odd rule should be used to determine “insideness.” It's a bit vague on the effect of this. The same goes for polarity.

Is there something more complete than the Adobe Illustrator CS4 Scripting Reference: JavaScript guide?

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
Guide ,
Jul 01, 2010 Jul 01, 2010

Copy link to clipboard

Copied

if any stumbles across the meaning of the property 'is isolated' then I would like to know because it just don't figure to me…

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 ,
Jul 01, 2010 Jul 01, 2010

Copy link to clipboard

Copied

In the UI you can isolate a path or group which greys out all other items on the page and lets you edit just the one that is isolated. If you have lots of overlapping objects and it's hard to alter the ones you want this is probably useful.  That's my take on it anyway. I've only used it in the UI when selecting the right object was difficult.

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
Contributor ,
Jul 01, 2010 Jul 01, 2010

Copy link to clipboard

Copied

no, has nothing to do with isolationmode.

was still there in cs (and 10?).

but for what?

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
Contributor ,
Jul 01, 2010 Jul 01, 2010

Copy link to clipboard

Copied

LATEST

Ah, this is...

I don't know in english, have a look at the transparancy palette (with options).

the top left checkmark.

chris

and knockout is the top right...

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