Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: ami on February 06, 2011, 05:56:59 pm
-
Hi,
I'm trying to remove element from diagram.
lets say that I have a path diagram (like a linked list) inside an array,
and I want to remove one element in place "index".
this code from some reason wont do the job:
for (short i = 0; i < List[index - 1].Connectors.Count; i++)// connecting to the next in list
{
if (((Connector)List[index - 1].Connectors.GetAt(i)).SupplierID == List[index].ElementID)// if the connector is pointing to element to remove
{
((Connector)List[index - 1].Connectors.GetAt(i)).SupplierID = List[index + 1].ElementID;// skip and connect to next one
((Connector)List[index - 1].Connectors.GetAt(i)).Update();
List[index - 1].Connectors.Refresh();
break;
}
}
for (short i = 0; i < List[index].Connectors.Count; i++)// removing connector pointing out FROM selected activity
{
if (((Connector)List[index].Connectors.GetAt(i)).ClientID == List[index].ElementID)
{
List[index].Connectors.DeleteAt(i, true);// delete the connector pointing out from selected element
break;
}
}
the idea is to skip the selected element and to connect the previous to the next.
why it's not working?