Book a Demo

Author Topic: Making notes in Diagram visible from API  (Read 4075 times)

MMiletic

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Making notes in Diagram visible from API
« on: March 01, 2023, 01:14:33 am »
Hey guys,

does anybody maybe knows if there is way to make notes visible for diagram from API, I've been looking at object "diagram", but couldn't find anything, it seems it's not available atm?

Thank you in advance for your answers,
BR, M

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Making notes in Diagram visible from API
« Reply #1 on: March 01, 2023, 02:03:43 am »
You'll have to be more specific about what you mean by "making notes in diagram visible".

I can think of at least three different interpretations, and I'm pretty sure all three would be wrong. ;D

Geert

MMiletic

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Making notes in Diagram visible from API
« Reply #2 on: March 01, 2023, 02:37:15 am »
Hi Geert,
thank you for answer.

Oh sorry  :D
I mean the notes checkbox in Diagram -> Properties -> Elements -> Show Compartments -> NOTES
You check it and then for instance requirements diagram shows notes from requirements.
Do you understand explanation?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Making notes in Diagram visible from API
« Reply #3 on: March 01, 2023, 03:57:59 am »
Yes, that is clear. I don't know that one by heart, but seems like that should be a property of the Diagram object, possibly stored in a field such as StyleEx or similar.

The way I figure things like that out is usually by looking in the database (t_diagram) and comparing records for a diagram that has this setting vs one that doesn't.
From there it's usually pretty straight-forward which field in the API you have to use.

Geert




qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Making notes in Diagram visible from API
« Reply #4 on: March 01, 2023, 09:38:41 am »
Actually it's stored in t_diagramobjects.objectstyle where you have to add some string like "Notes=1000;" to show a note with max. length of 1000 chars. I usually use Repository.Execute("<sq>l") for such things. But EA has an API: EaElement.SetStyle(1, <item>, <value>) works globally on all diagrams. So "Notes" and "1000" for <item> and <value> should do the magic. To do it for individual diagrams you need to locate tha diagram element and do the string operation on EaDiagramObject.Style.

q.

MMiletic

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Making notes in Diagram visible from API
« Reply #5 on: March 01, 2023, 06:40:19 pm »
Hey guys, thank you for help,
this code (Python) worked for that, for maybe any future questions :)
Code: [Select]
diagram = package.Diagrams.AddNew( packageName + " Diagram", "SysML1.4::Requirement")
        diagram_styleEx = str(diagram.StyleEx)
        if "ShowNotes=1" in diagram_styleEx:
            diagram_newStyleEx = diagram_styleEx.replace("ShowNotes=0", "ShowNotes=1")
            diagram.StyleEx = diagram_newStyleEx
        else:
            diagram_styleEx += "ShowNotes=1"
            diagram.StyleEx = diagram_styleEx
        diagram.Update()
        eaRepository.RefreshModelView(package.PackageID)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Making notes in Diagram visible from API
« Reply #6 on: March 01, 2023, 06:46:41 pm »
I think you should be checking for ";" as well.
By simply adding "ShowNotes=1" you might introduce errors.

Possibly it's enough to simply add "ShowNotes=1;", but I'm not sure if you can count on the fact that the style will always end with ";"

Geert

MMiletic

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Making notes in Diagram visible from API
« Reply #7 on: March 01, 2023, 07:02:33 pm »
If you are thinking of part that append to string, makes sense, changed that but since it worked without it I guess EA automatically adds the missing ";" which is cool

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Making notes in Diagram visible from API
« Reply #8 on: March 01, 2023, 07:09:49 pm »
I guess EA automatically adds the missing ";" which is cool
I don't think so. I think EA doesn't really care if the style string ends with ";" when rendering.
What it might do is assume it ends with ";", because EA's code always does so when editing that field.
So the problem might only appear when EA (or other code similar to this) adds another property to the style field.

But anyhow, you fixed it now, so it won't be a problem.

Geert