Active layer

I have a book with 50 document. Each document with several layers (4)
Content, Illustrations, Prices €, Prices £

I want to make a script that can activate (or deactivate) a layer. Is this possible with applescript?

Hi Evisita

Is this in indesign or illustrator?? maybe, what version if it is?, if not what application and version are we dealing with

cheers

I am working in Indesign CS5

this is what I get at this moment, but it just activate a layer, but it won’t change the visibility

tell application "Adobe InDesign CS5"
	activate
	if active document exists then
	else
		set GetParentPath to ((choose file with prompt "Kies het document dat je wilt aanpassen:" of type "IDd5"))
		open GetParentPath
		delay 1
	end if
end tell
tell application "Adobe InDesign CS5"
	set myDocument to active document
	set Interactive to (display dialog "Wil je euros?" buttons {"Ja", "Neen"} default button {"Ja"})
	if button returned of Interactive is "Ja" then
		set active layer of active window to layer "€" of myDocument
	else
		set active layer of active window to layer "£" of myDocument
	end if
end tell

Hi Evisita

try this, toggles each layer’s visibility on or off, depending on your choice

tell application "Adobe InDesign CS5"
	activate
	if active document exists then
	else
		set GetParentPath to ((choose file with prompt "Kies het document dat je wilt aanpassen:" of type "IDd5"))
		open GetParentPath
		delay 1
	end if
end tell
tell application "Adobe InDesign CS5"
	set myDocument to active document
	set Interactive to (display dialog "Wil je euros?" buttons {"Ja", "Neen"} default button {"Ja"})
	if button returned of Interactive is "Ja" then
		
		set active layer of active window to layer "€" of myDocument
		tell active document
			set properties of layer "€" to {visible:true}
			set properties of layer "£" to {visible:false}
		end tell
	else
		set active layer of active window to layer "£" of myDocument
		tell active document
			set properties of layer "£" to {visible:true}
			set properties of layer "€" to {visible:false}
			
		end tell
	end if
	
end tell

Thanks a lot…

Do you know if it is possible to do this is every document of a book?
(I want that the script opens document 1, activates the wright layer, saves the document and than opens document 2,…)

I don’t see any reason why you cant, you would just have to pop the code in a repeat ,which should take care of it for you

Thanks,

I am sorry, I am just a beginner.

I will search how I will have to make a repeat operation. If I can’t find it, you will hear it… :wink:

mate, im no expert trust me, just happy to help if i can

Budgie,

I made this


tell application "Adobe InDesign CS5.5"
	activate
	if active book exists then
	else
		set GetParentPath to ((choose file with prompt "Kies een Indesignbook:" of type "Indb"))
		open GetParentPath
		delay 1
	end if
end tell
tell application "Adobe InDesign CS5.5"
	tell active book
		set fileList to full name of book contents
	end tell
	repeat with aFile in fileList
		set theDoc to open aFile
		set myDocument to active document
		set Prices to (display dialog "Wil je prijzen vermelden in je cataloog?" buttons {"Ja", "Neen"} default button {"Ja"})
		if button returned of Prices is "Ja" then
			set active layer of active window to layer "Prijzen" of myDocument
			tell active document
				set properties of layer "Prijzen" to {visible:true}
				set properties of layer "Geen Prijzen" to {visible:false}
			end tell
		else
			set active layer of active window to layer "Geen Prijzen" of myDocument
			tell active document
				set properties of layer "Geen Prijzen" to {visible:true}
				set properties of layer "Prijzen€" to {visible:false}
				
			end tell
		end if
		close theDoc saving yes
	end repeat
end tell

it works fine, but now I get the dialog after opening each document. Is it possible to make the question in the beginning?

Budgie,

I did it… it works with only one question in the beginning…

great stuff, glad you got it to work

Hi,

I will to update my script… Suppose we have 4 Price layers and some other layers… We want to make just one Price layer visible (and the other layers). I made this…


tell application "Adobe InDesign CS5.5"
	activate
	if active book exists then
	else
		set GetParentPath to ((choose file with prompt "Kies een Indesignbook:" of type "IDb5.5"))
		open GetParentPath
		delay 1
	end if
end tell
tell application "Adobe InDesign CS5.5"
	set Prices to (display dialog "Wil je prijzen vermelden in je cataloog?" buttons {"Ja", "Neen"} default button {"Ja"})
	set CountryArray to {"BE", "FR", "NL", "EX", "DE"}
	set CountryID to choose from list CountryArray with prompt "Selecteer de juiste catalogus prijzen." OK button name "Update book"
	if CountryID is false then return
	
	tell active book
		set fileList to full name of book contents
	end tell
	repeat with aFile in fileList
		set theDoc to open aFile
		set myDocument to active document
		tell myDocument
			set AllLayers to every layer
			repeat with thisLayer in AllLayers
				set visible of thisLayer to true
			end repeat
		end tell
		if button returned of Prices is "Ja" then
			set ActivateLayer to "prijzen & '& CountryID & '"
			set DeactivateLayer to "????"
			tell active document
				set properties of layer ActivateLayer to {visible:true}
				set properties of layer DeactivateLayer to {visible:false}
			end tell
		else
			tell active document
			set DeactivateLayer to "???"
				set properties of layer "Geen Prijzen" to {visible:true}
				set properties of layer "DeactivateLayer to {visible:false}
				
			end tell
		end if
		close theDoc saving yes
	end repeat
end tell

I think I can make the chosen layer visible, but the how do I make the other price layers (DeactivateLaye) invisible?