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

 
Applescript help Thread Tools Search this Thread Display Modes
Hi,

I have a series of questions regarding applescript for omnigraffle professional 5.

Let me start by this:
Let's say I have 10canvases in my document, and I want my script to append/insert a new canvas after the fourth canvas.
I'd imagine it'll be something like this
Code:
tell the first document
		set myCanvas to (make new canvas at fourth canvas)
end tell
However this script overwrite my fourth canvas instead of inserting a new canvas.


Thanks
 
One approach might be:

Code:
tell application id "OGfl"
	tell front document
		set myCanvas to (make new canvas with properties {name:"New blank sheet"})
		move myCanvas to after canvas 4
	end tell
end tell
 
Hi RobTrew,
Thanks for the answer. It worked.

I think the following is my final question before I get this script working fully..
Let's say again, I have 10 canvases, and I have a loop like this
Code:
tell application "OmniGraffle Professional 5"
	set theCanvases to every canvas of the first document
        set myCanvas to fourth canvas of the first document
        set numCanvas to 0 
        set maxItemsPerCanvas to 3
	tell the first document
		repeat with theCanvas in theCanvases
                   tell myCanvas
                      --@CODE TO DRAW SOMETHING
                   end tell
                   set numCanvas to numCanvas + 1
                   if numCanvas > maxItemsPerCanvas then
			set myCanvas to canvas after myCanvas --@HERE
			set maxItemsPerCanvas to maxItemsPerCanvas + maxItemsPerCanvas
		   end if
		end repeat
	end tell
end tell
@HERE : I wanted to set myCanvas to the next Canvas in the document after myCanvas. But this code doesn't work. It is essentially "set myCanvas to fifth canvas" but I want to do this without hardcoding it.
 
May be easier, if you want to loop through the last N canvases, to loop with an index range.

Code:
tell application id "OGfl"
	set oWin to front window
	tell front document
		
		set lngCanvas to count of canvases
		repeat with i from 4 to lngCanvas
			set oCanvas to canvas i
			set canvas of oWin to oCanvas
		end repeat
		
		set canvas of oWin to canvas 5
	end tell
end tell

Last edited by RobTrew; 2012-09-04 at 09:07 AM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML and AppleScript seanprice OmniFocus Extras 0 2013-03-14 02:07 PM
Applescript help mojaverat OmniFocus 1 for Mac 1 2011-08-23 04:18 PM
$$ for Applescript Help Hewdini OmniFocus Extras 1 2009-08-14 12:34 PM
Applescript Help ryan_marsh OmniFocus 1 for Mac 3 2008-11-24 09:51 AM
Help with applescript mrpuggles AppleScripting Omni Apps 1 2008-09-16 05:40 PM


All times are GMT -8. The time now is 02:35 PM.


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