zoukankan      html  css  js  c++  java
  • 过滤选择集

     /// <summary>
            /// 过滤选择集合
            /// 调用方法如: ObjectIdCollection EntityCollection = GetSelection();  
            /// </summary>
            /// <returns>对象集合</returns>
            public static ObjectIdCollection GetSelection()
            {
                Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
                Database db = doc.Database;
                Editor ed = doc.Editor;
                Entity entity = null;
                DBObjectCollection entityCollection = new DBObjectCollection();

                // 建立选择的过滤器内容
                TypedValue[] values = new TypedValue[]
                {
                    new TypedValue((int)DxfCode.Start,"Text")
                };
                SelectionFilter filter = new SelectionFilter(values);
                PromptSelectionResult optSel = ed.GetSelection(filter);

                if (optSel.Status == PromptStatus.OK)
                {
                    using (Transaction transaction = db.TransactionManager.StartTransaction())
                    {
                        SelectionSet SS = optSel.Value;
                        foreach (ObjectId id in SS.GetObjectIds())
                        {
                            entity = (Entity)transaction.GetObject(id, OpenMode.ForWrite, true);
                            if (entity != null)
                                entityCollection.Add(entity);
                        }
                        transaction.Commit();
                    }
                }

                ObjectIdCollection ids = new ObjectIdCollection();
                foreach (Entity ent in entityCollection)
                {
                    ObjectId id = ent.ObjectId;
                    ids.Add(id);
                }
                return ids;
            }

  • 相关阅读:
    vs项目,点击.sln文件时出错:“项目所需的应用程序未安装,确保已安装项目类型(.csproj)的应用程序”解决办法
    Oracle VM VirtualBox各种显示模式切换 热键
    ajax从asp后台获取数据
    js获取页面的宽度
    SharePoint列表数据展现方法
    select改变执行操作
    SharePoint中删除列表记录
    HP EliteBook 8770p打开Vt-x
    SPlist按PID层级顺序导入datatable
    Excel导入DataTable
  • 原文地址:https://www.cnblogs.com/swtool/p/3828989.html
Copyright © 2011-2022 走看看