I'm currently developing an Add-In with a variety of functions, one of them to align ports in a diagram horizontally.
Therefore, I need to get the current selected element/ port in a diagram ( in this case Hand(Port4)) as an "anchor" element so that the other selected ports align themselves to the same x - coordinate.
Example diagram I'm working on
In EA itself, it works wonderfully with
Select Object_ID, Name from t_object where Object_id = #CurrentElementID#
Going into my Add-In (that I'm developing in C# in Visual Studio 2022), I thought that I could do the same with a SQLQuery a la
String selectedPort = repository.SQLQuery("Select Object_ID, Name from t_object where Object_ID = #CurrentElementID# ");
Which gives me a syntax error at Object_ID = #CurrentElementID#
and I don't know why tbh. I found this link where #OBJECTID# was suggested but that didn't work either.
How do I get around this problem and get the port.top
- value so that I can align the other ports to it?
CodePudding user response:
You can not use the #-enclosed keywords except in custom SQL (from the search builder). So you have to use EADiagram.SelectedObjects
which is a collection. repository.GetCurrentDiagram
will give you the according diagram object. You need to check if the collection contains only a single element and use that. From here you can find the elementId/ObjectId and place it in your query.
Since you are using an add-in it's probably easier to use EA_OnContextItemChanged which points you to the port you right clicked to start the add-in.