Cannot change alignment with applescript in OG 7.8


#1

I am modifying a posted script for my own purposes, and am trying to change the text alignment of a shape. (I am not an Applescript expert )

The shape is created by the line (edited for brevity):

set nodeText to make new shape at end of graphics with properties {origin:{50,50}, size:10, ... text:{text:itemName, font:labelFont, alignment:left} }

Now when this command is executed in the debugger:
set xxx to properties of text of nodeText

the log window shows:

{size:10.0, baseline offset:missing value, alignment:left, color:{0, 0, 0}, font:"Helvetica", text:"Test Top level", underlined:false, superscript:missing value}

The command
set size of text of nodeText to 19

changes the size property as expected. However, the command
set alignment of text of nodeText to left

causes an error that OG “can’t set alignment of every text of graphic id…”

I cannot even get the alignment property. How can I modify the alignment property?


#2

I am seeing this work in OmniGraffle 7.8 with this test document:
RealignUs.graffle (5.9 KB)

Here’s a working example that swaps the text alignment from left to right (and back again). There is a bug where it doesn’t appear on canvas that the alignment has been updated, which is a redraw problem, but once you select the shape you will see the alignment update on canvas. As a workaround to the redraw problem, you can select all and then deselect, or you can save the document, close and then reopen to make sure everything refreshes. The redraw issue has been reported to the team.

-- Toggle all shapes in the front canvas between left and right aligned text
tell application "OmniGraffle"
	tell front canvas of front document
		set refRuns to a reference to attribute runs of text of shapes
		set lstAlign to alignment of refRuns
		if first item of lstAlign = {left} then
			set alignment of refRuns to right
		else
			set alignment of refRuns to left
		end if
		alignment of refRuns
	end tell
end tell

Thanks,
Lanette