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 to quickly build a set of text objects Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Here's an AppleScript that will take a simple text object and create multiple text objects which represent all it's lines.

I use this to paste in a list of site map objects from (eg.) an email or a spreadsheet, and quickly generate separate text objects for me to then join up.

If I have a very long nested list I'll instead import into OmniOutliner, save as an outline, then open in OmniGraffle, create the outline, and copy/paste into my real document. As you can see, that path isn't worth it for a dozen lines or so.

tell application id "OGfl"
	tell front window
		set theSelection to the selection
		set theItem to item 1 of theSelection
		set theText to (text of theItem) as text
		set theSize to size of theItem
		set theHeight to item 2 of theSize
		set theOrigin to the origin of theItem
	end tell
	set theDown to (item 2 of theOrigin) + theHeight
	set theRight to item 1 of theOrigin
	set theLines to paragraphs of theText
	set numLines to length of theLines
	repeat with lineNo from 1 to numLines
		set theDown to theDown + 16
		set theOrigin to {theRight, theDown}
		set theLine to item lineNo of theLines
		tell canvas of front window
			make new shape at end of graphics with properties {draws stroke:false, fill:no fill, origin:theOrigin, vertical padding:0, autosizing:full, size:{180.0, 13.0}, text:{text:theLine, size:11}, side padding:1, draws shadow:false}
		end tell
	end repeat
end tell

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

All times are GMT -8. The time now is 02:19 AM.

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