(ORD C# - 2021 Release 1) How to save TemplateLibrary after added TemplateDefinition?

Hello.

I am writing an addin program using C# ORD SDK and I am trying to add new TemplateDefinition to TemplateLibrary.

So I loaded default TemplateLibrary and add new TemplateDefinition to the TemplateLibrary loaded.

But I don't know how to save TemplateLibrary. 

Is there a way to save TemplateLibrary?

Here is my code.

        protected override void OnPostInstall()
        {
            base.OnPostInstall();

            // load default template library
            string strlibPath = TemplateLibrary.GetDefaultTemplateLibraryPath();
            var templateLibrary = TemplateLibrary.Load(strlibPath);
            
            // root cate
            var rootCate = templateLibrary.RootCategory;

            // create new TemplateDefination
            var newTemp = new TemplateDefinition("fff");

            // points
            TemplatePointConstraint cl_c1 = new TemplatePointConstraint(ConstraintType.None, 0, "");
            TemplatePointConstraint cl_c2 = new TemplatePointConstraint(ConstraintType.None, 0, "");
            TemplatePoint cl = new TemplatePoint("cl", "cl_f", "cl_s", false, 0, 0, 0, "cl_sc", "cl_scm", 2.5, cl_c1, cl_c2);
            

            TemplatePointConstraint p1_c1 = new TemplatePointConstraint(ConstraintType.Slope, 2, "cl");
            TemplatePointConstraint p1_c2 = new TemplatePointConstraint(ConstraintType.Horizontal, -10, "cl");
            TemplatePoint p1 = new TemplatePoint("p1", "p1_f", "p1_s", false, 0, 0, 0, "p1_sc", "p1_scm", 2.5, p1_c1, p1_c2);

            newTemp.AddPoint(cl);
            newTemp.AddPoint(p1);

            // component
            var comp = new TemplateComponent("paveL", "", TemplateComponentType.Normal, true, "", "");
            newTemp.AddComponent(comp);
            comp.AddVertex(new TemplateVertex(p1, 0));
            comp.AddVertex(new TemplateVertex(cl, 0));

            // add to new TemplateDefinition
            rootCate.AddTemplate(newTemp);

            // Question : how to save the templateLibrary as strlibPath?

            ExitTool();
            
        }

Thank you.

Parents
  • Currently there is not way to save the template library using TemplateLibrary class.

    You can try using .NET XmlDocument class to read, create new elements and save the XML file and use the InRoads.xsd schema file to help you validate your XML file.

    I hope it helps.

    Henrique

    Answer Verified By: BasisSoft BDN 

Reply
  • Currently there is not way to save the template library using TemplateLibrary class.

    You can try using .NET XmlDocument class to read, create new elements and save the XML file and use the InRoads.xsd schema file to help you validate your XML file.

    I hope it helps.

    Henrique

    Answer Verified By: BasisSoft BDN 

Children