Skip to content

Instantly share code, notes, and snippets.

@moxuse
Last active January 19, 2016 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moxuse/c07744ea5c54a5508406 to your computer and use it in GitHub Desktop.
Save moxuse/c07744ea5c54a5508406 to your computer and use it in GitHub Desktop.
Adobe script. Split all anchors of path to json array
#target illustrator
var sel = app.activeDocument.selection;
var height_ = app.activeDocument.height
var file = File.saveDialog('save centers', 'center:*.txt');
var height_ = app.activeDocument.height
file.open('w')
file.write("[\n")
for(var i = 0; i < sel.length; i++){
if(sel[i].typename == "PathItem"){
var points = sel[i].pathPoints;
$.writeln(points)
for (var j = 0; j< points.length; j++) {
var pos = points[j].anchor;
file.write("\t{\"x\": "+ pos[0] + " , \"y\": "+ (height_ - pos[1]) +"}");
if (j != points.length-1) {
file.write(",")
}
file.write("\n")
}
}
}
file.write("]")
file.close();
@moxuse
Copy link
Author

moxuse commented Jan 14, 2016

.aiファイルのパス状態でスクリプトを使うと、y座標がずれます。一度svgファイルにして開き直してからスクリプト走らせてください

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment