diff --git a/src/main/java/gov/nasa/jpl/mbee/mdk/util/Utils.java b/src/main/java/gov/nasa/jpl/mbee/mdk/util/Utils.java index 6302e7319..a61936fd7 100644 --- a/src/main/java/gov/nasa/jpl/mbee/mdk/util/Utils.java +++ b/src/main/java/gov/nasa/jpl/mbee/mdk/util/Utils.java @@ -111,7 +111,12 @@ public static List removeDuplicates(Collection elements) { * @return */ public static Collection getElementsOnDiagram(Diagram diagram) { - return Project.getProject(diagram).getDiagram(diagram).getUsedModelElements(true); + DiagramPresentationElement diagramPresentationElement = Project.getProject(diagram).getDiagram(diagram); + if (diagramPresentationElement == null) { + return Collections.emptyList(); + } + diagramPresentationElement.ensureLoaded(); + return diagramPresentationElement.getUsedModelElements(); } /**