有群友遇到下面问题:
想不出问题出在哪里,
于是自己写了测试代码,
使用样例文件中的Corridor-3b.dwg进行测试,
(Civil 3d 2018简体中文版)
(C:Program FilesAutodeskAutoCAD 2018C3DHelpCivil TutorialsDrawings)
并没有发现问题。
有兴趣的朋友可以测试一下:
[CommandMethod("MyGroup", "Tt103", CommandFlags.Modal)]
public void TestCommand3() // This method can have any name
{
Document doc = Application.DocumentManager.CurrentDocument;
Editor ed = doc.Editor;
CivilDocument cDoc = CivilApplication.ActiveDocument;
PromptEntityOptions peo = new PromptEntityOptions(" 拾取道路");
peo.SetRejectMessage(" 选择道路");
peo.AddAllowedClass(typeof(Corridor), true);
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status == PromptStatus.OK)
{
try
{
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
Corridor cor = per.ObjectId.GetObject(OpenMode.ForWrite) as Corridor;
CorridorSurface cs = cor.CorridorSurfaces.Add("Test");
cs.AddLinkCode("顶部", false);
tr.Commit();
}
}
catch (System.Exception ex)
{
ed.WriteMessage(ex.Message);
}
}
测试结果
}