Author Topic: How to Add DiagramObject to Custom View in EA Add-In  (Read 1183 times)

niko_ea

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
How to Add DiagramObject to Custom View in EA Add-In
« on: June 13, 2024, 06:56:38 pm »
Dear all,

I am currently developing an Add-In for EA. I read here that it is possible to implement a custom view in an Add-In.

In my Add-In, I would like to offer an option that displays all elements with a certain tagged value set to 'true' in a custom view. Currently, I have this feature as a Diagram Filter, but I would like to automate it with a script.

However, I cannot figure out how to add a DiagramObject to my UserControl. The reason for this is that I have many diagrams in my project, and rather than adding the same DiagramFilter to every diagram manually, I want to automate the process.

I would greatly appreciate any help or guidance you can provide.

Thank you very much!

Best regards,
Niko

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13136
  • Karma: +547/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to Add DiagramObject to Custom View in EA Add-In
« Reply #1 on: June 13, 2024, 10:13:14 pm »
What do you mean by adding a diagramObject to your usercontrol?
What exactly do you need to happen?

Geert

niko_ea

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: How to Add DiagramObject to Custom View in EA Add-In
« Reply #2 on: June 13, 2024, 11:49:25 pm »
Basically, what I need is to go through the DiagramObjects, and if the tagged value is set to true, I want to add the object to my custom tab. This way, the user can see the original view of the diagram and an alternative view in a separate tab.

As far as I understand, for the custom view, I need to write my own class that extends UserControl. This class can be added through the Repository.AddTab() function. Therefore, I believe I need to add the DiagramObject somehow to the UserControl so it can be displayed in the custom tab.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8038
  • Karma: +118/-20
    • View Profile
Re: How to Add DiagramObject to Custom View in EA Add-In
« Reply #3 on: June 14, 2024, 12:07:46 pm »
It sounds like what you're expecting is to have a functioning EA diagram in your custom view.

The closest I think you could get is to make a temporary diagram that your add-in uses, add the objects to that, save the image and then show that image in your control.

https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/the_addnew_function.html

https://sparxsystems.com/enterprise_architect_user_guide/16.1/add-ins___scripting/project_2.html

niko_ea

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: How to Add DiagramObject to Custom View in EA Add-In
« Reply #4 on: June 14, 2024, 05:59:38 pm »
Thank you very much for the answer. This should solve my problem. I will try out this approach.

ea0522

  • EA User
  • **
  • Posts: 113
  • Karma: +3/-0
    • View Profile
Re: How to Add DiagramObject to Custom View in EA Add-In
« Reply #5 on: June 17, 2024, 04:31:27 pm »
Quote
Currently, I have this feature as a Diagram Filter, but I would like to automate it with a script.

Would it be an option to have your script add the Diagram Filter to the diagrams you selected for processing?

niko_ea

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: How to Add DiagramObject to Custom View in EA Add-In
« Reply #6 on: June 20, 2024, 05:37:08 pm »
Yes, this would also be an option. I looked into it but couldn't find an API call to add a Diagram Filter to the Diagram automatically. Do you know how to do that?