get child packages of package

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

get child packages of package

Postby joe0532 » Fri Aug 23, 2019 2:48 pm

Hi.

It seems like it should be easier to find an answer to such a simple question.
I have a handle on a package. What method should be used to get a list of contained (child) packages? getOwnedElement() and getOwnedPackage() fail for package.
Thank you in advance.
joe0532
Forum Newbie
Forum Newbie
 
Posts: 7
Posts Rating:0
Joined: Fri Aug 23, 2019 2:31 pm

Re: get child packages of package

Postby sgarfinkel@mitre.org » Fri Aug 30, 2019 8:53 am

Do you want all nested packages recursively or just direct descendants?

I believe http://jdocs.nomagic.com/190/com/nomagic/uml2/ext/magicdraw/classes/mdkernel/Package.html#getNestedPackage-- is the method you want for directly owned packages.

For all nested packages, you can use the Finder: http://jdocs.nomagic.com/190/com/nomagic/magicdraw/uml/Finder.ByTypeRecursivelyFinder.html
sgarfinkel@mitre.org
Forum Newbie
Forum Newbie
 
Posts: 3
Posts Rating:4
Joined: Tue Aug 13, 2019 8:54 am

Re: get child packages of package

Postby prasad.bhat@yahoo.com » Wed May 24, 2023 5:37 pm

I tried Finder APIs which didn't work for me.

This was far more easier to fetch the element list. The same can be tried for packages.

var modelRoot = AutomatonMacroAPI.getModelData();

Application.getInstance().getGUILog().log(modelRoot.Member.get(1).Name);
Application.getInstance().getGUILog().log(modelRoot.Member.get(2).Name);

https://docs.nomagic.com/display/MD182/Opaque+objects
prasad.bhat@yahoo.com
Forum Newbie
Forum Newbie
 
Posts: 4
Posts Rating:0
Joined: Wed Jan 08, 2020 11:58 pm


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 3 guests