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;
            }

  • 相关阅读:
    大数据挖掘算法篇之K-Means实例
    断篇-金融大数据最佳实践总结篇
    网络爬虫之Windows环境Heritrix3.0配置指南
    开源中文分词框架分词效果对比smartcn与IKanalyzer
    Eclipse整合Tomcat开发Dynamic Web Project环境总结
    c#系统消息类封装
    Uploadify v3.2.1 参数说明
    js 或 且 非
    数据注解特性--NotMapped
    SQLServer2008/2005 生成数据字典语句
  • 原文地址:https://www.cnblogs.com/swtool/p/3828989.html
Copyright © 2011-2022 走看看