Saturday, April 9, 2016

adobe illustrator - How to get the x/y position of multiple points on an artboard


I've got a bunch of objects on an artboard and I'd like to know the X/Y positions of them all. It would be fine to either have pixel values, or a % from the sides of the artboard.


Importantly, I don't want to just click each one and then copy down the values stored in their position fields. Ideally I could generate a list of:


object_name : x_position, y_position



values. Anyone have an idea how I could accomplish something like this in Illustrator or Inkscape?



Answer



You can also do this with Illustrator scripting, with same caveat as @Wrzlprmft's answer that objects have to be at top level. (you can recurse the for loop for groups compound paths etc if you wish. This is a quick example after all):


#target illustrator

var sel = app.activeDocument.selection;
var file = File.saveDialog('save centers', 'center:*.txt');
file.open('w')

for(var i = 0; i < sel.length; i++){

if(sel[i].typename == "PathItem"){
var obj = sel[i];
var center = obj.position
center[0] -= obj.width/2.0;
center[1] += obj.height/2.0;
file.write(obj.name+" : "+center[0] + ", "+center[1]+"\n");
}
}

file.close();


Script asks for file name and dumps data into it (without warning!). To run put in a .jsx file and drag and drop to illustrator or use extendScript toolkit.


No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...