Esempio n. 1
0
 /// <summary>
 /// 将图形数据库中的有名对象字典数据读入对话框中,显示钢束总体信息
 /// </summary>
 /// <param name="db">图形数据库</param>
 /// <param name="tdinfo">钢束信息对话框</param>
 public static void ReadNamedDicToDlg(this TendonInfo tdInfo, Database db)
 {
     using (Transaction trans = db.TransactionManager.StartTransaction())//开始事务处理
     {
         //1.操作有名对象字典,获取钢束总体信息
         DBDictionary dicts = db.NamedObjectsDictionaryId.GetObject(OpenMode.ForWrite) as DBDictionary;
         //如果已有名为DA_Tendons的字典项,则将其中数据读入界面中
         ObjectId     tdsDictId = dicts.GetAt("DA_Tendons");
         DBDictionary tdsDict   = tdsDictId.GetObject(OpenMode.ForWrite) as DBDictionary; //获取DA_Tendons字典
         if (tdsDict != null)
         {
             //管道偏差系数
             ObjectId       xrecId = tdsDict.GetAt("kii");
             Xrecord        xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
             TypedValueList vls    = xrec.Data;
             tdInfo.textBoxKii.Text = vls[0].Value.ToString();
             //摩阻系数
             xrecId = tdsDict.GetAt("miu");
             xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
             vls    = xrec.Data;
             tdInfo.textBoxMiu.Text = vls[0].Value.ToString();
             //钢束弹性模量
             xrecId = tdsDict.GetAt("Ep");
             xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
             vls    = xrec.Data;
             tdInfo.textBoxEp.Text = vls[0].Value.ToString();
             //张拉控制应力
             xrecId = tdsDict.GetAt("ctrlStress");
             xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
             vls    = xrec.Data;
             tdInfo.textBoxCtrlStress.Text = vls[0].Value.ToString();
             //张拉端工作长度
             xrecId = tdsDict.GetAt("workLen");
             xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
             vls    = xrec.Data;
             tdInfo.textBoxWorkLen.Text = vls[0].Value.ToString();
             trans.Commit();//执行事务处理
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 将图形数据库与tdGenParas中的数据同步
 /// </summary>
 /// <param name="db">图形数据库</param>
 /// <param name="tdGenParas">程序中的tdGenParas类</param>
 public static void SyncDwgToTdGenParas(this Database db, TendonGeneralParameters tdGenParas)
 {
     using (Transaction trans = db.TransactionManager.StartTransaction())//开始事务处理
     {
         // 获取当前图形数据库的有名对象字典
         DBDictionary dicts     = db.NamedObjectsDictionaryId.GetObject(OpenMode.ForWrite) as DBDictionary;
         ObjectId     tdsDictId = new ObjectId();             //
         if (!dicts.Contains("DA_Tendons"))                   //如果字典中不含DA_Tendons的字典项
         {
             tdsDictId = db.AddNamedDictionary("DA_Tendons"); //则添加该字典项
         }
         else//如果字典中含有DA_Tendons的字典项
         {
             tdsDictId = dicts.GetAt("DA_Tendons");//则获取该字典项
         }
         //将字典项内容与tdGenParas同步
         //管道偏差系数
         TypedValueList values = new TypedValueList();
         values.Add(DxfCode.Real, tdGenParas.Kii);
         tdsDictId.AddXrecord2DBDict("kii", values);
         //摩阻系数
         values = new TypedValueList();
         values.Add(DxfCode.Real, tdGenParas.Miu);
         tdsDictId.AddXrecord2DBDict("miu", values);
         //钢束弹性模量
         values = new TypedValueList();
         values.Add(DxfCode.Real, tdGenParas.Ep);
         tdsDictId.AddXrecord2DBDict("Ep", values);
         //张拉控制应力
         values = new TypedValueList();
         values.Add(DxfCode.Real, tdGenParas.CtrlStress);
         tdsDictId.AddXrecord2DBDict("ctrlStress", values);
         //张拉端工作长度
         values = new TypedValueList();
         values.Add(DxfCode.Real, tdGenParas.WorkLen);
         tdsDictId.AddXrecord2DBDict("workLen", values);
         trans.Commit();//执行事务处理
     }
 }
Esempio n. 3
0
 public static void SetDefaultTendonParams(this Polyline td)
 {
     //钢束名称默认为F1
     if (td.ExtensionDictionary.IsNull || td.ObjectId.GetXrecord("tdName") == null)
     {
         TypedValueList values = new TypedValueList();
         values.Add(DxfCode.Text, "F1");
         td.ObjectId.AddXrecord("tdName", values);
     }
     //钢束规格默认为Φ15-12
     if (td.ExtensionDictionary.IsNull || td.ObjectId.GetXrecord("tdStyle") == null)
     {
         TypedValueList values = new TypedValueList();
         values.Add(DxfCode.Text, "Φ15-12");
         td.ObjectId.AddXrecord("tdStyle", values);
     }
     //3.钢束根数默认为1
     if (td.ExtensionDictionary.IsNull || td.ObjectId.GetXrecord("tdNum") == null)
     {
         TypedValueList values = new TypedValueList();
         values.Add(DxfCode.Int16, 1);
         td.ObjectId.AddXrecord("tdNum", values);
     }
     //4.管道直径默认为90
     if (td.ExtensionDictionary.IsNull || td.ObjectId.GetXrecord("tdPipeDia") == null)
     {
         TypedValueList values = new TypedValueList();
         values.Add(DxfCode.Real, 90);
         td.ObjectId.AddXrecord("tdPipeDia", values);
     }
     //5.张拉方式默认为两端张拉,0
     if (td.ExtensionDictionary.IsNull || td.ObjectId.GetXrecord("tdDrawStyle") == null)
     {
         TypedValueList values = new TypedValueList();
         values.Add(DxfCode.Int16, 0);
         td.ObjectId.AddXrecord("tdDrawStyle", values);
     }
 }
Esempio n. 4
0
        /// <summary>
        /// 将表格数据读入至钢束线的Xrecord中
        /// </summary>
        /// <param name="row">表格</param>
        /// <param name="tdId">钢束多段线的ObjectId</param>
        public static void ReadRowToXrecord(this ObjectId tdId, DataGridViewRow row)
        {
            //钢束名称
            TypedValueList values = new TypedValueList();

            values.Add(DxfCode.Text, row.Cells[0].Value.ToString());
            tdId.SetXrecord("tdName", values);
            //钢束规格
            values = new TypedValueList();
            values.Add(DxfCode.Text, row.Cells[1].Value.ToString());
            tdId.SetXrecord("tdStyle", values);
            //钢束根数
            values = new TypedValueList();
            values.Add(DxfCode.Int16, Int16.Parse(row.Cells[2].Value.ToString()));
            tdId.SetXrecord("tdNum", values);
            //管道直径
            values = new TypedValueList();
            values.Add(DxfCode.Real, double.Parse(row.Cells[3].Value.ToString()));
            tdId.SetXrecord("tdPipeDia", values);
            //张拉方式
            values = new TypedValueList();
            if ((bool)(row.Cells[4].Value) == true && (bool)(row.Cells[5].Value) == false)//左侧张拉
            {
                values.Add(DxfCode.Int16, -1);
                tdId.SetXrecord("tdDrawStyle", values);
            }
            else if ((bool)(row.Cells[4].Value) == true && (bool)(row.Cells[5].Value) == true)//两端张拉
            {
                values.Add(DxfCode.Int16, 0);
                tdId.SetXrecord("tdDrawStyle", values);
            }
            else if ((bool)(row.Cells[4].Value) == false && (bool)(row.Cells[5].Value) == true)//右侧张拉
            {
                values.Add(DxfCode.Int16, 1);
                tdId.SetXrecord("tdDrawStyle", values);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 将多段线钢束中的Xrecord信息读入到表格中
        /// 没有Xrecord则按默认值输入
        /// </summary>
        /// <param name="tdInfo">窗体</param>
        /// <param name="td">钢束多段线</param>
        /// <param name="kii">管道偏差系数(1/m)</param>
        /// <param name="miu">摩阻系数</param>
        /// <param name="Ep">钢束弹模(MPa)</param>
        /// <param name="ctrlStress">张拉控制应力(MPa)</param>
        /// <param name="workLen">工作长度(mm)</param>
        /// <returns>新加行的行号</returns>
        public static int?ReadXRecordToRow(TendonInfo tdInfo, Polyline td,
                                           double kii, double miu, double Ep, double ctrlStress, double workLen)
        {
            int index       = tdInfo.dataGridViewTendons.Rows.Add(); //添加新行
            int tdDrawStyle = 0;                                     //张拉方式

            #region 1.钢束名称
            if (td.ExtensionDictionary.IsNull || td.ObjectId.GetXrecord("tdName") == null)
            {
                TypedValueList values = new TypedValueList();
                values.Add(DxfCode.Text, $"F{1 + index}");
                td.ObjectId.AddXrecord("tdName", values);
                tdInfo.dataGridViewTendons.Rows[index].Cells[0].Value = $"F{1 + index}";
            }
            else//如果存在该键值,采用Xrecord中记录的信息
            {
                string tdName = (string)td.ObjectId.GetXrecord("tdName")[0].Value;
                tdInfo.dataGridViewTendons.Rows[index].Cells[0].Value = tdName;
            }
            #endregion
            #region 2.钢束规格
            if (td.ExtensionDictionary.IsNull || td.ObjectId.GetXrecord("tdStyle") == null)
            {
                TypedValueList values = new TypedValueList();
                values.Add(DxfCode.Text, "Φ15-12");
                td.ObjectId.AddXrecord("tdStyle", values);
                tdInfo.dataGridViewTendons.Rows[index].Cells[1].Value = "Φ15-12";
            }
            else//如果存在该键值,采用Xrecord中记录的信息
            {
                string tdStyle = (string)td.ObjectId.GetXrecord("tdStyle")[0].Value;
                tdInfo.dataGridViewTendons.Rows[index].Cells[1].Value = tdStyle;
            }
            #endregion
            #region 3.钢束根数
            if (td.ExtensionDictionary.IsNull || td.ObjectId.GetXrecord("tdNum") == null)
            {
                TypedValueList values = new TypedValueList();
                values.Add(DxfCode.Int16, 1);
                td.ObjectId.AddXrecord("tdNum", values);
                tdInfo.dataGridViewTendons.Rows[index].Cells[2].Value = "1";
            }
            else//如果存在该键值,采用Xrecord中记录的信息
            {
                Int16 tdNum = (Int16)td.ObjectId.GetXrecord("tdNum")[0].Value;
                tdInfo.dataGridViewTendons.Rows[index].Cells[2].Value = tdNum.ToString();
            }
            #endregion
            #region 4.管道直径
            if (td.ExtensionDictionary.IsNull || td.ObjectId.GetXrecord("tdPipeDia") == null)
            {
                TypedValueList values = new TypedValueList();
                values.Add(DxfCode.Real, 90);
                td.ObjectId.AddXrecord("tdPipeDia", values);
                tdInfo.dataGridViewTendons.Rows[index].Cells[3].Value = "90";
            }
            else//如果存在该键值,采用Xrecord中记录的信息
            {
                double tdPipeDia = (double)td.ObjectId.GetXrecord("tdPipeDia")[0].Value;
                tdInfo.dataGridViewTendons.Rows[index].Cells[3].Value = tdPipeDia.ToString("F0");
            }
            #endregion
            #region 5.张拉方式
            if (td.ExtensionDictionary.IsNull || td.ObjectId.GetXrecord("tdDrawStyle") == null)
            {
                TypedValueList values = new TypedValueList();
                values.Add(DxfCode.Int16, 0);
                td.ObjectId.AddXrecord("tdDrawStyle", values);
                tdInfo.dataGridViewTendons.Rows[index].Cells[4].Value = true;
                tdInfo.dataGridViewTendons.Rows[index].Cells[5].Value = true;
            }
            else//如果存在该键值,采用Xrecord中记录的信息
            {
                tdDrawStyle = (Int16)td.ObjectId.GetXrecord("tdDrawStyle")[0].Value;
                switch (tdDrawStyle)
                {
                case -1:    //左侧张拉
                    tdInfo.dataGridViewTendons.Rows[index].Cells[4].Value = true;
                    tdInfo.dataGridViewTendons.Rows[index].Cells[5].Value = false;
                    break;

                case 0:    //两侧张拉
                    tdInfo.dataGridViewTendons.Rows[index].Cells[4].Value = true;
                    tdInfo.dataGridViewTendons.Rows[index].Cells[5].Value = true;
                    break;

                case 1:    //右侧张拉
                    tdInfo.dataGridViewTendons.Rows[index].Cells[4].Value = false;
                    tdInfo.dataGridViewTendons.Rows[index].Cells[5].Value = true;
                    break;
                }
            }
            #endregion
            #region 6.引伸量
            switch (tdDrawStyle)
            {
            case -1:
                //左侧引伸量
                tdInfo.dataGridViewTendons.Rows[index].Cells[6].Value
                    = td.SingleDrawAmount(ctrlStress, kii, miu, -1, Ep).ToString("F0");
                //右侧引伸量
                tdInfo.dataGridViewTendons.Rows[index].Cells[7].Value = "0";
                break;

            case 0:
                //左侧引伸量
                tdInfo.dataGridViewTendons.Rows[index].Cells[6].Value
                    = td.BothDrawAmount(ctrlStress, kii, miu, Ep)[0].ToString("F0");
                //右侧引伸量
                tdInfo.dataGridViewTendons.Rows[index].Cells[7].Value
                    = td.BothDrawAmount(ctrlStress, kii, miu, Ep)[1].ToString("F0");
                break;

            case 1:
                //左侧引伸量
                tdInfo.dataGridViewTendons.Rows[index].Cells[6].Value = "0";
                //右侧引伸量
                tdInfo.dataGridViewTendons.Rows[index].Cells[7].Value
                    = td.SingleDrawAmount(ctrlStress, kii, miu, 1, Ep).ToString("F0");
                break;
            }
            #endregion
            #region 7.钢束长度
            //钢束净长
            tdInfo.dataGridViewTendons.Rows[index].Cells[8].Value = td.Length.ToString("F0");
            //钢束总长
            tdInfo.dataGridViewTendons.Rows[index].Cells[9].Value
                = (td.Length + (2 - Math.Abs(tdDrawStyle)) * workLen).ToString("F0");
            #endregion
            return(index);
        }
Esempio n. 6
0
        public void TendonTable()
        {
            //创建钢束信息界面
            TendonInfo tdInfo = new TendonInfo();
            Document   doc    = Application.DocumentManager.MdiActiveDocument;
            Database   db     = doc.Database;
            Editor     ed     = doc.Editor;

            using (Transaction trans = db.TransactionManager.StartTransaction())//开始事务处理
            {
                //1.操作有名对象字典,获取钢束总体信息
                // 获取当前数据库的有名对象字典
                DBDictionary dicts = db.NamedObjectsDictionaryId.GetObject(OpenMode.ForWrite) as DBDictionary;
                if (dicts.Contains("DA_Tendons"))                                //调试用
                {
                    dicts.Remove("DA_Tendons");                                  //调试用
                }
                if (!dicts.Contains("DA_Tendons"))                               //如果字典中不含DA_Tendons的字典项
                {
                    ObjectId tdsDictNewId = db.AddNamedDictionary("DA_Tendons"); //则添加该字典项
                    //管道偏差系数
                    TypedValueList values = new TypedValueList();
                    values.Add(DxfCode.Real, kii);
                    tdsDictNewId.AddXrecord2DBDict("kii", values);
                    //摩阻系数
                    values = new TypedValueList();
                    values.Add(DxfCode.Real, miu);
                    tdsDictNewId.AddXrecord2DBDict("miu", values);
                    //钢束弹性模量
                    values = new TypedValueList();
                    values.Add(DxfCode.Real, Ep);
                    tdsDictNewId.AddXrecord2DBDict("Ep", values);
                    //张拉控制应力
                    values = new TypedValueList();
                    values.Add(DxfCode.Real, ctrlStress);
                    tdsDictNewId.AddXrecord2DBDict("ctrlStress", values);
                    //张拉端工作长度
                    values = new TypedValueList();
                    values.Add(DxfCode.Real, workLen);
                    tdsDictNewId.AddXrecord2DBDict("workLen", values);
                }
                //如果已有名为DA_Tendons的字典项,则将其中数据读入界面中
                dicts = db.NamedObjectsDictionaryId.GetObject(OpenMode.ForRead) as DBDictionary; //获取当前数据库有名对象字典
                ObjectId     tdsDictId = dicts.GetAt("DA_Tendons");
                DBDictionary tdsDict   = tdsDictId.GetObject(OpenMode.ForWrite) as DBDictionary; //获取DA_Tendons字典
                ed.WriteMessage(tdsDict.Count.ToString());                                       //调试用
                //管道偏差系数
                ObjectId       xrecId = tdsDict.GetAt("kii");
                Xrecord        xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
                TypedValueList vls    = xrec.Data;
                tdInfo.textBoxKii.Text = vls[0].Value.ToString();
                //摩阻系数
                xrecId = tdsDict.GetAt("miu");
                xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
                vls    = xrec.Data;
                tdInfo.textBoxMiu.Text = vls[0].Value.ToString();
                //钢束弹性模量
                xrecId = tdsDict.GetAt("Ep");
                xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
                vls    = xrec.Data;
                tdInfo.textBoxEp.Text = vls[0].Value.ToString();
                //张拉控制应力
                xrecId = tdsDict.GetAt("ctrlStress");
                xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
                vls    = xrec.Data;
                tdInfo.textBoxCtrlStress.Text = vls[0].Value.ToString();
                //张拉端工作长度
                xrecId = tdsDict.GetAt("workLen");
                xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
                vls    = xrec.Data;
                tdInfo.textBoxWorkLen.Text = vls[0].Value.ToString();
                trans.Commit();//执行事务处理
            }
            //显示钢束信息界面
            Application.ShowModalDialog(tdInfo);
        }
Esempio n. 7
0
 /// <summary>
 /// 将钢束总体参数与图形数据库中的数据同步
 /// </summary>
 /// <param name="db">图形数据库</param>
 public static void SyncTdGenParasToDwg(Database db)
 {
     using (Transaction trans = db.TransactionManager.StartTransaction())//开始事务处理
     {
         // 获取当前图形数据库的有名对象字典
         DBDictionary dicts = db.NamedObjectsDictionaryId.GetObject(OpenMode.ForWrite) as DBDictionary;
         if (!dicts.Contains("DA_Tendons"))                               //如果字典中不含DA_Tendons的字典项
         {
             ObjectId tdsDictNewId = db.AddNamedDictionary("DA_Tendons"); //则添加该字典项
             //将字典项内容与tdGenParas同步
             //管道偏差系数
             TypedValueList values = new TypedValueList();
             values.Add(DxfCode.Real, TendonGeneralParameters.Kii);
             tdsDictNewId.AddXrecord2DBDict("kii", values);
             //摩阻系数
             values = new TypedValueList();
             values.Add(DxfCode.Real, TendonGeneralParameters.Miu);
             tdsDictNewId.AddXrecord2DBDict("miu", values);
             //钢束弹性模量
             values = new TypedValueList();
             values.Add(DxfCode.Real, TendonGeneralParameters.Ep);
             tdsDictNewId.AddXrecord2DBDict("Ep", values);
             //张拉控制应力
             values = new TypedValueList();
             values.Add(DxfCode.Real, TendonGeneralParameters.CtrlStress);
             tdsDictNewId.AddXrecord2DBDict("ctrlStress", values);
             //张拉端工作长度
             values = new TypedValueList();
             values.Add(DxfCode.Real, TendonGeneralParameters.WorkLen);
             tdsDictNewId.AddXrecord2DBDict("workLen", values);
         }
         else//如果存在该字典项,则把tdGenParas各属性与图形数据库同步
         {
             ObjectId     tdsDictId = dicts.GetAt("DA_Tendons");
             DBDictionary tdsDict   = tdsDictId.GetObject(OpenMode.ForWrite) as DBDictionary; //获取DA_Tendons字典
             //管道偏差系数
             ObjectId       xrecId = tdsDict.GetAt("kii");
             Xrecord        xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
             TypedValueList vls    = xrec.Data;
             TendonGeneralParameters.Kii = (double)vls[0].Value;
             //摩阻系数
             xrecId = tdsDict.GetAt("miu");
             xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
             vls    = xrec.Data;
             TendonGeneralParameters.Miu = (double)vls[0].Value;
             //钢束弹性模量
             xrecId = tdsDict.GetAt("Ep");
             xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
             vls    = xrec.Data;
             TendonGeneralParameters.Ep = (double)vls[0].Value;
             //张拉控制应力
             xrecId = tdsDict.GetAt("ctrlStress");
             xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
             vls    = xrec.Data;
             TendonGeneralParameters.CtrlStress = (double)vls[0].Value;
             //张拉端工作长度
             xrecId = tdsDict.GetAt("workLen");
             xrec   = xrecId.GetObject(OpenMode.ForRead) as Xrecord;
             vls    = xrec.Data;
             TendonGeneralParameters.WorkLen = (double)vls[0].Value;
         }
         dicts.DowngradeOpen();
         trans.Commit();//执行事务处理
     }
 }
Esempio n. 8
0
        public void TendonAnnotation()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;

            db.SyncDwgToTdGenParas();//设置默认总体参数,已有总体参数字典项则无动作
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                #region 1.选择梁顶缘线
                PromptEntityOptions tpLineOpt = new PromptEntityOptions("\n选择梁顶缘线");
                tpLineOpt.SetRejectMessage("\n顶缘线应为直线、圆弧或多段线");
                tpLineOpt.AddAllowedClass(typeof(Line), true);     //可以选择直线
                tpLineOpt.AddAllowedClass(typeof(Polyline), true); //可以选择多段线
                tpLineOpt.AddAllowedClass(typeof(Arc), true);      //可以选择圆弧线
                PromptEntityResult tpLineRes = ed.GetEntity(tpLineOpt);
                if (tpLineRes.Status != PromptStatus.OK)
                {
                    return;
                }
                ObjectId tpLineId = tpLineRes.ObjectId;
                Curve    tpLine   = trans.GetObject(tpLineId, OpenMode.ForRead) as Curve;
                #endregion
                #region 2.选择钢束线
                PromptEntityOptions tdLineOpt = new PromptEntityOptions("\n选择钢束");
                tdLineOpt.SetRejectMessage("\n钢束应为多段线");
                tdLineOpt.AddAllowedClass(typeof(Polyline), true);//仅能选择多段线
                PromptEntityResult tdLineRes = ed.GetEntity(tdLineOpt);
                if (tdLineRes.Status != PromptStatus.OK)
                {
                    return;
                }
                ObjectId tdLineId = tdLineRes.ObjectId;
                Polyline tdLine   = trans.GetObject(tdLineId, OpenMode.ForRead) as Polyline;

                //判断钢束线是否在顶缘线以内,否则报错返回
                if (tdLine.StartPoint.X < tpLine.StartPoint.X || tdLine.EndPoint.X > tpLine.EndPoint.X)
                {
                    Application.ShowAlertDialog("钢束线超出顶缘线,请检查!");
                    return;
                }
                tdLine.SetDefaultTendonParams();//设置钢束默认参数,如已有Xrecord信息则无动作
                #endregion
                #region 3.设置绘图参数(包括张拉方式和工作长度设置)
                //3.1 尺寸标注绘图位置及张拉方式和工作长度设置
                Point3d            pos    = new Point3d();//初始化标注点
                PromptPointOptions posOpt = new PromptPointOptions("\n设置标注线位置或设置[张拉方式(D)/工作长度(W)]");
                posOpt.Keywords.Add("D");
                posOpt.Keywords.Add("W");
                posOpt.AppendKeywordsToMessage = false;                                                     //提示信息中不显示关键字
                //获取钢束张拉方式
                int tdDrawStyle = 0;                                                                        //默认为两端张拉
                if (!tdLine.ExtensionDictionary.IsNull && tdLine.ObjectId.GetXrecord("DA_Tendons") != null) //如果钢束线有扩展记录则取扩展记录数据
                {
                    tdDrawStyle = (Int16)tdLine.ObjectId.GetXrecord("DA_Tendons")[4].Value;
                }
                //获取工作长度信息
                double       workLen = 800;
                DBDictionary dicts   = db.NamedObjectsDictionaryId.GetObject(OpenMode.ForWrite) as DBDictionary;
                if (dicts.Contains("DA_Tendons"))//如果字典中含DA_Tendons的字典项
                {
                    ObjectId       tdsDictId = dicts.GetAt("DA_Tendons");
                    DBDictionary   tdsDict   = tdsDictId.GetObject(OpenMode.ForRead) as DBDictionary; //获取DA_Tendons字典
                    ObjectId       xrecId    = tdsDict.GetAt("workLen");                              //获取字典中的工作长度项
                    Xrecord        xrec      = xrecId.GetObject(OpenMode.ForRead) as Xrecord;         //获取工作长度项中的Xrecird
                    TypedValueList vls       = xrec.Data;                                             //获取Xrecord中的TypedValueList数据
                    workLen = (double)vls[0].Value;                                                   //根据TypedValueList数据中的数值更新工作长度workLen
                }
                for (;;)
                {
                    PromptPointResult posRes = ed.GetPoint(posOpt);
                    if (posRes.Status == PromptStatus.Keyword)
                    {
                        switch (posRes.StringResult)
                        {
                        case "D":                    //选择修改张拉方式
                            PromptIntegerOptions drwOpt = new PromptIntegerOptions($"\n输入张拉方式[两端张拉(0)/左端张拉[-1]/右端张拉[1]<{tdDrawStyle}>");
                            drwOpt.AllowNone = true; //允许ESC退出
                            PromptIntegerResult drwRes = ed.GetInteger(drwOpt);
                            if (drwRes.Value == 0)
                            {
                                tdDrawStyle = 0;
                            }
                            else if (drwRes.Value == -1)
                            {
                                tdDrawStyle = -1;
                            }
                            else if (drwRes.Value == 1)
                            {
                                tdDrawStyle = 1;
                            }
                            TypedValueList values = tdLine.ObjectId.GetXrecord("DA_Tendons");    //根据输入更新钢束线的Xrecord记录
                            values.RemoveAt(4);
                            values.Add(DxfCode.Int16, tdDrawStyle);
                            break;

                        case "W":                    //修改工作长度
                            PromptDoubleOptions wklOpt = new PromptDoubleOptions($"\n输入工作长度<{workLen.ToString("F0")}>");
                            wklOpt.AllowNone = true; //允许ESC退出
                            PromptDoubleResult wklRes = ed.GetDouble(wklOpt);
                            if (wklRes.Status == PromptStatus.OK)
                            {
                                workLen = wklRes.Value;
                                ObjectId       tdsDictId = dicts.GetAt("DA_Tendons");//更新DA_Tendons字典中的钢束总体参数
                                DBDictionary   tdsDict   = tdsDictId.GetObject(OpenMode.ForRead) as DBDictionary;
                                ObjectId       xrecId    = tdsDict.GetAt("workLen");
                                Xrecord        xrec      = xrecId.GetObject(OpenMode.ForWrite) as Xrecord;
                                TypedValueList vls       = new TypedValueList();
                                vls.Add(DxfCode.Real, workLen);
                                xrec.Data = vls;
                                xrec.DowngradeOpen();
                            }
                            break;
                        }
                    }
                    else if (posRes.Status == PromptStatus.OK)
                    {
                        pos = posRes.Value;
                        break;
                    }
                }
                //3.2 绘图比例
                PromptDoubleOptions scaleOpt = new PromptDoubleOptions($"\n设置绘图比例<{scale}>");
                scaleOpt.AllowNone     = true;                        //允许回车,则采用前次比例
                scaleOpt.AllowNegative = false;                       //不允许负值
                scaleOpt.AllowZero     = false;                       //不允许零值
                PromptDoubleResult scaleRes = ed.GetDouble(scaleOpt); //获取比例
                if (scaleRes.Status != PromptStatus.OK && scaleRes.Status != PromptStatus.None)
                {
                    return;
                }
                else if (scaleRes.Status == PromptStatus.OK)
                {
                    scale = scaleRes.Value;
                }
                #endregion
                #region 4.建立各类标注
                List <Point3d>   ptsH = new List <Point3d>();   //创建水平标注点集
                List <Dimension> dims = new List <Dimension>(); //创建标注集,存放各类标注
                for (int i = 0; i < tdLine.NumberOfVertices - 1; i++)
                {
                    //4.1 水平点集
                    ptsH.Add(tdLine.GetPoint3dAt(i));

                    //4.2 每段钢束线的长度
                    //4.3 直线标注角度
                    //4.4 圆弧线标注半径
                    if (tdLine.GetSegmentType(i) == SegmentType.Line)
                    {
                        LineSegment3d lineSeg = tdLine.GetLineSegmentAt(i);
                        //4.2 每段钢束线的长度
                        db.LineLengthDim(lineSeg, scale);
                        //4.3 直线标注角度
                        if (tdLine.StartPoint.X < tdLine.EndPoint.X)
                        {
                            db.LineAngelDim(lineSeg, !(i == tdLine.NumberOfVertices - 2), scale);
                        }
                        else
                        {
                            db.LineAngelDim(lineSeg, (i == tdLine.NumberOfVertices - 2), scale);
                        }
                    }
                    else if (tdLine.GetSegmentType(i) == SegmentType.Arc)
                    {
                        CircularArc3d arcSeg = tdLine.GetArcSegmentAt(i);
                        //4.2 每段钢束线的长度
                        db.ArcLengthDim(arcSeg, scale);
                        //4.3 圆弧标注半径
                        db.ArrowRadiusDim(arcSeg, scale);
                    }
                    //4.5 竖直距离标注
                    Ray vRay = new Ray();//建立竖直射线
                    vRay.BasePoint = tdLine.GetPoint3dAt(i);
                    vRay.UnitDir   = new Vector3d(0, 1, 0);
                    Point3dCollection ptIntersects = new Point3dCollection();
                    tpLine.IntersectWith(vRay, Intersect.OnBothOperands, ptIntersects, IntPtr.Zero, IntPtr.Zero);
                    Point3d          ptIntersect = ptIntersects[0];
                    RotatedDimension dimV        = new RotatedDimension();
                    dimV.XLine1Point    = tdLine.GetPoint3dAt(i); //第一条尺寸边线
                    dimV.XLine2Point    = ptIntersect;            //第二条尺寸边线
                    dimV.DimLinePoint   = tdLine.GetPoint3dAt(i); //尺寸线位置
                    dimV.Rotation       = Math.PI / 2;            //标注旋转90度
                    dimV.DimensionStyle = db.Dimstyle;            //尺寸样式为当前样式
                    dimV.Dimscale       = scale;                  //设置尺寸全局比例
                    dims.Add(dimV);
                }
                //4.1 节点间距点集缺钢束最后一个点、梁顶缘线端点
                ptsH.Add(tdLine.EndPoint);
                ptsH.Add(tpLine.StartPoint);
                ptsH.Add(tpLine.EndPoint);
                db.ContinuedHorizontalDims(ptsH, pos, scale);//建立水平连续标注

                //4.5 竖直距离标注缺最后一个点
                Ray vRayLast = new Ray();//建立竖直射线
                vRayLast.BasePoint = tdLine.GetPoint3dAt(tdLine.NumberOfVertices - 1);
                vRayLast.UnitDir   = new Vector3d(0, 1, 0);
                Point3dCollection ptIntersectsLast = new Point3dCollection();
                tpLine.IntersectWith(vRayLast, Intersect.OnBothOperands, ptIntersectsLast, IntPtr.Zero, IntPtr.Zero);
                Point3d          ptIntersectLast = ptIntersectsLast[0];
                RotatedDimension dimVLast        = new RotatedDimension();
                dimVLast.XLine1Point    = tdLine.GetPoint3dAt(tdLine.NumberOfVertices - 1); //第一条尺寸边线
                dimVLast.XLine2Point    = ptIntersectLast;                                  //第二条尺寸边线
                dimVLast.DimLinePoint   = tdLine.GetPoint3dAt(tdLine.NumberOfVertices - 1); //尺寸线位置
                dimVLast.Rotation       = Math.PI / 2;                                      //标注旋转90度
                dimVLast.DimensionStyle = db.Dimstyle;                                      //尺寸样式为当前样式
                dimVLast.Dimscale       = scale;                                            //设置尺寸全局比例
                dims.Add(dimVLast);
                #endregion
                #region 5 绘制张拉端
                //5.1 获取张拉端几何特征
                //获取钢束线真实的起点和终点
                Point3d tdStart = (tdLine.StartPoint.X < tdLine.EndPoint.X) ? tdLine.StartPoint : tdLine.EndPoint;
                Point3d tdEnd   = (tdLine.StartPoint.X < tdLine.EndPoint.X) ? tdLine.EndPoint : tdLine.StartPoint;
                //获取钢束线真实的起终点角度
                double iclStart = (tdLine.StartPoint.X < tdLine.EndPoint.X) ?
                                  tdLine.GetLineSegmentAt(0).GetAngleOfLineSeg() : tdLine.GetLineSegmentAt(tdLine.NumberOfVertices - 2).GetAngleOfLineSeg();
                double iclEnd = (tdLine.StartPoint.X < tdLine.EndPoint.X) ?
                                tdLine.GetLineSegmentAt(tdLine.NumberOfVertices - 2).GetAngleOfLineSeg() : tdLine.GetLineSegmentAt(0).GetAngleOfLineSeg();
                //初始化张拉端图元
                Polyline leftDraw  = new Polyline();
                Polyline rightDraw = new Polyline();
                MText    lengthL   = new MText();
                MText    lengthR   = new MText();
                //5.2 左侧张拉端
                //5.2.1 两侧张拉或左侧张拉时左端绘制工作长度线
                if (tdDrawStyle == 0 || tdDrawStyle == -1)
                {
                    //创建张拉端几何点
                    Point3d tdDrawL = GeTools.PolarPoint(tdStart, iclStart, -workLen);
                    //创建张拉段
                    leftDraw = new Polyline();
                    leftDraw.AddVertexAt(0, tdStart.ToPoint2d(), 0, 0, 0);
                    leftDraw.AddVertexAt(1, tdDrawL.ToPoint2d(), 0, 0, 0);
                    leftDraw.Layer = tdLine.Layer;//张拉段与钢束线应该在同一层
                    //标注左侧张拉段
                    lengthL = new MText();
                    //长度
                    lengthL.Contents = "工作长度" + workLen.ToString("F0");
                    //文字高度
                    lengthL.TextHeight = 3 * scale;
                    //样式为当前样式
                    lengthL.TextStyleId = db.Textstyle;
                    //旋转角度同直线段倾角
                    lengthL.Rotation = iclStart;
                    //对齐位置为右上
                    lengthL.Attachment = AttachmentPoint.TopRight;
                    //位置为中点垂线以下0.5个单位
                    lengthL.Location = GeTools.PolarPoint(GeTools.MidPoint(leftDraw.StartPoint,
                                                                           leftDraw.EndPoint), iclStart - Math.PI / 2, 0.5 * scale);
                }
                //5.2.2 右侧张拉时绘制P锚标识
                else
                {
                    //创建P锚起终点
                    Point3d tdDrawL1 = GeTools.PolarPoint(tdStart, iclStart + Math.PI / 2, 0.75 * scale);
                    Point3d tdDrawL2 = GeTools.PolarPoint(tdStart, iclStart + Math.PI / 2, -0.75 * scale);
                    //创建P锚标志
                    leftDraw = new Polyline();
                    leftDraw.AddVertexAt(0, tdDrawL1.ToPoint2d(), 0, 0.35 * scale, 0.35 * scale);
                    leftDraw.AddVertexAt(1, tdDrawL2.ToPoint2d(), 0, 0.35 * scale, 0.35 * scale);
                    leftDraw.Layer = tdLine.Layer;//张拉段与钢束线应该在同一层
                    //标注左侧P锚
                    lengthL = new MText();
                    //长度
                    lengthL.Contents = "P锚";
                    //文字高度
                    lengthL.TextHeight = 3 * scale;
                    //样式为当前样式
                    lengthL.TextStyleId = db.Textstyle;
                    //旋转角度同直线段倾角
                    lengthL.Rotation = iclStart;
                    //对齐位置为右中
                    lengthL.Attachment = AttachmentPoint.MiddleRight;
                    //位置为P锚标志右侧0.5个单位
                    lengthL.Location = GeTools.PolarPoint(GeTools.MidPoint(leftDraw.StartPoint,
                                                                           leftDraw.EndPoint), iclStart, -2 * scale);
                }
                //5.3 右侧张拉端绘制
                //5.3.1 两侧张拉或右侧张拉时右端绘制工作长度线
                if (tdDrawStyle == 0 || tdDrawStyle == 1)
                {
                    //创建张拉端几何点
                    Point3d tdDrawR = GeTools.PolarPoint(tdEnd, iclEnd, workLen);
                    //创建张拉段
                    rightDraw = new Polyline();
                    rightDraw.AddVertexAt(0, tdEnd.ToPoint2d(), 0, 0, 0);
                    rightDraw.AddVertexAt(1, tdDrawR.ToPoint2d(), 0, 0, 0);
                    rightDraw.Layer = tdLine.Layer;//张拉段与钢束线应该在同一层
                    //标注右侧张拉段
                    lengthR = new MText();
                    //长度
                    lengthR.Contents = "工作长度" + workLen.ToString("F0");
                    //文字高度
                    lengthR.TextHeight = 3 * scale;
                    //样式为当前样式
                    lengthR.TextStyleId = db.Textstyle;
                    //旋转角度同直线段倾角
                    lengthR.Rotation = iclEnd;
                    //对齐位置为左上
                    lengthR.Attachment = AttachmentPoint.TopLeft;
                    //位置为中点垂线以下0.5个单位
                    lengthR.Location = GeTools.PolarPoint(GeTools.MidPoint(rightDraw.StartPoint,
                                                                           rightDraw.EndPoint), iclEnd - Math.PI / 2, 0.5 * scale);
                }
                //5.2.2 左侧张拉时绘制P锚标识
                else//绘制P锚
                {
                    //创建P锚起终点
                    Point3d tdDrawR1 = GeTools.PolarPoint(tdEnd, iclEnd + Math.PI / 2, 0.75 * scale);
                    Point3d tdDrawR2 = GeTools.PolarPoint(tdEnd, iclEnd + Math.PI / 2, -0.75 * scale);
                    //创建P锚标志
                    rightDraw = new Polyline();
                    rightDraw.AddVertexAt(0, tdDrawR1.ToPoint2d(), 0, 0.35 * scale, 0.35 * scale);
                    rightDraw.AddVertexAt(1, tdDrawR2.ToPoint2d(), 0, 0.35 * scale, 0.35 * scale);
                    rightDraw.Layer = tdLine.Layer;//张拉段与钢束线应该在同一层
                    //标注左侧P锚
                    lengthR = new MText();
                    //长度
                    lengthR.Contents = "P锚";
                    //文字高度
                    lengthR.TextHeight = 3 * scale;
                    //样式为当前样式
                    lengthR.TextStyleId = db.Textstyle;
                    //旋转角度同直线段倾角
                    lengthR.Rotation = iclEnd;
                    //对齐位置为左中
                    lengthR.Attachment = AttachmentPoint.MiddleLeft;
                    //位置为P锚标志右侧0.5个单位
                    lengthR.Location = GeTools.PolarPoint(GeTools.MidPoint(rightDraw.StartPoint,
                                                                           rightDraw.EndPoint), iclEnd, 2 * scale);
                }
                #endregion
                #region 6 在截面顶缘标识“梁顶缘线”
                Point3d midPt     = GeTools.MidPoint(tpLine.StartPoint, tpLine.EndPoint);  //顶缘线起终点中点
                Point3d midPtInTp = tpLine.GetClosestPointTo(midPt, Vector3d.YAxis, true); //顶缘线上靠近中点的点
                MText   tpAnno    = new MText();
                tpAnno.Contents = "梁顶缘线";
                //文字高度
                tpAnno.TextHeight = 3 * scale;
                //样式为当前样式
                tpAnno.TextStyleId = db.Textstyle;
                //对齐位置为右上
                tpAnno.Attachment = AttachmentPoint.BottomLeft;
                //位置为中点以上0.5个单位
                tpAnno.Location = GeTools.PolarPoint(midPtInTp, Math.PI / 2, 0.5 * scale);
                #endregion
                db.AddToModelSpace(dims.ToArray());                        //添加各类标注
                db.AddToModelSpace(leftDraw, rightDraw, lengthL, lengthR); //添加张拉段线
                db.AddToModelSpace(tpAnno);                                //添加梁顶缘线标识
                trans.Commit();
            }
        }