Get Models and Presentations

You can learn how to get Models and Presentations by using Astah API. You can find a list of available Models and Presentations to get from here.

Get Models

Find models in a project

Call ProjectAccessor#findElements() to get models in a project. ProjectAccessor can get from AstahAPI#getProjectAccessor().

Sample with ModelFinder

Class Diagram Picker
Entry Point Picker

Get a model selected in the structure tree

Get a model selected on the diagram


Let’s get an association from Class0 in the sample diagram below.


This is the instance diagram. As you can see, there is no direct way to get associations from Class. So you need to get it through the AssociationEnd.


This is how Astah API works in this case.


You can get Attributes and AssociationEnds from Classes with IClass#getAttributes().
You can get Associations from Associations with IAttribute#getAssociation(). (It returns null if you call IAttribute#getAssociation() from attributes.)


Let’s get a dependency from Class0.


This is the instance diagram.


This is how API works in this case. INamedElement is a parent class of IClass.


You can get the dependency from Class0 with INamedElement#getClientDependencies().
If you want to get it from Class 1, you can do so with INamedElement#getSupplierDependencies().

Template Classes

You can get an array of templateBindings (ITemplateBinding) between the target Class and its Template Class with IClass#getTemplateBindings().
Then you can get the Template Class with ITemplateBinding#getTemplate().
If you’d like to get a Template Parameter, you can get an array of the class’s template parameter (IClassifierTemplateParameter) with IClass#getTemplateParameters().

Packages - recursively

Subsystems and Models that inherit packages (IPackage) are also included in the Package.

Classes under Packages

Get all the model elements under package (IPackage) and pick classes.

Namespace of Class

Get the name of class by calling getName() in case they are subclasses of INamedElement (i.g. IClass).
In addition, by calling getOwner() that obtains the owned model elements, the Full Path name from the project model can be obtained.

Activity Diagram Models

Sample Activity Diagram:


This is the instance diagram.
Please note that there is a Dimension as a superPartition of Partition0.


This is a structure of the API for the Activity Diagram models.


Sequence Diagram Models

Sample Sequence Diagram, its instance diagram and the structure of the API :




Statemachine Diagram Models

Sample Statemachine Diagram, its instance diagram and the structure of API.




Use IState#getSubvertexes() to get all the models inside the state0.
Use IState#getSubvertexes(int regionIndex) if you want to get models per regision.


Use ITaggedValue to get TaggedValues.


You can get Stereotypes as an array of Strings with IElement#getStereotypes().


Alias are stored as TaggedValues.
Key of Alias1 is jude.multi_language.alias1 and jude.multi_language.alias2 is for Alias2. TaggedValues or Alias from presentation

Get Diagrams and Presentations

Get Diagrams

Get all presentations in the diagram

With IDiagram#getPresentations() you can get all the presentations in the diagram.
Please note that IElement#getPresentations() behaves differently.

Get presentation from model

With IElement#getPresentations() you can get all the presentations that will be “IPresentation#getModel() == element”.
Since IDiagram#getPresentations() will get the presentation in the diagram, exception handling is done in the example below.

Get presentation of selected model on the diagram

You can get presentation of a model that is currently selected on the diagram with IDiagramViewManager#getSelectedPresentations()

Alias from presentation

You can get Alias by passing PresentationPropertyConstants#Key#ALIAS1 or PresentationPropertyConstants#Key#ALIAS2 to IPresentation#getProperty(java.lang.String)