我可以在Applescript中读写Illustrator画板的名称吗?

问题描述 投票:0回答:1

是否可以在Applescript中获得Illustrator画板的名称?

此脚本非常有效,直到我尝试获得画板的名称:

tell application "Adobe Illustrator"
  tell document 1
       set artboards_count to count of artboards
       set c to 1       
       repeat while c <= artboards_count 
          log index of artboard c as text
          log artboard rectangle of artboard c as text 
          log name of artboard c as text -- this line fails
          set c to c + 1
       end repeat
   end tell
end tell

log name of artboard c as text失败-一切正常。

消息是:

Adobe Illustrator got an error: Can’t get name of artboard 1 of document 1. (-1728)

关于为什么的任何想法?

BTW也无法设置名称。但是,如果我这样做

tell application "Adobe Illustrator"
  tell document 1
       return properties of artboard 1
  end tell
end tell

我得到(为清楚起见,增加了回车):

artboard rectangle:0.0, 0.0, 841.889999999999, -595.280000000001, 
   ruler PAR:1.0, show center:false, show cross hairs:false, 
   show safe areas:false, ruler origin:0.0, 0.0, name:Artboard 1,
   container:document 1, best type:reference, default type:reference,
   class:artboard, index:1

从哪个人应该认为属性name应该存在。

applescript adobe-illustrator
1个回答
0
投票

name属性是只读的,因此一旦画板存在就无法更改它。即使您可以获取画板的属性,但是如果您只想定位特定的画板,也无法将其转换为字符串。但是尽管如此,我还是偶然发现了一种方法。假设您有几个画板,并且想要定位名为“ Squash this”的画板。这是这样做的方法:

Tell application "Adobe Illustrator"
    tell current document
        set artCount to number of artboards
        repeat with i from 1 to artCount
            set artProp to get properties of artboard i
            try
                set propString to artProp as string --this will fail
            on error
                set errorDisp to text of result --this captures the text of the error
            set errorDispText to errorDisp as string --changes the text to a ¬ 
                searchable string
            end try
            if errorDispText contains "quash" then
                display notification "errorDispText" --oddly enough, this displays just ¬
                  the artboard name 
                exit repeat
            end if
        end repeat
     end tell
end tell
© www.soinside.com 2019 - 2024. All rights reserved.