Hi!
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.
ex:
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:
AppleScript:
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.
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.
ex:
Code:
set text of current_graphic to "a new value"
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:
AppleScript:
Code:
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
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..