The OG interface’s origin
property is at the top left of a shape, so you just need to give it coordinates half a seat-size to the left of the calculated centroid, and half a seat-size above it.
#determine coords of seat
set xCentre to xtCentre + Hoff
set yCentre to ytCentre + Voff
-- Delta
set xPos to xCentre - halfSeat
set yPos to yCentre - halfSeat
I think you may be pulling in sin and cos functions from an osax library (perhaps Satimage ?) so to make the following work I tacked on a slow import of Math.sin and Math.cos from JavaScript
(from evalOSA
onwards, plus the use Framework
line at the top of the script)
and this also meant that I had to add the keyword “my” before the sin and cos calls, but this should be testable and give you a sense of the positioning edits I made.
(For FileMaker use, you may need to revert to your existing sin and cos approach, and remove the evalOSA version)
Note: I wasn’t sure at first what your variable Seat
was, so in this copy I’ve renamed it seatSize
and used it in the make new shape
expression as well.
use framework "Foundation"
property perFont : "GillSans"
property seatSize : 42
property Gap : 3
property seatSpace : seatSize + Gap
on run
set memberCount to 15
set tPerim to memberCount * (seatSpace)
set tRadius to tPerim / (2 * pi)
if tRadius < 40 then set tRadius to 60
set attList to {"GBa", "JMi", "PMi", "DMa", "SMi", "PDo", "RVi", "JMi", "PMi", "DMa", "SMi", "PDo", "RVi", "JMi", "PMi", "DMa", "SMi", "PDo", "RVi", "JMi", "PMi", "DMa", "SMi", "PDo", "RVi"}
tell application id "com.omnigroup.OmniGraffle6"
tell canvas of front window
# draw circular table
set xOrigin to 150
set yOrigin to 250
set tDiam to 2 * tRadius
set pointList to {0, xOrigin, yOrigin}
make new layer at end with properties {name:"Table"}
-- select layer id 2
make new shape with properties {name:"Circle", textSize:{0.8, 0.7}, draws shadow:false, size:{tDiam, tDiam}, origin:{xOrigin, yOrigin}, textPosition:{0.1, 0.15}}
# now draw seats
# - set coords of centre of table
--set tRadius to tRadius / 2
set xtCentre to xOrigin + tRadius
set ytCentre to yOrigin + tRadius
set halfSeat to seatSize / 2
make new layer at end with properties {name:"Seats"}
--select layer 1 ??
repeat with i from 1 to memberCount
#functions are in radians
set tAngle to (i * (360 / memberCount))
set tRadians to tAngle * (2 * pi) / 360
# set chair offsets from centre
set Hoff to (tRadius + halfSeat + Gap) * (my cos(tRadians))
set Voff to (tRadius + halfSeat + Gap) * (my sin(tRadians))
#determine coords of seat
set xCentre to xtCentre + Hoff
set yCentre to ytCentre + Voff
-- Delta
set xPos to xCentre - halfSeat
set yPos to yCentre - halfSeat
# get member initials
set perINIT to text item i of attList
# draw a line from table centre to Chair origin
make new line with properties {point list:{{xtCentre, ytCentre}, {xCentre, yCentre}}, thickness:0.25}
set shapeRef to (make new shape with properties {name:"AndGate", textSize:{1.0, 0.8}, draws shadow:false, size:{seatSize, seatSize}, text:{alignment:center, font:perFont, text:perINIT}, textRotation:90, rotation:tAngle, origin:{xPos, yPos}, thickness:0, textPosition:{0.0, 0.1}, vertical padding:0, fill color:{0.0, 1.0, 1.0, 0.304984}})
end repeat
end tell
end tell
end run
-- evalOSA :: ("JavaScript" | "AppleScript") -> String -> String
on evalOSA(strLang, strCode)
set ca to current application
set oScript to ca's OSAScript's alloc's initWithSource:strCode ¬
|language|:(ca's OSALanguage's languageForName:(strLang))
set {blnCompiled, oError} to oScript's compileAndReturnError:(reference)
if blnCompiled then
set {oDesc, oError} to oScript's executeAndReturnError:(reference)
if (oError is missing value) then return oDesc's stringValue as text
end if
return oError's NSLocalizedDescription as text
end evalOSA
on cos(x)
evalOSA("JavaScript", "Math.cos(" & (x as string) & ")") as real
end cos
on sin(x)
evalOSA("JavaScript", "Math.sin(" & (x as string) & ")") as real
end sin