API to access message number of a sequence diagram message

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

API to access message number of a sequence diagram message

Postby sean.conway.mbse@gmail.com » Tue Jan 22, 2019 12:55 pm

In the code below, I am trying to loop through Sequence Diagram Elements specifically messages by matching the diagram name to a spreadsheet input and then matching the message number to a spreadsheet input. I cannot figure out the API to get the message number though. Without this number I can't make a trace to the requirement from the spreadsheet accurately.

What is the API to get a Message number?

//Go Find the UC Step by iterating through diagams
Iterator<DiagramPresentationElement> diagramIterator = allDiagrams.iterator();
while (diagramIterator.hasNext()) {
DiagramPresentationElement currentDiagram = diagramIterator.next();
String diagramName = currentDiagram.getName();
diagramName = diagramName.replaceAll(" ", "_");
diagramName = diagramName.replaceAll("\\.", "_");
if(diagramName.contains(useCase)) {
Application.getInstance().getGUILog().log("UseCase Located: "+useCase+ " : "+ diagramName);
Collection<Element> modelElements = currentDiagram.getUsedModelElements(false);
Application.getInstance().getGUILog().log("OwnedElements: "+ modelElements.size());
Iterator<Element> elementIterator= modelElements.iterator();
Element currElement = (Element) elementIterator.next();
if(currElement instanceof Message) {
Application.getInstance().getGUILog().log("Message Located: "+ ModelHelper.getName(currElement));
Message theMessage = (Message) currElement;
//TODO Need to find the Message Number (for example 1, 2, 3, ... to compare to the input .csv)
Forum Newbie
Forum Newbie
Posts: 4
Posts Rating:0
Joined: Mon Nov 26, 2018 1:18 pm

Re: API to access message number of a sequence diagram message

Postby gdhardy1 » Tue Jan 22, 2019 1:47 pm

Forum Newbie
Forum Newbie
Posts: 8
Posts Rating:2
Joined: Thu Oct 18, 2018 11:24 am

Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 0 guests