The
Edit > Select > Ancestors menu option is a built-in way of doing something like this, but if you need to do it through Applescript for any reason (to select only ancestral links, or only ancestral nodes, rather than both, for example) a simple sketch might look something like this, which extends the selection up through the ancestral path.
Editing the value of the properties
pblnNodes and
pblnLinks at the start of the script (setting each to
true or
false) will enable you to determine whether it is the ancestral nodes which are highlighted, or the ancestral links, or both.
Code:
-- ver 0.03
property pblnNodes : true
property pblnLinks : false
tell application id "OGfl"
if (count of documents) < 1 then return
tell front window
set lstPaths to {}
repeat with oShape in (selection as list)
if (class of oShape) is shape then
set lstPaths to lstPaths & my GetPath(oShape, pblnNodes, pblnLinks)
end if
end repeat
set selection to lstPaths
end tell
end tell
on GetPath(oShape, blnNodes, blnLinks)
tell application id "OGfl"
set lstIncoming to incoming lines of oShape
if lstIncoming ≠ {} then
set oLink to first item of lstIncoming
set lstPath to my GetPath(source of oLink, blnNodes, blnLinks)
if blnLinks then set lstPath to lstPath & {oLink}
if blnNodes then set lstPath to lstPath & {oShape}
else
if blnNodes then
set lstPath to {oShape}
else
set lstPath to {}
end if
end if
return lstPath
end tell
end GetPath
--