1

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?

2

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .