Created
September 19, 2024 10:01
-
-
Save supertask/64192a51a83568351adb1c73ae80a5af to your computer and use it in GitHub Desktop.
Get selected position in pixel on Illustrator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var file = new File("~/Desktop/points.tsv"); // 出力先を指定 | |
file.open("w"); | |
var offsetX = 0; | |
var offsetY = -4271; | |
var doc = app.activeDocument; | |
var selection = doc.selection; | |
for (var i = selection.length - 1; i >= 0; i--) { | |
var item = selection[i]; | |
var position = doc.convertCoordinate(item.position, app.coordinateSystem, CoordinateSystem.ARTBOARDCOORDINATESYSTEM); | |
var x = position[0] + item.width * 0.5; | |
var y = position[1] - item.height * 0.5; | |
x = x - offsetX; | |
y = y - offsetY; | |
file.write(x + "\t" + y + "\n"); // オブジェクト名と座標をTSV形式で書き出し | |
} | |
file.close(); | |
alert("TSV file with object names has been saved to your desktop."); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment