Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

get position of selected object

Explorer ,
Oct 04, 2012 Oct 04, 2012

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.

TOPICS
Scripting
1.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Oct 04, 2012 Oct 04, 2012

if it is one item selected, yes, if more that one, yes also but it needs parsing

alert(app.activeDocument.selection[0].position)

Translate
Adobe
Community Expert ,
Oct 04, 2012 Oct 04, 2012

if it is one item selected, yes, if more that one, yes also but it needs parsing

alert(app.activeDocument.selection[0].position)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 04, 2012 Oct 04, 2012

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 11, 2012 Oct 11, 2012

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 11, 2012 Oct 11, 2012
LATEST

correct, it is based on stacking order, not selection order.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 04, 2012 Oct 04, 2012

The position property is inherited from the pageItem super class… You can also work with pageItems the same as other collections…

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines