其他分享
首页 > 其他分享> > CAD二次开发获取当前视角范围内对象

CAD二次开发获取当前视角范围内对象

作者:互联网

 1 private List<Curve> GetCurveFromView() {
 2             List<Curve> curves = new List<Curve>();
 3             ViewTableRecord viewTableRecord = ed.GetCurrentView();
 4             double w = viewTableRecord.Width;
 5             double h = viewTableRecord.Height;
 6             Point2d point = viewTableRecord.CenterPoint;
 7             Point3d P1 = new Point3d(point.X - w / 2, point.Y - h / 2, 0);
 8             Point3d P2 = new Point3d(point.X + w / 2, point.Y + h / 2, 0);
 9             PromptSelectionResult promptSelectionResult = ed.SelectCrossingWindow(P1, P2);
10             if (promptSelectionResult.Status == PromptStatus.OK)
11             {
12                 ObjectId[] objectIds = promptSelectionResult.Value.GetObjectIds();
13                 using (Transaction trans = doc.TransactionManager.StartTransaction())
14                 {
15                     foreach (ObjectId objectId in objectIds)
16                     {
17                         Curve curve = trans.GetObject(objectId, OpenMode.ForRead) as Curve;
18                         if (curve != null) {
19                             curves.Add(curve);
20                         }
21                     }
22                 }
23             }
24 
25             return curves;
26         }

 

标签:viewTableRecord,视角,point,List,promptSelectionResult,二次开发,new,Point3d,CAD
来源: https://www.cnblogs.com/chenshuangjian/p/15958230.html