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: Updating the text of a shape without affecting the formatting Thread Tools Search this Thread Display Modes

I'm currently working on an AppleScript that takes text values from an excel sheet and puts these into a omnigraffle document. I'm running into a problem when setting the text to a new value. The formating of the original text is lost.

set text of current_graphic to "a new value"
defaults the formating to 13pt Helvetica.

How do i update the value of a text without losing its formatting?

-- Update --
After some emailing with support and trial and error i've managed to find a solution. I'm putting it up here in case anyone else is stuck with this issue:

tell application "OmniGraffle Professional 5"
   set foo to first item of graphics of canvas of first document
   copy properties of text of foo to myRecord
   set class of myRecord to record
   set myRecord to {text:"and yet another"} & myRecord
   set text of foo to myRecord
end tell
While this will actually work it's a bit of an unwieldy aproach:

When copying the properties of the text to a new record it is copied as a 'text' class (3). When setting the properties of a text a 'record' class is expected(6) so the class of the new record needs to be changed to record(4).
To update the text property of the record you need to concatenate the existing record with a record containing the new text(5).

This way you can update the copy with a new value.

Last edited by jschel; 2008-08-26 at 03:21 AM..

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
formatting of text disappears [A: OPML spec doesn't include text formatting.] jojoba OmniOutliner 3 for Mac 4 2013-03-20 10:11 AM
Formatting text from AppleScript ptorngaard OmniFocus Extras 0 2010-03-12 02:27 AM
Formatting Text KeithFK OmniGraffle General 0 2008-08-04 10:05 AM
Strip formatting from pasted text? Roger Barre OmniOutliner 3 for Mac 1 2007-04-02 02:24 PM

All times are GMT -8. The time now is 05:50 PM.

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