如题
public class 测试选择集的点选位置和点选方式 { //对应lisp的ssnamex,获取选择的方式和选择的角点 [CommandMethod("tt_getssgetpick", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw)] public void tt_getssgetpick() { Database db = HostApplicationServices.WorkingDatabase;//当前的数据库 Editor ed = Acap.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage(Environment.NewLine + "****惊惊连盒-测试选择集的点选位置和点选方式"); var tkids = new List<ObjectId>(); //创建选择集过滤器,只选择块对象 TypedValue[] filList = new TypedValue[] { // new TypedValue((int)DxfCode.Start, "INSERT") }; SelectionFilter filter = new SelectionFilter(filList); //定义选择集选项 var pso = new PromptSelectionOptions { RejectObjectsOnLockedLayers = true, //不选择锁定图层对象 AllowDuplicates = true, //不允许重复选择 }; var ssPsr = ed.GetSelection(pso, filter);//手选 if (ssPsr.Status != PromptStatus.OK) { return; } //获取所有的id //foreach (var item in ssPsr.Value.GetObjectIds()) //{ // Debug.WriteLine(item);//所有的角点信息 //} var va = ssPsr.Value; foreach (var vaItem in va) { if (vaItem is CrossingOrWindowSelectedObject cows)//框选方式 { foreach (var ppd in cows.GetPickPoints()) { Debug.WriteLine(ppd.PointOnLine);//ppd内还有内容 } } else if (vaItem is PickPointSelectedObject pps)//点选方式 { Debug.WriteLine(pps.PickPoint);//pps内还有内容 } } } }