AutoCAD表格中的字体非常小

时间:2014-10-16 14:57:09

标签: c# .net autocad

我正在尝试创建一个在用户提交更多数据时动态添加行的表:

public void addRow(String[] data)
{
Transaction tr = doc.TransactionManager.StartTransaction();
DocumentLock docLock = doc.LockDocument();
using (tr)
using (docLock)
{
if (!IsWriteEnabled || !IsReadEnabled) //Committing transactions closes everything for reading and writing so it must be reopened
{
tr.GetObject(this.ObjectId, OpenMode.ForRead);
tr.GetObject(this.ObjectId, OpenMode.ForWrite);
}
if (!data[0].Equals("Mark")) //If the data being added is not the titles of the columns
{
SetSize(NumRows + 1, NumColumns);
}

BlockTable bt = (BlockTable)tr.GetObject(doc.Database.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[Autodesk.AutoCAD.DatabaseServices.BlockTableRecord.ModelSpace], OpenMode.ForWrite);
selectedRow = NumRows - 1; //Sets the lowest empty row as the one to be modified
//Adding data to each cell
for (int i = 0; i < data.Length; i++)
{
Cells[selectedRow, i].SetValue(data[i], ParseOption.SetDefaultFormat);
}
GenerateLayout();
//Attempting to add table into drawing. If table already exists and is just being updated the catch statement will realize this and move on
try
{
btr.AppendEntity(this);
tr.AddNewlyCreatedDBObject(this, true);
}
catch (Autodesk.AutoCAD.Runtime.Exception e)
{
SetRowHeight(3); //Sets height of new row
SetColumnWidth(8); //Sets width of new columns
Cells.TextHeight = 1; //Sets height of new text
}

tr.Commit(); //Updating table
}
}

然而最终发生的事情是,创建表时添加的列的标题格式正确(中心对齐,大小合适的字体),但之后添加的所有内容都具有非常小的字体大小。如何使每个条目添加的字体大小相同?

1 个答案:

答案 0 :(得分:1)

想出来。结果显示SetTextHeight的第二个参数很重要。数字1-7根据行类型设置不同的单元格。要设置标题,数据和标题类型的行高,我需要使用

SetTextHeight(1,7)