Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: sravang on September 06, 2021, 04:02:46 pm

Title: Where can we find Object_Type in UI of an element?
Post by: sravang on September 06, 2021, 04:02:46 pm
Hello,

I am not able to find Object_Type of an element in UI inside properties of an element. I can see stereotype but not able to find object type. Can you suggest me where to look for it in UI

Thanks,
Sravan
Title: Re: Where can we find Object_Type in UI of an element?
Post by: Geert Bellekens on September 06, 2021, 04:10:01 pm
You can't. The actual object type has been hidden since v15.

The easiest way would be to use a query. You can do something like this:

Code: [Select]
Select o.Object_Type as myType from t_object o where o.ea_guid = '<paste the actual guid of the element>'
and execute that in the scratch pad. Make sure to use the alias, as EA will otherwise trick you and show the metatype of the element you are looking at instead.

Another method is to remove the stereotype and see what you end up with.

Geert
Title: Re: Where can we find Object_Type in UI of an element?
Post by: sravang on September 06, 2021, 04:25:35 pm
Hi Geert,

Thanks for your reply. Is there any way can I add one option on right click to display object_type through my c# addin?

Thanks,
Sravan
Title: Re: Where can we find Object_Type in UI of an element?
Post by: qwerty on September 06, 2021, 06:28:57 pm
Just issue the above SQL with repository.sqlquery and show its result.

q.
Title: Re: Where can we find Object_Type in UI of an element?
Post by: Geert Bellekens on September 06, 2021, 06:35:54 pm
Hi Geert,

Thanks for your reply. Is there any way can I add one option on right click to display object_type through my c# addin?

Thanks,
Sravan
Sure, using EA_GetMenuItems you should do that, or you could show that in your own add-in window for each selected element (a bit like my EA Navigator does)

Geert
Title: Re: Where can we find Object_Type in UI of an element?
Post by: sravang on September 06, 2021, 10:16:57 pm
Hi Geert,

I have used Repository.GetContextObject() function to get current selected element, so that I can display object_type of that selected element. But this function throws an error when we select package or diagram. Is there any way so that we can use this function without any error and also one more help can we add this click under right click option of an element instead of our addin menu options.Right now it comes under specialize->Addin menu.

Thanks,
Sravan
Title: Re: Where can we find Object_Type in UI of an element?
Post by: Geert Bellekens on September 06, 2021, 10:28:06 pm
You have to test the type of the returned object and act accordingly. I suspect the function itself doesn't throw an error, but your code tries to cast the returned object to EA.Element, even when getting a package (EA.Package) or diagram (EA.Diagram)

There is no way to add a context menu anywhere else than in the Specialize submenu.

Geert