How would you write a script to move all points of all selected paths to the nearest (non-pixel grid) grid point?
e.g. I want all of the points of each polygon/path to snap to the nearest point on a custom grid. Mine is setup as 1 grid unit = 11.338px or 4mm, but ideally the script would extend to any unit value
MY PSEUDOCODE, v0.1:
// set grid units as pixels - in my case 11.338px = 8mm = 1 grid unit
units = 11.338
// Nested loop through all polygons/paths, then all points in each polygon
For each Polygon {
For each Point P in Polygon {
// move the Point x, y to the nearest grid point in units
P.x = units * Round(P.x/units)
P.y = units * Round(P.y/units)
}
}
Does this make sense? It's been a while since I've done any programming. I've also never scripted for Illustrator, so not exactly sure how to implement this.
LINK: I've looked at the post by @KromStern but not sure how to implement based on that thread. How to align all selected points to a grid?