//WS: click "Select" button private void btnSelect_Click(object sender, EventArgs e) { BCOM.ElementEnumerator oEnum = AddInMain.ComApp.ActiveModelReference.GetSelectedElements(); BCOM.Element[] oEleSet = oEnum.BuildArrayFromContents(); if (oEleSet.Length != 1) { AddInMain.ComApp.CadInputQueue.SendCommand("CHOOSE NONE"); AddInMain.ComApp.CommandState.StartLocate(new LocateEle()); } else //WS: check if a correct cell with tag is already selected. { if (oEleSet[0].IsCellElement()) { if (oEleSet[0].AsCellElement().Name == "Embankment" || oEleSet[0].AsCellElement().Name == "Dike" || oEleSet[0].AsCellElement().Name == "Pond" || oEleSet[0].AsCellElement().Name == "Road" || oEleSet[0].AsCellElement().Name == "OpenChannel" || oEleSet[0].AsCellElement().Name == "RetainWall") { BCOM.Element oEle = oEleSet[0]; ECInstanceList oECInstancelist = GeoTag.Tag.oECAdaptor.ReadInstancesFromElement(oEle, false); foreach (ECInstance oEC in oECInstancelist) { if (oEC.ClassDefinition.Name == "Embankment" || oEC.ClassDefinition.Name == "RetainWall" || oEC.ClassDefinition.Name == "Pond" || oEC.ClassDefinition.Name == "Road" || oEC.ClassDefinition.Name == "OpenChannel" || oEC.ClassDefinition.Name == "Dike") { Commons.PopulateGeoTagForm(GeoTag.Tag.s_current, oEC); AddInMain.ComApp.ShowPrompt("Old Tag Data Retrived."); return; //Not necessary, but good practice. } } } else { AddInMain.ComApp.CadInputQueue.SendCommand("CHOOSE NONE"); AddInMain.ComApp.CommandState.StartLocate(new LocateEle()); } } } }
public void Accept(BCOM.Element Element, ref BCOM.Point3d Point, BCOM.View View) { BCOM.Element oEle = Element; ECInstanceList oECInstancelist = Tag.oECAdaptor.ReadInstancesFromElement(oEle, false); foreach (ECInstance oEC in oECInstancelist) { if (oEC.ClassDefinition.Name == "Embankment" || oEC.ClassDefinition.Name == "RetainWall" || oEC.ClassDefinition.Name == "Pond" || oEC.ClassDefinition.Name == "Road" || oEC.ClassDefinition.Name == "OpenChannel" || oEC.ClassDefinition.Name == "Dike") { Commons.UpdateUIBasedOnFunctionCode(Tag.s_current, oEC.ClassDefinition.Name); Commons.PopulateGeoTagForm(Tag.s_current, oEC); //WS: select the element. AddInMain.ComApp.ActiveModelReference.SelectElement(oEle, true); AddInMain.ComApp.ShowCommand(""); AddInMain.ComApp.ShowPrompt("Old Tag Data Retrived."); break; } } }