老师指点一下吧,我目前感觉自己还没有入门,不知如何去写,今天我又搞了一天都没有头绪,以下是我写的获取线的端点,后续如何将点加入到数组和判断我不会...请指导...- public void CLine()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Editor ed = doc.Editor;
- Database db = HostApplicationServices.WorkingDatabase;
- SelectionFilter sf = new SelectionFilter(new TypedValue[] { new TypedValue(0, "Line") });
- PromptSelectionResult psr = ed.GetSelection(sf);
- if (psr.Status != PromptStatus.OK)
- return;
- Point3d[] Sptsum = new Point3d[0];
- Point3d[] Eptsum = new Point3d[0];
- int i = 0;
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- BlockTableRecord curSpace=tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
- foreach (ObjectId id in psr.Value.GetObjectIds())
- {
- Entity ent = tr.GetObject(id, OpenMode.ForRead) as Entity;
- if (ent.GetType() == typeof(Line))
- {
- Line ls = ent as Line;
- Point3d Spt = ls.StartPoint;
- Point3d Ept = ls.EndPoint;
-
- //Sptsum[i] = AddPoint3d(i, Spt[i], 0, 0, 0);
- //Eptsum[i] = AddPoint3d(i, Ept[i], 0, 0, 0);
- //i++;
- //Line len = new Line(Spt, Ept);
- //curSpace.AppendEntity(len);
- //tr.AddNewlyCreatedDBObject(len, true);
- }
- }
-
- tr.Commit();
- }
- }
|