Skip to main content
Parts4Arts
Inspiring
Sep 1, 2021 9:10 AM UTC
Answered

Looking for Javascript commands for path finder operation?

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 is closed to new replies. Start a new post to keep the conversation going.
femkeblanco
femkeblancoCorrect answer
Legend
Sep 1, 2021 9:27 AM UTC

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

 

 

5 replies

Parts4Arts
Inspiring
Sep 1, 2021 12:00 PM UTC

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;
Translate
m1b
Community Expert
Community Expert
Sep 1, 2021 9:28 AM UTC

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

Translate
Parts4Arts
Inspiring
Sep 1, 2021 9:31 AM UTC

Thanks for the answer. But that are bad news 😞

– Jens.

Translate
femkeblanco
femkeblancoCorrect answer
Legend
Sep 1, 2021 9:27 AM UTC

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

 

 

Translate
Parts4Arts
Inspiring
Sep 1, 2021 9:44 AM UTC

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.

Translate