/// <summary> /// 在图纸上画表格 /// </summary> /// <param name="paper">待画入的图纸</param> /// <returns></returns> internal bool DrawTableOnPaper(ref PaperLayout paper) { if (blocks[0].DrawMode == BeamBoxBlock.DrawingMode.AUTO) UnifyBlockLines(); BeamBoxBlock boxBlock = blocks[0]; DatabaseToAcad block = new DatabaseToAcad(boxBlock.DimScale); DatabaseToAcad blockTable = new DatabaseToAcad(boxBlock.DimScale); boxBlock.DrawGeneral(block); try { TxTable table = TxTable.CreateTable(1, 1); DatabaseToAcad tempDB; for (int i = 0; i < blocks.Count; i++) { TxTable temp; tempDB = new DatabaseToAcad(DimScale); //获取表格要求先虚绘一个图 blocks[i].DrawMode = BeamBoxBlock.DrawingMode.USER_CENTER; blocks[i].Draw(tempDB); blocks[i].GetParamTable(out temp); if (temp.ColumnCount > table.ColumnCount) table.tb.InsertColumns(table.ColumnCount, 1, temp.ColumnCount - table.ColumnCount); table.tb.InsertRows(table.RowCount, 1, 5); for (int j = 0; j < 5; j++) for (int k = 0; k < temp.ColumnCount - 1; k++) table.tb.Cells[table.RowCount - 5 + j, k].Value = temp.tb.Cells[j, k].Value; } table.tb.InsertRows(1, 1, 2); for (int i = 0; i < boxBlock.BoxCount; i++) { table.tb.Cells[1, 1].Value = "板编号"; table.tb.Cells[2, i + 1].Value = (i + 1).ToString(); } for (int i = boxBlock.BoxCount; i < table.ColumnCount - 1; i++) { table.tb.Cells[1, boxBlock.BoxCount + 1].Value = "湿接缝编号"; table.tb.Cells[2, i + 1].Value = (i - boxBlock.BoxCount + 1).ToString(); } table.tb.MergeCells(Autodesk.AutoCAD.DatabaseServices.CellRange.Create(table.tb, 1, 1, 1, boxBlock.BoxCount)); table.tb.MergeCells(Autodesk.AutoCAD.DatabaseServices.CellRange.Create(table.tb, 1, boxBlock.BoxCount + 1, 1, table.ColumnCount - 1)); table.tb.InsertColumns(0, 1, 1); table.tb.DeleteColumns(table.ColumnCount - 1, 1); blockTable.AddTable(table); table.tb.Cells[1, 0].Value = "桩号PL~PR"; for (int i = 0; i < blocks.Count; i++) { for (int j = 0; j < 5; j++) table.tb.Cells[i * 5 + j + 2, 0].Value = "P" + (i + 1).ToString() + "~P" + (i + 2).ToString(); table.tb.MergeCells(Autodesk.AutoCAD.DatabaseServices.CellRange.Create(table.tb, i * 5 + 3, 0, i * 5 + 7, 0)); } table.tb.Cells[1, 1].Value = "参数"; table.tb.Cells[0, 0].Value = "梁参数表"; table.tb.MergeCells(Autodesk.AutoCAD.DatabaseServices.CellRange.Create(table.tb, 1, 0, 2, 0)); table.tb.MergeCells(Autodesk.AutoCAD.DatabaseServices.CellRange.Create(table.tb, 1, 1, 2, 1)); table.tb.MergeCells(Autodesk.AutoCAD.DatabaseServices.CellRange.Create(table.tb, 0, 0, 0, table.ColumnCount - 1)); //修改表格样式 for (int i = 0; i < table.RowCount; i++) { table.tb.Rows[i].Height = 3 * DrawScale * DimScale; for (int j = 0; j < table.ColumnCount; j++) { table.tb.Cells[i, j].Alignment = Autodesk.AutoCAD.DatabaseServices.CellAlignment.MiddleCenter; table.tb.Cells[i, j].TextHeight = 2 * DrawScale * DimScale; } } table.tb.Columns[1].Width = 24 * DrawScale * DimScale; paper.AddBlock(block.ConvertToBlockBase()); paper.AddBlock(blockTable.ConvertToBlockBase()); paper.AutoLayoutBlock_OneRow(); return true; } catch { System.Windows.Forms.MessageBox.Show("绘图出错,请修改结构定义。" + "可能是结构边线是否合理。"); return false; } }