The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniGraffle > OmniGraffle General
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Showing/Hiding a notes layer across document using Applescript Thread Tools Search this Thread Display Modes
I am trying to globally show/hide a layer called "Notes" which exists in every canvas using an applescript.

What I have so far is:

Code:
tell application "OmniGraffle Professional 5"
	set theDocument to front document
	set canvasCount to count of canvases of theDocument
	
	repeat with canvasNumber from 1 to canvasCount
		
		set canvas of front window to canvas canvasNumber of theDocument
		set the visible of layer "Notes" to true
	end repeat
end tell
Code:
set the visible of layer "Notes" to true
- OG doesn't like this. In fact I can't work out how to do anything with the layers within a canvas - I can't get Applescript to return how many there are, their names etc.

Any suggestions from a Graffle guru out there?

Thank you!

Last edited by Andrew N; 2008-10-16 at 07:52 AM..
 
Quote:
Originally Posted by Andrew N View Post
Code:
set the visbile of layer "Notes" to true
- OG doesn't like this.
Are you using the same misspelling ("visbile" instead of "visible") in the actual script?
 
Quote:
Originally Posted by whpalmer4 View Post
Are you using the same misspelling ("visbile" instead of "visible") in the actual script?
Sorry typo. Visible is the correct spelling!

But, no this isn't the issue. The error I get is "Can't set layer "Notes" to true.
 
OK I have an answer. OG great support provided this script:

Code:
tell application "OmniGraffle Professional 5"
	set theDocument to front document
	set allCanvases to canvases of theDocument
	repeat with canvasCount from 1 to (length of allCanvases)
		set nextCanvas to item canvasCount of allCanvases
		set nextCanvasLayers to layers of nextCanvas
		repeat with layercount from 1 to (length of nextCanvasLayers)
			set nextLayer to item layercount of nextCanvasLayers
			if (name of nextLayer is "Notes") then
				set currentVisibility to visible of nextLayer
				set visible of nextLayer to not currentVisibility
			end if
		end repeat
	end repeat
end tell
Seems to work a treat. More complex than I thought...

Last edited by Andrew N; 2008-10-16 at 03:34 PM..
 
This, which also works, is a simple edit of your code.

Code:
tell application "OmniGraffle Professional 5"
	set theDocument to front document
	set canvasCount to count of canvases of theDocument
	
	repeat with canvasNumber from 1 to canvasCount
		
		set oCanvas to canvas canvasNumber of theDocument
		set lyrNotes to layer "Notes" of oCanvas
		set blnVisible to visible of lyrNotes
		set visible of lyrNotes to not blnVisible
	end repeat
end tell
 
Thanks Rob - looks like a more efficient piece of code as it doesn't run the embedded repeat function.
 
Hi guys-

I'm using Omni 5.1. The more verbose script above works, while the more compact one, below it, does not work for me. It compiles but generates an error when I try to use it.

Does every canvas need to have a 'Notes' layer for the second script to work?

Also, I'd like to be able to create print/non-printable and locked/unlocked toggles. Is there somewhere that documents what OMNI exposes to AppleScript like a document object model? I've programmed for 30 years, but never much with applescript before?

Thanks!
 
Quote:
Originally Posted by jdkunesh View Post
Does every canvas need to have a 'Notes' layer for the second script to work?
Yes, but the following redraft should suspend that requirement:

Code:
tell application "OmniGraffle Professional 5"
	set theDocument to front document
	set canvasCount to count of canvases of theDocument
	
	repeat with canvasNumber from 1 to canvasCount
		
		set oCanvas to canvas canvasNumber of theDocument
		try
			set lyrNotes to layer "Notes" of oCanvas
			set blnVisible to visible of lyrNotes
			set visible of lyrNotes to not blnVisible
		end try
	end repeat
end tell

Script editing software for Applescript will generally have an "Open Dictionary" command in the menu system (probably under the File menu), which will enable you to look at documentation of an application's object model.
 
Thanks Rob!!
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Showing/Hiding Layers Fails To Export To PDF pixel_pirate OmniGraffle General 6 2013-10-29 11:22 AM
Best Practice Question: Notes Inspector vs Notes Layer atwoodsa OmniGraffle General 2 2011-08-10 10:01 AM
Error message when showing/hiding Guides fjordaan OmniGraffle General 0 2010-04-30 01:10 PM
Images in notes not showing Ol!ver OmniFocus for iPhone 11 2008-09-04 11:29 AM
Shortcut for showing/hiding notes? Rolf_schmolling OmniOutliner 3 for Mac 1 2007-10-24 04:17 PM


All times are GMT -8. The time now is 09:03 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.