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

      

  • 相关阅读:
    echarts设置数据在轴线上显示
    LeetCode【189. 旋转数组】
    pycharm快捷键
    LeetCode【461. 汉明距离】
    LeetCode【1051. 高度检查器】
    LeetCode【509. 斐波那契数】
    LeetCode【1021. 删除最外层的括号】
    LeetCode【206. 反转链表】
    LeetCode【344. 反转字符串】
    tensorboard运行
  • 原文地址:https://www.cnblogs.com/wwssgg/p/15498660.html
Copyright © 2011-2022 走看看