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

Script call for Simplify?

New Here ,
Feb 17, 2021 Feb 17, 2021

Copy link to clipboard

Copied

I can find some ways to process certain methods within ExtendScript, I have trouble figuring out how/when certain menu commands are available and called.  In this case, I would like to call the menu command (Object/Path/Simplify) on a path that I created. It would be just too easy if I could:

myPath = myPath.simplify (98,0,options:straigh:false)

I can dream can't I!

 

Generally, shouldn't you be able to call any menu item in Illustrator in some standardized way?

 

TOPICS
Scripting

Views

336

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
Adobe
Guide ,
Feb 17, 2021 Feb 17, 2021

Copy link to clipboard

Copied

For a selected path

 

app.executeMenuCommand("simplify menu item");

 

But this brings up the dialog box.  There is no way around this.

 

This is a list of menu commands (used as in the example above)

https://ten-artai.com/illustrator-ccver-22-menu-commands-list/ 

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
New Here ,
Feb 17, 2021 Feb 17, 2021

Copy link to clipboard

Copied

OK, that looks reasonable however, I tried that and get an error:  app.executeMenuCommand is not a function

Clearly, I am new to this...

Here is a sample of what I'm trying to accomplish.

The example code generates a circle with 360 points.  If I simplify via the menu, that gets colapsed to 5.

 

myDoc = app.activeDocument;
myLine = myDoc.pathItems.add();
tmpCoord = new Array();
for (i= 0 ; i < 360; i ++){
newPoint = myLine.pathPoints.add();
tmpCoord[0] = 50 * Math.cos(i *Math.PI/180);
tmpCoord[1] = 50 * Math.sin(i *Math.PI/180);
newPoint.anchor = tmpCoord;
newPoint.leftDirection = newPoint.anchor;
newPoint.rightDirection = newPoint.anchor;
newPoint.pointType = PointType.SMOOTH;
}
app.executeMenuCommand("simplify menu item"); // this command fails
app.redraw(); // this command works

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
Community Expert ,
Feb 17, 2021 Feb 17, 2021

Copy link to clipboard

Copied

What is your Illustrator version?

 

OT

What is your final goal?

Maybe you want a circle with a certain number of anchor points? Perhaps the existing Ovalize.jsx script will help you.

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
New Here ,
Feb 17, 2021 Feb 17, 2021

Copy link to clipboard

Copied

Version = CS5 (V15.0.0)

This is just a sample to demonstrate the error.  The goal is to take a complicated plot of points, in my case generated from thousands of data points, plot them to a complex pattern then have Illistrator simplify the plot to a reasonable size and number of data points.  Doing the plot is not a problem although I had to break that into segments to stay under what appears to be 8190 max. So I may end up with an array of 10 paths, all of which might have 8000 points.  The end goal then is to simplify each path (results look to reduce the points by 80%-90%)  Then I will want to Join them together into a single path.  So with that explaination I think you can see why I broke the prooblem to a sample of code that demonstrates the issue.

Given the circle generated in the example, it is clearly more complex than need be and can be reduced.

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
Community Expert ,
Feb 17, 2021 Feb 17, 2021

Copy link to clipboard

Copied

LATEST

Version = CS5 (V15.0.0)


By @Tembere

 

I thought so.

app.executeMenuCommand was introduced with CS6

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