老师好,我现在需要把已存在廊道的模板复制应用到新创建的廊道里,类似ORD中 “廊道 -- 复制三维路面”功能,请问有什么接口可以实现吗?
下面是我现在的实现代码,但是生成廊道的时候报错实现不了
TemplateDefinition oldCorridorTmplate = null;
foreach (Bentley.CifNET.GeometryModel.SDK.Corridor corridor in con.GetActiveGeometricModel().Corridors) // 查找目标廊道名称 { if (alignmentOld.Name.Contains(corridor.Name)) { IEnumerable<TemplateDrop> tempDrops = corridor.TemplateDrops; TemplateDrop tempDrop = tempDrops.First<TemplateDrop>(); //获取廊道中使用工具而非代码添加的正常templateDrop //直接获取templateDrop的xml1 string xml1 = tempDrop.Template.XMLFragment; // 取目标廊道的模板 break; } }
......
con.StartTransientMode();
templateDrop = ApplyTemplateTool.ApplyTemple(newCorridor, startDis, endDis, oldCorridorTmplate); // 新模板应用老模板的模板
.......
con.PersistTransients(); // 写入报错
目前并没有拷贝模板的功能,以下代码示例如何在廊道对象上增加一个模板应用对象:
void CreateTemplateDrop(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; }
老师,那请问怎么取当前廊道的廊道模型呢?我上述代码
IEnumerable<TemplateDrop> tempDrops = corridor.TemplateDrops; TemplateDrop tempDrop = tempDrops.First<TemplateDrop>(); //获取廊道中使用工具而非代码添加的正常templateDrop //直接获取templateDrop的xml1 string xml1 = tempDrop.Template.XMLFragment; // 取目标廊道的模板
这样是对的吗?
ConsensusConnectionEdit con = ConsensusConnectionEdit.GetActive(); con.StartTransientMode(); GeometricModel gm = con.GetActiveGeometricModel(); if ( gm == null ) return; // 根据需要出表的Alignment foreach ( Corridor cor in gm.Corridors ) { Alignment al = cor.CorridorAlignment; //获取廊道对应路线 Corridor corridorEdit = cor as Corridor; if ( cor.TemplateDrops != null) { //进行处理 } }
Answer Verified By: 卫 成
明白了,谢谢老师