Use com.nomagic.magicdraw.uml.Finder for finding elements by the name or type (meta-type) in a project. This utility class provides several internal finders for executing different types of search operations.
For example:
Project project = ...; //find a Model element under the project primary model with a name "MyModel". It is not a recursive search Model model = Finder.byName().find(project.getPrimaryModel(), Model.class, "MyModel"); //find a first Model element under project primary model with a name "MyModel". It is a recursive search. Model model = Finder.byNameRecursively().find(project.getPrimaryModel(), Model.class, "MyModel"); //find all Model elements under project primary model with a name "MyModel". It is a recursive search. Collection<Model> models = Finder.byNameAllRecursively().find(project.getPrimaryModel(), Model.class, "MyModel");
Finding or creating Classifiers
A special utility class is available for search or creating Classifiers by metatype, simple or qualified name - com.nomagic.magicdraw.uml.ClassifierFinder
Related pages