c# - Enterprise Architect 9: Add Note to Connector -
I want to add notes to connectors in an Enterprise Architect Diagram program program. So far, I have been able to add notes to the elements with the following code:
foreach (EA.Element element in the package Elements) {foreach (element.Connector conn in element.Connectors) {EA Element Minute = Package. Elements Edewe ("minote", "note"); NewNote.Notes = "Some String"; NewNote.Update (); // Status calculation EA has been omitted here. DiagramObject k = diagram DiagramObjects.AddNew (status, ""); K.ElementID = newNote.ElementID; K.Sequence = 9; K.Update (); EA.Connector newConn = newNote.Connectors.AddNew ("NewLink", "Notlink"); NewConn.SupplierID = conn.SupplierID; NewConn.Update (); EA Diagram link new link = diagram. Diagram link. Add New ("New Link", "Note Lynch"); NewLink.ConnectorID = newConn.ConnectorID; NewLink.Update (); The image probably illustrates what I really want to do:
My question is: Can I connect the connector? I think that this line is called "newConn.SupplierID = conn.SupplierID;" Changed, but "newConn.SupplierID = conn.ConnectorID" causes an exception. I would be glad if someone could help me!
Best Relationship
Note links for elements from EA connectors to note links Handles in a very different way.
Connectors always run between two elements In your example, there are four elements (two types of activity named O1 and O2 and two types of notes ; These are usually unknown) and three connectors (O1 - O2, "this is what I have," - running from the edge of an image from O2, and O1). An object that looks like a connector is "what I want" O1 - O2 connector, in fact, is not a connector at all - it just looks like a GUI, a Link to the connector is unresponsive and you can not bring a property dialog for it. This is the reason that.
The fact is that the connection is connected to the connector itself in the note element, stored in the MiscData collection. What you need to do is get the string idref = & lt; Connector_id & gt ;; Add MiscData (3) to . You may have to set the note 's sub type to area 1. However, MiscData is read-only so you have to go to the database and go directly to t_object (where the elements are stored) Have to update. In the API, the MiscData corresponds to the PDATA1 and so on. Note that the indexes are different from one, so the corresponds to MiscData (0) PDATA1 , etc. You also get undocumented repository Except () repository since SQLQuery () allows only the select statement. Therefore, the following should be done:
foreach (E.A. Connector in Connector) {EA.Element newNote = Package.Elements.AddNew ("MyNote", " note"); NewNote.Subtype = 1; NewNote.Notes = "Some String"; NewNote.Update (); Repository.Execute ("Update t_object set PDATA4 = 'idref =" + conn.ConnectorID + ";" "+ where object_ID =" + newnot.edlementID "); // Status calculation EA has been omitted here. Diagram object k = diagram Diagram object .AddNew (status, ""); K.ElementIE = Minot. ElementID; KS Reason = 9; K.Epment ();} You may have to set an element subtype after this database update, I'm not sure.
Element. Subtype values are inappropriate in ADI, as is the content of Element.MiscData , hence this solution is not future proof But it is very unlikely that EA will ever change the way to control these things).
Comments
Post a Comment