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; // 返回指定名称的块参照的属性名和属性值
    

      

  • 相关阅读:
    Stack
    汇编语言结构
    位操作指令bitwise logical instructions
    Linux中一些系统调用的汇编程序
    Ctrl + D
    一般的二进制数描述方法
    在汇编中定义table(array)
    (转)yujiaun 企业站MVC3.0版源码
    (转)knockout.js教程
    (转)开源中国WP7客户端全面开源,包括iPhone客户端与Android
  • 原文地址:https://www.cnblogs.com/wwssgg/p/15498660.html
Copyright © 2011-2022 走看看