Civil 3d 修改纵断面图标注栏中纵断面1及纵断面2
语言描述不清,
看截图:
话不多数,
直接上代码:
public void C_Test20231217() { Document doc = Application.DocumentManager.MdiActiveDocument; Editor ed; ed = doc.Editor; PromptEntityOptions peo = new PromptEntityOptions("\n拾取纵断面图"); PromptEntityResult per = ed.GetEntity(peo); if (per.Status != PromptStatus.OK) return; using (Transaction tr = doc.TransactionManager.StartTransaction()) { var pv = per.ObjectId.GetObject(OpenMode.ForWrite) as ProfileView; if (pv != null) { int i = 1; foreach (var po in pv.GraphOverrides) { ed.WriteMessage("\n{0}\t{1}", i, po.ProfileName); i++; } var bbis = pv.Bands.GetBottomBandItems(); i = 1; foreach (var pvbi in bbis ) { ed.WriteMessage("\n{0}\t{1}", i, pvbi.BandType.ToString()); i++; } var pir = ed.GetInteger("\n输入标注栏项序号"); if (pir.Status != PromptStatus.OK) { tr.Abort(); return; } var pir1 = ed.GetInteger("\n输入纵断面1的序号"); if (pir1.Status != PromptStatus.OK) { tr.Abort(); return; } var pir2 = ed.GetInteger("\n输入纵断面2的序号"); if (pir2.Status != PromptStatus.OK) { tr.Abort(); return; } bbis[pir.Value - 1].Profile1Id = pv.GraphOverrides[pir1.Value - 1].ProfileId; bbis[pir.Value - 1].Profile2Id = pv.GraphOverrides[pir2.Value - 1].ProfileId; pv.Bands.SetBottomBandItems(bbis); } tr.Commit(); } }
以上代码在运行中列出纵断面图中的纵断面及标注栏中各项,
之后用户需要输入对应序号,
之后即可根据输入内容进行修改。
代码没有进行异常处理,
输入的序号超出列表范围,
应该会出问题。
修改前:
修改过程中命令行的显示:
修改后: