querying for elements on a diagram

Systems engineering related questions and discussions.

Moderator: Moderators

querying for elements on a diagram

Postby dale.edwards@capgemini.com » Thu Jun 23, 2022 6:08 am

I've built a static view that would allow me to publish where particular model elements are used across the model enabling users unfamiliar with the model to see at a glance how other system models are being used in the overarching context and in models being developed by other teams for example in a published high level system model to see where any changes may impact the design. I've used similar functionality in other tools for many years as it really helps non tool users understand the models when they ask it specific questions

I have built a simple depe'cy matrix which would do the job but am unable to locate any relationship that duplicates the usage in diagram tool based functionality. I've located an internal function usageindiagram but it comes with a rather obscure waring and when using it as a script appears to do nothing

simple matrix example attached (with no rel so is blank)

I'm sure this can be done as its usually a standard modelling technique but am missing that final link to get the matrix to complete
any suggestions welcome

Dale
You do not have the required permissions to view the files attached to this post.
dale.edwards@capgemini.com
Forum Newbie
Forum Newbie
 
Posts: 1
Posts Rating:0
Joined: Thu Jun 23, 2022 5:19 am

Re: querying for elements on a diagram

Postby ogirdor » Fri Jun 24, 2022 9:18 am

Hi Dale,

the only way I can come up currently in order to find the diagrams where elements are used is getting a list of all diagrams and examining its PresentationElements. Unfortunately, I do not know how to use this information in a script as dependency criteria, but maybe it helps you get a step further:

(in Groovy)
Code: Select all
import com.nomagic.magicdraw.core.Application
import com.nomagic.magicdraw.core.Project
import com.nomagic.magicdraw.uml.symbols.DiagramPresentationElement

Project currentProject = Application.getInstance().getProject()
//Application.getInstance().getGUILog().log("arg1: " + arg1.getHumanName())
//get all diagrams in project
Collection<DiagramPresentationElement> allDiagrams = currentProject.getDiagrams()
//find usage in diagram
Collection<DiagramPresentationElement> allMatchingDiagrams = allDiagrams.findAll{diag ->
    diag.getPresentationElements().any{pe->pe.getElement().equals(arg1)}
}
Application.getInstance().getGUILog().log("Number of matching diagrams: "+allMatchingDiagrams.size())
return allMatchingDiagrams
ogirdor
Forum Beginner
Forum Beginner
 
Posts: 67
Posts Rating:19
Joined: Wed Jun 03, 2020 4:41 am

Re: querying for elements on a diagram

Postby ogirdor » Fri Jun 24, 2022 9:47 am

Hi again,

your mention of an internal function usageindiagram sent me looking for information on that. After looking at the PDF of a seminar on Structured Expressions (https://community.apan.org/cfs-file/__k ... icDraw.pdf) I have a nice and clean solution for the task of finding usage in diagrams.

For the dependency criteria create an operation as Operation from Model, and select the behavior UsageInDiagramsWithSymbols, which is not deprecated. Initially I had some problem setting THIS as the value for Element (see screenshot below), which I could solve by dragging and dropping from e.g. the metachain navigation.

UsageInDiagrams0.png

UsageInDiagrams.png
You do not have the required permissions to view the files attached to this post.
ogirdor
Forum Beginner
Forum Beginner
 
Posts: 67
Posts Rating:19
Joined: Wed Jun 03, 2020 4:41 am


Return to Model Based Systems Engineering (MBSE)

Who is online

Users browsing this forum: No registered users and 0 guests

cron