Hi,
I try to create (or find existing) Element Templates and attach them to elements. I can make most of the functionality work, but i can not figure out how to customize a newly created Element Template.It is simple and straightforward to insert a new Template, but customizing layer name, color, linestyle, cell name etc. is not so straightforward.
Below is a part of my code that handles the Element Templates, and I hope someone can help me fill in the blanks.
// Bentley namespaces using BDPN = Bentley.DgnPlatformNET; using BM = Bentley.MstnPlatformNET; using ECS = Bentley.ECObjects.Schema; using ECI = Bentley.ECObjects.Instance; BDPN.XDataTree.XDataTreeNode ElTemplate = BM.XDataTree.ElementTemplateMgr.FindTemplateByPath("Digitizer\\Ejerlejlighed"); if (ElTemplate is null) { BDPN.XDataTree.XDataTreeNode DigNode = BM.XDataTree.ElementTemplateMgr.FindTemplateByPath("Digitizer"); if (DigNode is null) { DigNode = BM.XDataTree.ElementTemplateMgr.InsertNewTemplateNode("Digitizer", true, 0, 0, true, BDPN.XDataTree.ECIXDataTreeOwner.CreateFromDgnFile(DgnFile)); } ElTemplate = BM.XDataTree.ElementTemplateMgr.InsertNewTemplateNode("Ejerlejlighed", true, DigNode.ElementId, DigNode.ChildNodes.Count, false, BDPN.XDataTree.ECIXDataTreeOwner.CreateFromDgnFile(DgnFile)); ECI.IECInstance Ustn_ElementParams = ElTemplate.GetECInstanceByClassName("Ustn_ElementParams"); foreach (ECS.IECProperty prop in Ustn_ElementParams.ClassDefinition.Properties(true)) { ECI.IECPropertyValue val = Ustn_ElementParams.FindPropertyValue(prop.Name, true, false, false); // Here I would like to set Levelname, Color, Line Weight an Style, Cellname, etc. } } // Set Element Template active BM.XDataTree.ElementTemplateMgr.ActivateElementTemplate(ElTemplate, false, false); // Apply Element Template to elements Boolean test = BM.XDataTree.ElementTemplateMgr.ApplyTemplateDefaultsToElement(ref ele, ElTemplate, true);
Regards, Peter