OmniGraffle Word Count
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 [/CODE] |
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).
[IMG]http://farm5.static.flickr.com/4105/5051070436_1b6daec000_o.png[/IMG] 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 [/CODE] |
Thankyou !
|
All times are GMT -8. The time now is 05:28 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.