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?


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

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.


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:

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

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

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.

tell application "Adobe Illustrator"
	set docRef to the current document
	set x to first artboard of docRef
	set (properties of x) to {«class bAl9»:"123"}  
end tell

When you hit return, the “«class bAl9»” statement will wanish and turn to “name” but the compiler will consider the right “name” item, and the script will run like a charm.

Put this somewhere in your script as you will need to copy/paste before each compilation :

-- reminder : artboard's name property = «class bAl9»

[edit:] FYI the ruler origin code is “«class bAl8»”

Well, that’s good to know. Thanks!

Still an ugly bug in Illustrator scripting, but nice work-around.