Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

If I create an OmniGraffle document, add a text box with “Test” in red in size 28, I can change the text with this snippet of AppleScript:

tell application "OmniGraffle Professional 4"
    set text of first solid of first canvas of first document to "Hello"
end tell

But this will also change the color, font size and other styling attributes to some defaults. I have an old AppleScript script which did something like the one below to change the text without changing the styling attributes by setting the “text” property of the “text” of the “solid”. The AppleScript dictionary of OmniGraffle Pro says that the “text” property of a “text” is the “The actual text content.”

tell application "OmniGraffle Professional 4"
    set text of text of first solid of first canvas of first document to "Hello"
end tell

I am sure this used to work, but I've gone through a few OS X upgrades and OmniGraffle updates since last running that script, and when I try it now, I get an error. (I am still using OmniGraffle Pro 4 though, not the new OmniGraffle Pro 5)

Is there some other way to change just the text without changing the styling attributes or a workaround for the above error (which I suspect to be a bug)? Does it work in OmniGraffle Pro 5?

share|improve this question
    
Did you ask the question on forums.omnigroup.com yet? –  patrix Aug 1 '12 at 8:09
    
I totally forgot they have their own forum. Thanks for the tip. –  Rinzwind Aug 6 '12 at 8:31

1 Answer 1

up vote 2 down vote accepted

To not change the color, font size and other styling attributes : You must use classes in Text Suite or in Extended Text Suite.

Like this :

tell application "OmniGraffle Professional 4"
   set someGraph to solid 1 of canvas 1 of document 1

  --set word 1 of text of someGraph to "Hello"
  --set characters 1 thru 4 of text of someGraph to "Hello"
  --set attribute run 1 of text of someGraph to "Hello"
  set paragraph 1 of text of someGraph to "Hello World"
end tell
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.