5

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:

enter image description here

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

enter image description here

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
1
  • 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.
    – Scott
    Feb 20, 2016 at 0:35

3 Answers 3

4

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.

enter image description here

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.

enter image description here

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).

1
  • 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! Feb 20, 2016 at 16:07
0

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?

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

According to Adobe's help site:

Select the anchor points. If they are not visible, use the direct selection tool to view the points. Selecting the lasso tool will allow you to enclose a collection of points. Clicking on a point, shift clicking on additional points is the more manual method of selecting multiple points, other methods may be available.

Once selected, two icons on the tool bar become useful and effective. One of them is the "convert to corner point" icon, while the other is "convert to smooth point." If you pause your mouse over the icon, a tool tip may appear with these identifiers.

The above text is paraphrased from the linked site which also contains images of the icons used in the process.

I tested this process on an .SVG file that was converted to .AI which worked for some of the anchor points. This may be an artifact of the original file format, or the process may work only on some anchor points. Experimentation is indicated.

Inkscape works in a similar manner, although you can select a point when using the node editing tool, pausing your mouse over the point and scrolling the mouse wheel. This will advance the number of selected anchor points (nodes) being selected. Alternatively, one can also rubber-band a box around the desired points.

A similar reference for Inkscape can be found at tutorviacomputer.com for node editing. The difference in action is once the nodes are selected, use Shift-C to convert to corner nodes. The text also provides the option to use the "make selected nodes corner" icon.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.