Updated on February 15, 2019
Removing Ambiguous Anchors in Illustrator
Sometimes after merging shapes it happens that a vector in illustrator has anchors that you don’t need. These anchors might prevent you from doing some other great things with your vector. Unfortunately the simplify function of Illustrator is not sufficient enough to get rid of those, so that is why I wrote a little Illustrator script to get rid of the annoying redundant anchor points.
For a recent project I created some simplified maps of Europe with either horizontal, vertical or 45 degree lines. With the Live Paint Bucket tool I was able to fill a grid built up of triangles. This way I created the borders of countries in a simplified way. However after I tried to stylise the vectors by applying rounded corners to it I noticed that only a few corners were rounded.
After zooming to 6400% I noticed the following. Many corners anchors in my path had redundant anchors close around them:
Unfortunately I could not find any plugins that can solve this issue by removing the redundant anchors. So I decided to write my first Illustrator Script.
The script is not optimal yet, but it worked like a charm in most of my use cases. These are some of it functionalities:
- It removes the redundant anchors
- Several methods to determine the optimal anchor (which one to keep), or interpolate between the possible options. It does this by looking one anchor back and one ahead of the group of ambiguous anchors.
- It can solve multiple groups of anchors at the same time (be careful that
- Adjust the threshold of how close anchors may be together to be called ambiguous
Download & How to use:Download
- Download the script.
- Save it your Adobe Illustrator Presets/Scripts folder. In my case that was: file:\%ProgramFiles%AdobeAdobe Illustrator CS6 (64 Bit)Presetsen_GBScripts
- Open your file with ambiguous anchors
- Select with the Direct Selection Tool (A) part of a path, or select an entire path
- Execute the script by going to File > Scripts > RemoveRedundant
- If the script is not present in this submenu, either you did not save it at the right place, or you have to restart Illustrator
- You can also navigate to the script by clicking on Other Script…
There are some global variables you can change to optimise the script for your usage. You should open the script in a text editor to do so.
- Turn on debugging (several alerts will be presented when executing the script), default is off
- Show a prompt dialog when executing the script to ask for the precision (threshold) for finding redundant anchors, default is off
- The default precision. The default is 0.1; (I have used it between 1 and 0.01)
- Maximum number of anchors to evaluate. This is a precaution to prevent your illustrator from freezing. Default is 100 anchors.
- Trying to solve too many anchors, or heavily anchored paths at the same time might freeze illustrator
- Sometimes certain ambiguous groups are completely removed (could not identify yet how). This happens often when multiple groups are being solved in one go. To prevent this select one group of ambiguous anchors at the same time.
- Grouped paths will be skipped at the moment. So select your path at the lowest level possible!
- It only works for straight cornered anchors. If you have smooth anchors these will be converted to corner anchors.
- On large files it can be a bit slow
If you come across any issues or have some suggestions please let me know! In some future I might try to turn this into a proper plugin which would make the script run much smoother and faster.