Thanks Geert - I didn't spot the 'Selection' parameter in the API call.
When I tried this (in V16 beta 1) the package returned from 'GetTreeSelectedPackage' is the same one which I can't seem to change, so, unless I keep a record of 'last package used', I'm no further ahead.
Is this, I wonder, connected with the issue of not being able to set the detault diagram (in v16) without having security switched-on? My model - created in V15 and now opened in V16 - had a default diagram set, which I now can't un-set using v16, without implementing security, which, as this is my main test repository, I don't want to do. It's he parent package of this diagram which always pops-up.
In the production world, where eaDocX is embedded inside EA, this won't be a problem: it will find the package which the user has currently got selected, and use that as a starting point for the selection.
But when I'm opening the repository from the API, and testing stuff outside of the EA user interface, I think I'm stuck.
The question is, despite your excellent reply, still valid - where does EA save the 'My Diagram' and 'My Package' values ? And why do I now need (in v16) security enabled to set 'My Diagram' or 'My Package' ? For 20 years I didn't need to do this :-(