Author Topic: Adding a legend with values to a diagram via script.  (Read 1791 times)

Ruff

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Adding a legend with values to a diagram via script.
« on: January 03, 2025, 07:18:19 am »
I was inspired by Java inserting into a legend
I have no issues adding the legend to the diagram but they entries to the legend aren't added.  Any ideas why this my not work are welcome.  (version 15.2.1554)

Here's the SQL statement in generates:(I can't post code but a paste link like this works?!?)


Link to Stack Overflow since I can't post code here.
« Last Edit: January 03, 2025, 07:50:58 am by Ruff »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13288
  • Karma: +557/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Adding a legend with values to a diagram via script.
« Reply #1 on: January 03, 2025, 08:00:50 pm »
What I've answered on SO:

Quote
You can't execute update or insert statements using Repository.SQLQuery()

You can use the undocumented and unsupported method Repository.Execute(), but you better be damn sure of what you are doing. This has the potential to seriously corrupt your model.

Geert

philchudley

  • EA User
  • **
  • Posts: 740
  • Karma: +20/-0
  • UML/EA Principal Consultant / Trainer
    • View Profile
Re: Adding a legend with values to a diagram via script.
« Reply #2 on: January 03, 2025, 11:20:25 pm »
Hi All

I have achieved this via a Model Based add-in, but as Geert says it is NOT trivial.

In addition to creating a Text element with a subtype = 76, all the legend stuff is located in t_xref with a specific ; delimited string and the RGB values must be stored in EA's own integer values this entry is then cross referenced to the Text element. This requires a new entry per legend to be created in t_xref with each having its own GUID.

Phil
follow me on Twitter

@SparxEAGuru