【ORD C#】读取路基横断面模板

请问老师,如何通过C#读取路基、隧道的横断面模板并沿着廊道进行放置,有没有代码示例,谢谢!

Parents
  • 请参考:

    static void testTemplateDropEdit()
            {
                long myid = 1546;
                ElementId elId = new ElementId(ref myid);
                Bentley.DgnPlatformNET.Elements.Element el1 = Session.Instance.GetActiveDgnModel().FindElementById(elId);
    
                TemplateDropEdit templateDrop = null;
                if (el1 == null)
                    return;
    
                Bentley.CifNET.SDK.Edit.ConsensusConnectionEdit con = Bentley.CifNET.SDK.Edit.ConsensusConnectionEdit.GetActive();
                Bentley.CifNET.GeometryModel.SDK.Alignment alignment = Bentley.CifNET.GeometryModel.SDK.Alignment.CreateFromElement(con, el1);
                if (alignment == null && alignment.ActiveProfile == null)
                    return;
    
                con.StartTransientMode();
                //创建廊道
                Bentley.CifNET.GeometryModel.SDK.Edit.CorridorEdit newCorridor = Bentley.CifNET.GeometryModel.SDK.Edit.CorridorEdit.CreateByAlignment(con, alignment.Name + "_Corridor", alignment);
    
    
                //创建templateDrop
                string strXmlXPath = @"路基\10米道路";
                TemplateDefinition templateDefinition = GetTemplate(strXmlXPath);
                templateDrop = ApplyTemple(newCorridor, newCorridor.StartDistance, newCorridor.EndDistance, templateDefinition);
                if (templateDrop == null)
                {
                    return;
                }
    
                System.Collections.Generic.List<double> station = new List<double>();
                station.Add(50);
                station.Add(100);
                IList<TemplateDropEdit> newTemplateDrops = templateDrop.Split(station);
    
                foreach (var tmpDrop in newTemplateDrops)
                {
                    TemplateDropEdit tmpDropEdit = tmpDrop as TemplateDropEdit;
                    tmpDropEdit.Description = "123";
    
                }
    
                con.PersistTransients();
    
            }
    
            static TemplateDropEdit ApplyTemple(CorridorEdit corridor,
                            double startStation,
                            double endStation,
                            TemplateDefinition tempDef)
            {
    
                TemplateDropParameters tempDropParams = new TemplateDropParameters(tempDef, startStation, endStation);
                tempDropParams.Interval = 5.0;
                tempDropParams.Desription = "Test Add TemplateDrop";
                TemplateDropEdit templateDrop = corridor.AddTemplateDrop(tempDropParams);
    
                return templateDrop;
            }
    
    
            static TemplateDefinition GetTemplate(string strXmlXPath)
            {
                try
                {
                    string strLib = TemplateLibrary.GetDefaultTemplateLibraryPath();
    
                    TemplateLibrary templateLibrary = TemplateLibrary.Load(strLib);
                    //从模板库的根目录开始遍历。
                    //GetCategoryAllTemplate(templateLibrary.RootCategory);
    
                    TemplateDefinition tempDef2 = templateLibrary.FindTemplateByPath(strXmlXPath);
                    return tempDef2;
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                    return null;
                }
            }

    Answer Verified By: sunday 

Reply Children
No Data