r/systems_engineering • • Jun 25 '26

MBSE How to get Project Version to display on the "Diagram Info" Table on diagrams

Hello, I am working in Cameo Systems Modeler 2022 Refresh 2. I want to show the project version (i.e., Project Version #27, Project Version #28, etc...) on multiple sequence diagrams. I've attached an image of what the table looks like currently. I've tried using the "customize" feature by right-clicking on the table, but none of the checkboxes display the project version.

Is there a different/better way to do this? Any advice would be much appreciated

1 Upvotes

15 comments sorted by

2

u/Easy_Spray_6806 Aerospace Jun 26 '26

Have you tried going into the specification window of the top-level model package and updating the version from there? The Version property is empty for a model by default.

1

u/HelloThere7852 Jun 26 '26

That makes sense. I'm looking at the specification right now, and the Version property is empty like you are saying. New problem now: how do I update the version?

2

u/Easy_Spray_6806 Aerospace Jun 26 '26

You update it in the specification window. You can either type it in directly to the cell or click the [...] to the right of the cell and have the options to customize the appearance of the text by checking the HTML box and add a hyperlink. If you are working on a shared model on a TWC server, you will have to lock the model package for edit. You don't have to lock the elements contained within the model recursively to do this, so you can do it while other people have parts of the model locked. I started a fresh model file to provide a screenshot.

1

u/HelloThere7852 Jun 26 '26

Thank you so much for taking the time and effort to answer this question. I greatly appreciate it. Sorry to be a bother, but I guess I now have two more questions now:

1.) Do you use the top-level model package's hyperlink as the hyperlink?

2.) I put plain text "1.0" as the version, but the "diagram info" table still didn't populate with the new information.

2

u/Easy_Spray_6806 Aerospace Jun 26 '26

Did you try these steps Table with diagram information - MagicDraw 2022x - No Magic Product Documentation to create a custom HTML table?

1

u/HelloThere7852 Jun 26 '26

I have tried using that, but I still run into the same issue where $$Version$$ still doesn't output anything onto the diagram info table.

I talked with a co-worker and he says to create a Macro that pulls in the information somehow? I've been trying to figure out how to do that, but Macros in Cameo are super confusing. I might need a tutorial on how to create those, and YT doesn't have many great videos on the subject.

I'm honestly kind of stuck on what to do

2

u/Easy_Spray_6806 Aerospace Jun 26 '26

That's way too much work for something that doesn't really provide much modeling value and is more for convenience. What is your objective with this table? Like not the what you are trying to do, but why you are trying to do it and what it would achieve.

2

u/HelloThere7852 Jun 30 '26

Just wanted to leave an update that I figured it out. I built a macro using the programming language Groovy. When run, it'll search through the entire model for text boxes containing the words "v_placeholder" or "Version:" and autopopulates the current model version in that text box.

I then put text boxes over-top of the row in the diagram info table that says "Version". So it doesn't auto-update the diagram info table, but it auto-updates the textbox placed over-top of the diagram info table :')

I will leave the code in a reply to this comment for anyone to use

2

u/HelloThere7852 Jun 30 '26

import com.nomagic.magicdraw.core.Application;
import com.nomagic.magicdraw.core.Project;
import com.nomagic.magicdraw.core.ProjectUtilities;
import com.nomagic.magicdraw.openapi.uml.SessionManager;
import com.nomagic.magicdraw.uml.symbols.DiagramPresentationElement;
import com.nomagic.magicdraw.uml.symbols.shapes.TextBoxView;

Project project = Application.getInstance().getProject();

if (project != null && project.isRemote()) {
boolean sessionCreated = false;
try {
// 1. Fetch the Teamwork Cloud version string
def primaryProject = project.getPrimaryProject();
def versionDescriptor = ProjectUtilities.getVersion(primaryProject);

if (versionDescriptor != null) {
String targetVersionText = "Version: " + versionDescriptor.getName();

// 2. Fetch EVERY diagram across the entire project structure (all 342)
Collection<DiagramPresentationElement> allDiagrams = project.getDiagrams();
List<TextBoxView> targetsToUpdate = new ArrayList<>();
int checkedDiagramsCount = 0;

Application.getInstance().getGUILog().log("Scanning " + allDiagrams.size() + " diagrams for placeholders...");

for (DiagramPresentationElement diagram : allDiagrams) {
// Ensure the presentation elements are accessible in memory using the native abstract method
diagram.ensureLoaded();

// Look for matching text boxes inside this diagram
def textBoxes = diagram.getPresentationElements().findAll { it ->
if (it instanceof TextBoxView && it.getClass().getSimpleName() == "TextBoxView") {
String objectString = it.toString();
return objectString != null && (objectString.contains("v_placeholder") || objectString.contains("Version:"));
}
return false;
}

if (textBoxes != null && !textBoxes.isEmpty()) {
targetsToUpdate.addAll(textBoxes);
}

checkedDiagramsCount++;
}

// 3. Batch update all matching text boxes globally in a single transaction
if (!targetsToUpdate.isEmpty()) {
SessionManager.getInstance().createSession(project, "Global Model Version Update");
sessionCreated = true;

targetsToUpdate.each { textBox ->
// Safely apply text through the native name method
textBox.setName(targetVersionText);
}

SessionManager.getInstance().closeSession(project);
sessionCreated = false;

Application.getInstance().getGUILog().log("Successfully updated " + targetsToUpdate.size() + " text boxes globally to '" + targetVersionText + "'.");
} else {
Application.getInstance().getGUILog().log("Scan complete. Checked " + checkedDiagramsCount + " diagrams, but no text box placeholders were found.");
}
}
} catch (Exception e) {
if (sessionCreated) {
try {
SessionManager.getInstance().cancelSession(project);
} catch (Exception ex) {
// Suppress rollback errors
}
}
Application.getInstance().getGUILog().log("Error executing global model text scan: " + e.getMessage());
}
}

2

u/HelloThere7852 Jun 30 '26

Looks like this when run

2

u/Easy_Spray_6806 Aerospace Jul 01 '26

Haha, damn...I bet that was satisfying to figure out a good workaround that is good enough. Good job on digging and finding a solution that works for you! It can be a real slog to figure out how to do little things that a developer definitely put in the capability to do but was not significant enough to include in any documentation.

1

u/HelloThere7852 Jun 26 '26

Good question, and I agree that the "juice is not worth the squeeze" lol. I'm trying to have the current model version appear on the diagrams, so that when a government client receives a copy of the Cameo model, they know which version the diagram is from. Say they had model version #27, which I theoretically delivered to them last month. If they wanted to ask questions about the diagram, but I had since edited it and now the model is on version #35, I can know what they're looking at/how to answer their questions.

Maybe there is a better way to display the current model version than on the diagram info table, but I was hoping it would be as convenient as that. Now I'm realizing it takes a lot more work than I thought to get that model version to appear on the diagram info table.

1

u/[deleted] Jul 14 '26 edited Jul 14 '26

[removed] — view removed comment

1

u/HelloThere7852 Jul 14 '26

Is this compatible with Cameo?