Tuesday, September 17, 2019

#1 2019-04-21 10:13:04 pm

tonykenobi
Member
Registered: 2017-07-14
Posts: 3

How can i rename the illustrator Artboard name by AppleScript?

Hello all , I want to to rename the Artboard name in Apple Script , but still error

Can anyone help?

Applescript:


tell application "Adobe Illustrator"
   
   set docRef to the current document
   set x to artboards of docRef
   set the artboards of x with properties{name:"123"}
end tell

Offline

 

#2 2019-04-26 10:11:50 am

t.spoon
Member
From:: BFE, Massachusetts
Registered: 2013-01-13
Posts: 414

Re: How can i rename the illustrator Artboard name by AppleScript?

First off, Illustrator scripting support is terrible, so it's not surprising this doesn't work.

However, I am surprised by some failure modes here that I didn't expect, and maybe some more senior scripters can shed some light on.

Applescript:


tell application "Adobe Illustrator"
   tell document 1
       set firstArtboard to the first artboard
       set artBoardProps to the properties of firstArtboard
   end tell
end tell
return artBoardProps

Result:

{artboard rectangle:{0.0, 0.0, 595.276, -841.889999999999}, ruler PAR:1.0, show center:false, show cross hairs:false, show safe areas:false, ruler origin:{0.0, 0.0}, name:"Bob", container:document 1, best type:reference, default type:reference, index:1}



Applescript:

tell application "Adobe Illustrator"
   tell document 1
       set firstArtboard to the first artboard
       set artBoardProps to the properties of firstArtboard
       set artBoardName to the name of artBoardProps
   end tell
end tell

Result:
error message

Can’t get name of {artboard rectangle:{0.0, 0.0, 595.276, -841.889999999999}, ruler PAR:1.0, show center:false, show cross hairs:false, show safe areas:false, ruler origin:{0.0, 0.0}, name:"Bob", container:document 1 of application "Adobe Illustrator", best type:reference, default type:reference, class:artboard, index:1}



I tried all the rest of the items from the record, and they can be retrieved except "name" and "ruler origin."

Applescript:

tell application "Adobe Illustrator"
   tell document 1
       set firstArtboard to the first artboard
       set artBoardProps to the properties of firstArtboard
       set artBoardIndex to the index of artBoardProps
   end tell
end tell
return artBoardIndex

Result:
1

I'm pretty sure this must be an Illustrator bug, and I'm guessing it's going to be hard to set the artboard names given this difficulty in retrieving them.

If you just needed to find artboard names, there are ways around this bug by coercing the record to a list - or hacky-ways to coerce it to text. But I'm not thinking of a way to set it when Applescript errors if you attempt to address the item at all.


Hackintosh built February, 2012 |  Mac OS Sierra
GIGABYTE GA-Z68X-UD3H-B3 | Core i5 2500k | 16 GB DDR3 | GIGABYTE Geforce 1050 TI 4GB
250 GB Samsung 850 EVO | 4 TB RAID
Dell Ultrasharp U3011 | Dell Ultrasharp 2007FPb

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)