Highlighted

Shape Mode Scripting continued - Unite equivalent script?

Explorer ,
Aug 18, 2020

Copy link to clipboard

Copied

I'm trying to work out how to achieve the same result as using the Pathfinder Shape Modes Unite tool via script. It's one of the few pathfinder tools not available via `executeMenu()`

 

So if I have two overlapping circles and unite them I end up with a single 'flattened' item of a single path with no internal paths, which differs from creating a CompoundPath which preserves the internal details for later editing - in this case, I'm deliberately trying to discard the internal details to get a clean united shape!

 

Screen Shot 2020-08-18 at 9.40.27 pm.png

 

 

 

 

A similar question was posed here https://community.adobe.com/t5/illustrator/shape-mode-scripting/m-p/11206350?page=1 and that was resolved for the minus front operation and also has some good examples of doing it with compound paths, but not anything on doing it in a way that mimics Unite.

 

I could record an action and replay that via a script, but it's super slow to replay and a bit of a hack!

Has anyone done this before? Thanks!

 

 

Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

Hi,

For Unite, the command is 'Live Pathfinder Add'

 

 

app.executeMenuCommand('Live Pathfinder Add')

 

When you record the action for Unite, you can see it add actions as Pathfinder->Add. See screenshot for reference.

But the problem is when I execute above command, nothing happens.

 

Screenshot 2020-08-18 at 6.46.04 PM.png

 

As per your requirement Unite operation can be done with combination of the exceuteMenuCommand. Make sure you have selected items.

 

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

 

Edit : Added after more information from Kurt_Gold

TOPICS
Performance, Scripting

Views

92

Likes

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

Shape Mode Scripting continued - Unite equivalent script?

Explorer ,
Aug 18, 2020

Copy link to clipboard

Copied

I'm trying to work out how to achieve the same result as using the Pathfinder Shape Modes Unite tool via script. It's one of the few pathfinder tools not available via `executeMenu()`

 

So if I have two overlapping circles and unite them I end up with a single 'flattened' item of a single path with no internal paths, which differs from creating a CompoundPath which preserves the internal details for later editing - in this case, I'm deliberately trying to discard the internal details to get a clean united shape!

 

Screen Shot 2020-08-18 at 9.40.27 pm.png

 

 

 

 

A similar question was posed here https://community.adobe.com/t5/illustrator/shape-mode-scripting/m-p/11206350?page=1 and that was resolved for the minus front operation and also has some good examples of doing it with compound paths, but not anything on doing it in a way that mimics Unite.

 

I could record an action and replay that via a script, but it's super slow to replay and a bit of a hack!

Has anyone done this before? Thanks!

 

 

Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

Hi,

For Unite, the command is 'Live Pathfinder Add'

 

 

app.executeMenuCommand('Live Pathfinder Add')

 

When you record the action for Unite, you can see it add actions as Pathfinder->Add. See screenshot for reference.

But the problem is when I execute above command, nothing happens.

 

Screenshot 2020-08-18 at 6.46.04 PM.png

 

As per your requirement Unite operation can be done with combination of the exceuteMenuCommand. Make sure you have selected items.

 

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

 

Edit : Added after more information from Kurt_Gold

TOPICS
Performance, Scripting

Views

93

Likes

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
Aug 18, 2020 1
Engaged ,
Aug 18, 2020

Copy link to clipboard

Copied

I thought 

app.executeMenuCommand("Live Pathfinder Add"); 

did that.  Sorry, I'm not at my PC to check.  

Likes

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
Reply
Loading...
Aug 18, 2020 1
Adobe Community Professional ,
Aug 18, 2020

Copy link to clipboard

Copied

Hi,

For Unite, the command is 'Live Pathfinder Add'

 

 

app.executeMenuCommand('Live Pathfinder Add')

 

When you record the action for Unite, you can see it add actions as Pathfinder->Add. See screenshot for reference.

But the problem is when I execute above command, nothing happens.

 

Screenshot 2020-08-18 at 6.46.04 PM.png

 

As per your requirement Unite operation can be done with combination of the exceuteMenuCommand. Make sure you have selected items.

 

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

 

Edit : Added after more information from Kurt_Gold

Best regards

Likes

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
Reply
Loading...
Aug 18, 2020 3
Adobe Community Professional ,
Aug 18, 2020

Copy link to clipboard

Copied

Charu,

 

> "But the problem is when I execute above command, nothing happens."

 

Actually something happens. The command applies a Pathfinder effect (see Effect menu).

 

Usually Pathfinder effects are applied to groups or layers. So, in order to see that something happens, just draw a couple of overlapping filled and stroked paths and group them. Then apply the script.

 

After that you may do an Object > Expand Appearance.

Likes

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
Reply
Loading...
Aug 18, 2020 2
Adobe Community Professional ,
Aug 18, 2020

Copy link to clipboard

Copied

Yes, that works perfectly.

With set of combination of commands, it is possible. I have updated the answer above.

 

Thank you. 🙂

 

 

Best regards

Likes

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
Reply
Loading...
Aug 18, 2020 1
Explorer ,
Aug 18, 2020

Copy link to clipboard

Copied

Thank you Charu and Kurt, that is totally awesome - exactly what I was hoping for!
Everytime I'm about to give on Extendscript the community saves the day 🙂

Likes

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
Reply
Loading...
Aug 18, 2020 1