[Help] Errors when try to set a layer to unvisible in illustrator

Hi

I’m new to applescript, and trying to create a script which can set certain layers to visible/unvisible in an ai file (illustrator CS 5), but when I running this script, it send back an error message said “can not set “visible of "layerName" to true”. number -10006 from visible of “layerName””. I don’t know why and did lots of research, but got nothing.

Please help me with this.

Thanks.

PS, I can create new layer and make this new layer visible/unvisible in same ai file.

Hi. Welcome to the forum.
If the target layer is locked, it must be unlocked prior to toggling the visibility. If this is not the cause of your issue, please post your code example for evaluation.

Thanks for your reply, please find my script below:

tell application "Adobe Illustrator"
	set locked of every layer of the current document to false
	set newLayer to make a new layer in the current document with properties {name:"test"}
	set visible of newLayer to false
	set visible of "black" to false
	set visible of "text layer" to false
end tell

This script can set new layer (test) to invisible, but can do nothing to visibility of existing layers (e.g. black and text layer).

Event log is

Is this caused by illustrator?

AppleScript: 2.2.1
Browser: Firefox 14.0.1
Operating System: Mac OS X (10.5)

tell application "Adobe Illustrator"
	set MyDocument to current document
	tell MyDocument
		set locked of every layer to false
		set newLayer to make a new layer with properties {name:"test"}
		set visible of newLayer to false
		set visible of layer "black" to false
		set visible of layer "text layer" to false
	end tell
end tell

It works that way :slight_smile:

when you say (set visible of “black” to false), it doesn’t know that you are addressing a layer.

Sbriss,

It works!! Thank you very much!!