2
votes

In the Enterprise Architect it's possible to hide a connector in a specific diagram. Developing an Add-in (Extension), I need to perform such action by "code", but I cannot find the corresponding attribute of the connector/diagram class.

I'd appreciate it if anybody could help finding the relevant attribute for setting the visibility of a connector.

2
How do you perform this manually? (not programmatically)user3165438
By a "right click" on the connector, there is a menu item named "Visibility". There it is possible to hide the connector manually.Siavash

2 Answers

2
votes

The connector is not hidden universally, but in a specific diagram. Thus, the visibility is not a property of the Connector class, but of the DiagramLinks class, which holds the representation of one connector in one diagram. (Yes, the class is called DiagramLinks with an 'S'.) In DiagramLinks you'll find the property IsHidden.

So what you need to do is:

  1. Retrieve the Connector you want to hide/show, and the Diagram you want to show/hide it in.
  2. Traverse the Diagram.DiagramLinks collection, whose constituent type is the DiagramLinks class.
  3. Find the DiagramLinks instance where Connector.ConnectorID matches DiagramLinks.ConnectorID.
  4. Set DiagramLinks.IsHidden to True (or false to unhide).
  5. Call DiagramLinks.Update(). You may also need to call Diagram.Update().
2
votes

I've tried the 5 steps:

  1. Retrieve the Connector you want to hide/show, and the Diagram you want to show/hide it in.
  2. Traverse the Diagram.DiagramLinks collection, whose constituent type is the DiagramLinks class.
  3. Find the DiagramLinks instance where Connector.ConnectorID matches DiagramLinks.ConnectorID.
  4. Set DiagramLinks.IsHidden to True (or false to unhide).
  5. Call DiagramLinks.Update(). You may also need to call Diagram.Update().

but i've to add a 6th to see the effect on the current diagram: Repository.RefreshOpenDiagrams(true);