Not sure if others have found a solution to these two problems in scripting the creation of a line connecting two shapes.
- source and destination can apparently not be specified in the make new line property list.
- code-created links between horizontally aligned objects are not horizontal
Code:
property pstrArrow : "FilledArrow"
property plstRed : {65535, 0, 0}
tell application id "OGfl"
tell (make new document)
tell front canvas
-- DISABLE AUTOMATIC LAYOUT
set automatic layout of its layout info to false
-- GET RELATIVE UNITS
set {rX, rY} to page size
set rSize to rX / 10
set rDown to rY / 3
set shapeA to make new shape with properties {name:"Circle", origin:{rDown, rDown}, size:{rSize, rSize}}
set shapeB to make new shape with properties {name:"Circle", origin:{rDown + (rSize * 1.3), rDown}, size:{rSize, rSize}}
-- PROBLEM 1: The following line of code fails ("AppleEvent handler failed")
-- set oLine to make new line with properties {source:shapeA, destination:shapeB, stroke color:plstRed, head type:pstrArrow}
-- (source and destination can apparently not be specified in the initial property list, before the line has been created,
-- Instead we have to create the line and THEN specify source and destination):
set oLine to make new line with properties {stroke color:plstRed, head type:pstrArrow}
tell oLine
set source to shapeA
set destination to shapeB
end tell
-- PROBLEM 2: The above creates a line which does NOT take the shortest (i.e. horizontal) path between the two shapes
end tell
end tell
end tell