Mobile app version of vmapp.org
Login or Join
Deb5748823

: 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

@Deb5748823

Posted in: #AdobeIllustrator #Export #IllustratorScripting #Inkscape #Svg

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?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Deb5748823

2 Comments

Sorted by latest first Latest Oldest Best

 

@Gail6891361

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.

10% popularity Vote Up Vote Down


 

@Turnbaugh909

If you look into the source of your SVG (open it with a text editor), you will find mainly stuff like this:

<rect
style="opacity:0.57009343;color:#000000;fill:#3f3790"
id="rect2996"
width="10.714286"
height="52.857143"
x="282.85715"
y="155.16518"
transform="translate(242.40625,114.78125)" />


Those lines starting with x= and y= contain exactly what you are looking for. You can now write some script to extract them, e.g., with an Inkscape-saved SVG the following works for me (for other SVGs you might need some adjustment):

grep " x="| y="" drawing.svg | sed "s/[^"]*"//;s/".*//" | paste -d 't' - -


Note that the above may not work if the objects belong to a transformed group or are otherwise special.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme