Global add/edit prefix or suffix for existing points in template
The below code gets the default template library and active template. Collects all the point elements and add prefix to point having name "BAR_UG2" .User can add or edit the name as required.
//Required References
using System.Xml;
public void AddPrefixOrSuffixToPointName()
{
//Prefix to add to point name
string prefix = "PREFIX_";
//Get default template library
string strTemplateLibraryPath = Bentley.CifNET.GeometryModel.SDK.TemplateLibrary.GetDefaultTemplateLibraryPath();
//Load the Template library as XMLDocument
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.Load(strTemplateLibraryPath);
//Get all "Point" node from template library
XmlNodeList pointsList = doc.GetElementsByTagName("Point");
//Read each point to add prefix or suffix, here for demo purpose first point is used
foreach (XmlNode pointNode in pointsList)
{
XmlElement pointEle = pointNode as XmlElement;
if (pointEle != null)
{
//Get point name
string pointNameAttribute = pointEle.GetAttribute("name");
//Sample point BAR_UG2 is used here to add prefix
if (pointNameAttribute == "BAR_UG2")
{
pointEle.SetAttribute("name", prefix + pointNameAttribute);
break;
}
}
}
//Save the template library document
doc.Save(strTemplateLibraryPath);
}
Output