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

  • 相关阅读:
    记录一次SpringCloud Alibaba整合Springboot出现的'com.netflix.client.config.IClientConfig' that could not be found
    ysoserial-URLDNS链分析
    DIVA闯关-APP测试
    前端页面直接转换为PDF文件流
    中位数最大问题
    【vim】Linux添加环境变量等
    FFmpeg使用笔记
    【memo】及时留坑
    【album】深度学习 / 机器学习 / 人工智能
    【Linux】软件安装使用【aubio / FFmpeg】
  • 原文地址:https://www.cnblogs.com/swtool/p/3828989.html
Copyright © 2011-2022 走看看