Skip to main content
Parts4Arts
Inspiring
September 1, 2021
Answered

Looking for Javascript commands for path finder operation?

  • September 1, 2021
  • 3 replies
  • 2965 views

Hello all,


I am looking for the commands in javascript to use the functions of the pathfinder in the script like Union or Delete Hidden Surface. Where can I find a documentation of these commands?


Thanks for the help in advance.
Jens.

This topic has been closed for replies.
Correct answer femkeblanco

There is no counterpart to the pathfinder panel in ExtendScript. The closest there is are menu commands for the pathfinder effect (Effect > Pathfinder). These are applied to a selected group, so the paths need selecting and grouping before, and apply effects, so they need expanding after. E.g.

 

app.executeMenuCommand("group");
app.executeMenuCommand("Live Pathfinder Add");
app.executeMenuCommand("expandStyle");
app.executeMenuCommand("ungroup");

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

 

 

3 replies

Parts4Arts
Inspiring
September 1, 2021

Thanks for your helps. Here is my script, that I made with:

 

// Simplify the currently selected object and preserve its name

// Preliminaries // Vorbereitungen
var docRef = app.activeDocument;
var selectedObjects = docRef.selection;
var vName = selectedObjects[0].name;

// Remove invisible paths // Entferne nicht sichtbare Pfade
app.executeMenuCommand("group");
app.executeMenuCommand("Live Pathfinder Minus Back");
app.executeMenuCommand("expandStyle");
app.executeMenuCommand("ungroup");

// Assign the old name to the new object // Weise dem neuen Objekt den alten Namen zu
selectedObjects = docRef.selection;
selectedObjects[0].name = vName;
m1b
Community Expert
Community Expert
September 1, 2021

There doesn't seem to be any nice API for pathfinder. Two options are available that I know of.

 

1. ExecuteMenuCommand

For example:

app.executeMenuCommand("group");
app.executeMenuCommand("Live Pathfinder Add");
app.executeMenuCommand("expandStyle");
app.executeMenuCommand("ungroup");

There is a list of commands here, and I'm sure other places.

 

2. Live Effects > Pathfinder

I have a github repo that includes some helper scripts for using Live Effects.

 

- Mark

Parts4Arts
Inspiring
September 1, 2021

Thanks for the answer. But that are bad news 😞

– Jens.

femkeblanco
femkeblancoCorrect answer
Legend
September 1, 2021

There is no counterpart to the pathfinder panel in ExtendScript. The closest there is are menu commands for the pathfinder effect (Effect > Pathfinder). These are applied to a selected group, so the paths need selecting and grouping before, and apply effects, so they need expanding after. E.g.

 

app.executeMenuCommand("group");
app.executeMenuCommand("Live Pathfinder Add");
app.executeMenuCommand("expandStyle");
app.executeMenuCommand("ungroup");

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

 

 

Parts4Arts
Inspiring
September 1, 2021

Thanks for this list. It works only with objects in a group and it's only an optical chance, the forms/objects are still the old ones.