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

  • 相关阅读:
    Android平台架构及特性
    MySQL 数据库性能优化之索引优化
    排序自己总结
    存储过程中“ 警告: 聚合或其他 SET 操作消除了 Null 值” 导致错误的解决
    存储过程的output及return的区别
    如果ssh端口转发时候g没有效果解决方案
    sql语句显示复选内容, indication 为复选框的累计value(整数),显示所有的
    kprfakesu.c Linux su密码欺骗 源码
    Unix/Linux上的后门技术和防范
    iis7应用程序池经常自动停止如何解决?
  • 原文地址:https://www.cnblogs.com/swtool/p/3828989.html
Copyright © 2011-2022 走看看