Skip to main content
kaveh1000
Participant
March 3, 2018
質問

Can't get visible bounds of selection

  • March 3, 2018
  • 返信数 2.
  • 1752 ビュー

I am having a frustrating time starting off with AppleScript in Illustrator. I have one rectangle selected on a page and I want to get the visible bounds. I run the following script:

tell application "Adobe Illustrator"

  set myselection to the selection

  if myselection is {} then

  display dialog "Choose something"

  end if

  set theBounds to visible bounds of myselection

end tell

When I try to run it, "bounds" is highlighted and I get error:

Expected end of line, etc. but found property.

What am I doing wrong?

このトピックへの返信は締め切られました。

返信数 2

pixxxelschubser
Community Expert
Community Expert
March 3, 2018

Hi kaveh1000,

sorry, I'm not familiar with AppleScript.

But here is the [JS] equivalent of your code

#target Illustrator

var mySelection = app.selection[0];

if (!mySelection) {

    alert ("Choose something");

    } else {

        alert(mySelection.visibleBounds)

        }

Have fun

OMOTI
Inspiring
March 3, 2018

Hi,

The class of selection is list.

Please try this script.

tell application "Adobe Illustrator"

  set myselection to the selection

  set theBounds to {}

  if myselection is {} then

    display dialog "Choose something"

  end if

  log class of myselection (*list*)

  repeat with i in myselection

    copy visible bounds of i to the end of theBounds

  end repeat

end tell

kaveh1000
kaveh1000作成者
Participant
March 3, 2018

Thank you OMOTI

1. copying your script verbatim and compiling, I get error: "Expected “into”, “to”, etc. but found property."

2. Why do I need to specify "class"? What is missing in my script that stops it working? I am trying to understand the logic. (Tried some 30 years with AppleScript but still finding it not as intuitive as it seems at first sight!!)

pixxxelschubser
Community Expert
Community Expert
March 3, 2018

Did you tried my Javascript snippet?

Are you able to translate to AppleScript?

(Furthermore you also can work with app.doScript - implementing JS in AS)