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

 
OmniGraffle Word Count Thread Tools Search this Thread Display Modes
I needed a word count this morning, for all the text in the nodes of a diagram.

In case anyone else needs to do this, here is what I used:

Code:
-- Word Count for OmniGraffle
-- Ver .001

set text item delimiters to space
tell application id "com.omnigroup.OmniGrafflePro"
	set oWin to front window
	tell canvas of oWin
		set lngWords to count of words of ((text of solids) as text)
		set {strCanvas, strDoc} to {name, name of oWin}
	end tell
	display dialog (lngWords as string) & " words in" & return & return & strCanvas ¬
		& " of " & return & return & strDoc buttons {"OK"} with title "OmniGraffle Word Count" with icon 1
end tell
 
Then, of course, I realised that I also needed to be able to count the words in one or more selected shapes (in addition to the count for the whole canvas).



so I needed version two, pasted below.

Code:
property pTitle : "Word Count for OmniGraffle"
property pVersion : ".002"

-- Ver 2 adds a postscript giving a separate total for words in those shapes which are currently selected.

set text item delimiters to space
tell application id "com.omnigroup.OmniGrafflePro"
	set oWin to front window
	tell canvas of oWin
		set lngWords to count of words of ((text of solids) as text)
		set {strCanvas, strDoc} to {name, name of oWin}
	end tell
	
	set lngSelnWords to 0
	set lngSolids to 0
	set lstSeln to selection of oWin
	if length of lstSeln > 0 then
		repeat with oGraphic in lstSeln
			try
				set lngSelnWords to lngSelnWords + (count of words of text of oGraphic)
				set lngSolids to lngSolids + 1
			end try
		end repeat
	end if
	
	set strReport to (lngWords as string) & " words in" & return & return & strCanvas ¬
		& " of " & return & return & strDoc
	if lngSelnWords > 0 then
		set strReport to ((strReport & return & return & "(Including " & lngSelnWords as string) & ¬
			" words in " & lngSolids as string) & " selected " & my pl(lngSolids, "shape") & ")."
	end if
	
	display dialog strReport buttons {"OK"} with title pTitle & " Ver " & pVersion with icon 1
end tell

on pl(lngNum, strTerm)
	lngNum
	if absolute(lngNum) is not 1 then
		strTerm & "s"
	else
		strTerm
	end if
end pl

on absolute(num)
	if num < 0 then
		-num
	else
		num
	end if
end absolute
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word Count Revisited Patrick J OmniOutliner 3 for Mac 22 2010-10-16 10:57 AM
Word Count and Statistics Patrick J OmniOutliner 3 for Mac 7 2009-04-20 10:50 PM
Word Count Patrick J OmniOutliner 3 for Mac 0 2007-10-20 09:40 AM
OmniGraffle and Word on Mac/Windows? DarylF2 OmniGraffle General 2 2007-05-25 04:47 AM
Word Count m_s OmniOutliner 3 for Mac 0 2006-10-25 03:49 AM


All times are GMT -8. The time now is 08:58 PM.


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