zoukankan      html  css  js  c++  java
  • autocad.netQQ群:193522571属性块中属性文字宽度比例自动调整到格子宽度内,比例因子小于标准比例因子的自动设置为标准比例因子

            #region 属性自动缩进
            /// <summary>
            /// 属性比例因子设置
            /// </summary>
            /// <param name="br">属性块参照</param>
            /// <param name="lstWidth">属性宽度集合</param>
            /// <param name="Factor">标准比例因子</param>
            public static void setAttributeReferenceWidth(this BlockReference br, List<double> lstWidth,double Factor)
            {
                //定义事务对象
                var trans = br.Id.Database.TransactionManager; 
                //初始化计数器
                int i = 0;
                //在每个属性中循环
                foreach (ObjectId attId in br.AttributeCollection)
                {
                    // 获取块参照属性对象
                    AttributeReference attRef = (AttributeReference)trans.GetObject(attId, OpenMode.ForRead);
                    //打开能属性对象
                    attRef.UpgradeOpen();
                    //如果属性对象不为空
                    if (attRef.TextString != "")
                    {
                        //属性比例因子
                        double nowFactor = attRef.WidthFactor;
                        //属性宽度
                        double attributeWidth = Math.Abs(attRef.GeometricExtents.MaxPoint.X - attRef.GeometricExtents.MinPoint.X);
                        attributeWidth=attributeWidth/nowFactor;
                        //标准宽度
                        double standardWidth=attributeWidth*Factor;
                        //如果属性宽度超出了指定宽度则修改属性宽度因子
                        if (standardWidth > lstWidth[i]-2)
                        {
                            double calFactor = (lstWidth[i]-2)/ standardWidth;
                            attRef.WidthFactor = Factor * calFactor;
                        }
                        //如果未超出则将比例因子统一为标准比例因子
                        else
                        {
                            attRef.WidthFactor = Factor;
                        }
                    }
                    attRef.DowngradeOpen();
                    i++;
                }
            }
            #endregion
  • 相关阅读:
    poj 1860 Currency Exchange(最短路径的应用)
    poj 2965 The Pilots Brothers' refrigerator
    zoj 1827 the game of 31 (有限制的博弈论)
    poj 3295 Tautology (构造法)
    poj 1753 Flip Game(枚举)
    poj 2109 (贪心)
    poj 1328(贪心)
    Qt 对单个控件美化
    Qt 4基础
    Bash Shell
  • 原文地址:https://www.cnblogs.com/swtool/p/3648472.html
Copyright © 2011-2022 走看看