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
  • 相关阅读:
    缓存ehcache启动失败missing element type
    使用Shell发布Spring Boot程序
    从游牧民族价值观看程序员问题
    浏览器端的缓存localStorage应用
    基于进程的Quartz.NET管理系统QuartzService(一)
    ASP.NET WebAPI 15 CORS
    ASP.NET WebAPI 14 仿写Filter管道
    ASP.NET WebAPI 13 Filter
    ASP.NET WebAPI 12 Action的执行
    ASP.NET WebAPI 11 参数验证
  • 原文地址:https://www.cnblogs.com/swtool/p/3648472.html
Copyright © 2011-2022 走看看