Skip to main content
Participant
June 13, 2020
Answered

Shape Mode scripting

  • June 13, 2020
  • 3 replies
  • 1309 views

Hi guys!

I have been searching how to implement shape mode function with javscript (in the Illustrator interface they are called unite and minus front from the Pathfinder window), with no luck. Basically I just need to cut one pathItem fron another one with a script - does anyone know how to do it?

This topic has been closed for replies.
Correct answer femkeblanco

You could try a compound path.

 

// select 2 paths
var path1 = selection[0];
var path2 = selection[1];
path2.evenodd = true;
var compound1 = app.activeDocument.compoundPathItems.add();
path2.moveToEnd(compound1);
path1.moveToEnd(compound1);

 

3 replies

pixxxelschubser
Community Expert
Community Expert
July 11, 2020

Live Pathfinder Add
Live Pathfinder Crop
Live Pathfinder Divide
Live Pathfinder Exclude
Live Pathfinder Hard Mix
Live Pathfinder Intersect
Live Pathfinder Merge
Live Pathfinder Minus Back
Live Pathfinder Outline
Live Pathfinder Soft Mix
Live Pathfinder Subtract
Live Pathfinder Trap
Live Pathfinder Trim

 

Have fun

😉

femkeblanco
femkeblancoCorrect answer
Legend
June 13, 2020

You could try a compound path.

 

// select 2 paths
var path1 = selection[0];
var path2 = selection[1];
path2.evenodd = true;
var compound1 = app.activeDocument.compoundPathItems.add();
path2.moveToEnd(compound1);
path1.moveToEnd(compound1);

 

Anna41Author
Participant
June 14, 2020

Thanks! I have tried the compound shape before, but I didn't know about the evenodd property, so it was not working.

rcraighead
Legend
June 13, 2020

I use this as part of a larger script.
app.executeMenuCommand("Live Pathfinder Crop");

 

Search this tread for a complete list of "executeMenuCommand" commands.

 

 [JS] CS6+ executeMenuCommand



[ link modified for better readability by moderator ]

 

Anna41Author
Participant
June 14, 2020

Thank you! I didn't know exactly how to use the "executeMenuCommand" commands, now I do 🙂 I was trying to find a more 'clean' way let's say, but this approach will work if there isn't one.