zoukankan      html  css  js  c++  java
  • 返回块参照的属性名和属性值

        /// <returns>返回块参照的属性名和属性值</returns>
            public static SortedDictionary<string, string> GetAttributesInBlock(this Database db, string blockName)
            {
                SortedDictionary<string, string> attributes = new SortedDictionary<string, string>();
                // 筛选指定名称的块参照
                TypedValue[] values = { new TypedValue((int)DxfCode.Start, "INSERT"),
                                        new TypedValue((int)DxfCode.BlockName, blockName),
                                        };
                var filter = new SelectionFilter(values);
                Editor ed = Application.DocumentManager.GetDocument(db).Editor;
                var entSelected = ed.SelectAll(filter);
                // 如果数据库不存在指定名称的块参照,则返回
                if (entSelected.Status != PromptStatus.OK) return null;
                using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                    // 遍历块参照
                    foreach (var id in entSelected.Value.GetObjectIds())
                    {
                        BlockReference bref = (BlockReference)trans.GetObject(id, OpenMode.ForRead);
                        // 遍历块参照中的属性
                        foreach (ObjectId attId in bref.AttributeCollection)
                        {
                            AttributeReference attRef = (AttributeReference)trans.GetObject(attId, OpenMode.ForRead);
                            // 将块参照的属性名和属性值添加到字典中
                            attributes.Add(attRef.Tag, attRef.TextString);
                        }
                    }
                    trans.Commit();
                }
                return attributes; // 返回指定名称的块参照的属性名和属性值
    

      

  • 相关阅读:
    树形DP求树的最小支配集,最小点覆盖,最大独立集
    贪心法求树的最小支配集,最小点覆盖,最大独立集
    树上两点的最近公共祖先问题(Least Common Ancestors)
    大厂前端面试题
    表单中包含上传图片
    element-ui表单验证
    一、React基础
    点击div上传图片,在img中预览
    持久化
    docker安装
  • 原文地址:https://www.cnblogs.com/wwssgg/p/15498660.html
Copyright © 2011-2022 走看看