CAD2008的二次开发,有个很奇怪的现象,只要你选择的点集不在当前视图上SelectCrossingPolygon和SelectFence返回结果Status就会为error,所以要获取正确的结果,在操作前最好全屏缩放一下!
小测试:
[CommandMethod("TestPromptSelectionResult")]
public void TestPromptSelectionResult()
{
Point3dCollection pt3dCol = new Point3dCollection();
pt3dCol.Add(new Point3d(, , ));
pt3dCol.Add(new Point3d(, , ));
pt3dCol.Add(new Point3d(, , ));
pt3dCol.Add(new Point3d(, , ));
pt3dCol.Add(new Point3d(, , ));
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
PromptSelectionResult psrss = doc.Editor.SelectFence(pt3dCol);
//if (psrss.Status != PromptStatus.OK)
MessageBox.Show(psrss.Status.ToString());
Polyline pl = new Polyline();
for (int i = ; i < pt3dCol.Count; i++)
{
//添加多段线的顶点
pl.AddVertexAt(i, new Point2d(pt3dCol[i].X, pt3dCol[i].Y), , , );
}
CadDatabase.AppendToModelSpace(pl, doc.Database);
}
最后你只要看到那个多段线,再打入命令TestPromptSelectionResult就会返回OK,个人认为是c#Cad二次开发的一下Bug,求大神打我脸!