# Automatically transform curves to polygons in AI CC

I have a script that reads SVG coordinates and creates a dot on each anchor point. The problem is that it does not work with curves so I need to transform the curves of any shape into straight lines - example:

A basic object like that is somewhat easy, but I actually need it on a larger scale. The simplest would look like this:

Is there any way to achieve that automatically with Illustrator CC?

I could adjust the script to read another file extension as long as it only outputs X and Y coordinates (no curves). Ex:

``````-20.8,262.5
-4.3,263.6
4,264.9
13.4,267.2
23.5,270.6
34.5,275.4
``````
• I can't tell you how... but the thing you are looking for is Flatness. All curves are constructed of straight segments upon output. The Flatness setting controls the tolerance before a new segment (anchor) is added. Illustrator (10 years ago) used to allow the user to control the Flatness setting upon output. That has since been removed in favor of the "highest possible option" automatically. So... long comment short :::: Look for something regarding Flatness in the script to edit. Commented Feb 20, 2016 at 0:35

One can do this with a combo of curve simplification and divide command, sort of. Do this:

1. Choose Object → Path → Add Anchor Points. This will add a anchor at the middle of each span (not uniform but along the t parameter of curve). Do this a few times for enough points.

2. The problem with previous step is that it also divides straight lines. Let us counter this with Object → Path → Simplify....

• Option straight lines ON
• Angle threshold to something low (Preview until your happy)

All of the above works uniformly on as many objects as you select so its really a few clicks no matter how complex your path is.

Image 1: Result of each stage. From left to right original, multi divided and simplified.

Now this is nonideal in many ways, for example you couldt want uniform stepping or so. One way would be to use ghostScript to do the flattening. Another would be to split with something more intelligent like Divide (length) by Hiroyuki Sato. This script would also be easy to modify to do the kind of flattening you need. Also this way you could get the points without actually flattening at all.

Another splitting option is to use a few lines as cutting cookie and then use shape builder to divide objects below. (there is a side effect in shape builder that splits at all intersections when you delete a segment.) But YMMV depending on why you sample the shape in the first place.

Image 2: Linear sampling along x axis done with splitting with a shape builder side effect (1 click to split all + creation and deletion of cookiecutter).

• Thanks @joojaa, I knew about adding extra anchor points, but it didn't struck me how that would be helpful, before fully exploring the Simplify function. By chance I figured it out myself, but you put it in a very nice understandable way. With this technique I managed to create the second shape in my post with 95% accuracy and 156 points. I'll have a look at the Divide script, seems promising. Thank you! Commented Feb 20, 2016 at 16:07

I know this is old. I'm actually seeing a lot of flatness problems in illy 2017 trying to flatten small intricate curvy paths and finding that curves are being lost in some areas. This is the first post I could even find that remembered there was a flatness setting years ago. I knew I wasn't crazy.

Adding points did help a little. It kept more fidelity but the loss of curves still happens. Maybe I will try scaling the whole shape way up before flattening and then scaling back down?

• If you have a question please ask a new one and explain better the problem or should that be a comment? Welcome! Commented Dec 20, 2018 at 21:18