Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Sunshine on September 12, 2025, 10:27:58 am
-
Is there a way to set the value of a bookmark value then enable it to be visible programmatically?
Looking that the documentation on DiagramObject and can't see an attribute or method that could do that. So I'm concluding its not possible and reaching out to the forum to see if anyone else has found a way?
I can do it manually via the GUI but its tedious to do for a few hundred diagram objects across multiple diagrams.
Does anyone know where the bookmark values are stored in the Database?
-
After a bit of digging I found there is no API support for bookmarks. However, entries in the diagram’s database table t_diagram.StyleEx field using the format:
OPTIONS_<DUID>=BkmOn=1:Bkm=<value>;. So you need to do a bit of jiggery pokery (that's a technical term) with regular expressions in JavaScript to add or remove entries in t_diagram.StyleEx row using t_diagram.StyleEX.
Here is a code snippet
// ...
var diagram = Repository.GetCurrentDiagram();
if (diagram == null) {
Session.Output("No diagram is currently open.");
return;
}
var diagramObjects = diagram.DiagramObjects;
var styleEx = diagram.StyleEx;
// Create a map of DUIDs to new bookmark values
var bookmarkMap = {};
//...<Code to manipulate value for bookmarks on diagram objects>
for (var duid in bookmarkMap) {
var newEntry = "OPTIONS_" + duid + "=BkmOn=1:Bkm=" + bookmarkMap[duid] + ";";
styleEx += newEntry;
}
diagram.StyleEx = styleEx;
diagram.Update();
Repository.ReloadDiagram(diagram.DiagramID);
-
From EA docs https://sparxsystems.com/enterprise_architect_user_guide/17.1/add-ins___scripting/diagram2.html :
StyleEx [...] Advanced style settings, reserved for the use of Sparx Systems.
So be warned. It (format?) can change without notice. ;)
-
Thanks, I saw that when looking through the API support docs.