Copy link to clipboard
Copied
is there a way to get position of any selected object? It seems like normally you have to dive into specific item like textFrames to get position, but was curious if there was a generic way of doing this for selected objects.
if it is one item selected, yes, if more that one, yes also but it needs parsing
alert(app.activeDocument.selection[0].position)
Copy link to clipboard
Copied
if it is one item selected, yes, if more that one, yes also but it needs parsing
alert(app.activeDocument.selection[0].position)
Copy link to clipboard
Copied
Sind mehrere Objekte ausgewählt, dann z.B. so (das Ergebnis wird in Millimeter ausgegeben):
var Sel = app.selection.length
for (i = 0; i < Sel; i++) {
alert("X0 von Objekt " + i + " = " +app.activeDocument.selection.position[0]*0.3527778 + " mm","Links");
alert("Y1 von Objekt " + i + " = " +app.activeDocument.selection.position[1]*0.3527778 + " mm","Oben");
}
Viel Spass
Copy link to clipboard
Copied
Ok, perfect. I am assuming if you return the object as a collection that the index is based on layer order and not order of selection? I was hoping to set up a script to copy text from one text frame to another, but wasn't sure how to go about controlling which ones recieves the text.
Copy link to clipboard
Copied
correct, it is based on stacking order, not selection order.
Copy link to clipboard
Copied
The position property is inherited from the pageItem super class… You can also work with pageItems the same as other collections…
Find more inspiration, events, and resources on the new Adobe Community
Explore Now