Applescript – Access elements

This is a small “how to” showing how to access elements in Merlin projects over Applescript.

If you want to access all elements of a currently opened Merlin project:

tell application "Merlin"
	set proj to root project of document 1
	set myElements to deep elements of proj
	repeat with aObj in myElements
              get aObj
        end repeat
end tell

If you want to access elements of the currently selected activity rows:

tell application "Merlin"
	set myselection to selected object of main window of document 1 as list
	repeat with aObj in myselection
               get element of aObj as list
		--to iterate in them
                repeat with anElement in element of aObj as list
                      display dialog title of aObj & ": " & title of anElement
		end repeat
	end repeat
end tell


elements of… asks for the elements attached on the object itself. While deep elements of… asks also for elements attached in sub objects as well.