Book a Demo

Author Topic: Setting bookmarks value and enabling them on diagram automatically  (Read 55494 times)

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Setting bookmarks value and enabling them on diagram automatically
« 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?
« Last Edit: September 12, 2025, 12:34:10 pm by Sunshine »
Happy to help
:)

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Setting bookmarks value and enabling them on diagram automatically
« Reply #1 on: September 12, 2025, 12:33:06 pm »
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
Code: [Select]

// ...
    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);

« Last Edit: September 12, 2025, 12:41:05 pm by Sunshine »
Happy to help
:)

Elpis

  • EA User
  • **
  • Posts: 64
  • Karma: +7/-0
  • Make MDA/MBSE vital.
    • View Profile
Re: Setting bookmarks value and enabling them on diagram automatically
« Reply #2 on: September 16, 2025, 02:23:32 am »
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. ;)

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Setting bookmarks value and enabling them on diagram automatically
« Reply #3 on: September 17, 2025, 10:26:40 am »
Thanks, I saw that when looking through the API support docs.
Happy to help
:)