c# - AutoCAD 表格中的字体非常小

标签 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
}
}

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

最佳答案

想通了。原来 SetTextHeight 的第二个参数很重要。数字 1-7 根据行类型设置不同的单元格。要设置标题、数据和标题类型的行的高度,我需要使用

设置文本高度(1, 7)

关于c# - AutoCAD 表格中的字体非常小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26407545/

相关文章:

c# - 无法建立 SSL 连接,请参阅内部异常

c# - Convert.ToString(...) 或 Object.ToString() 提高性能

.net - T4:在 Visual Studio 和 MSBuild 中使用属性

c# - 鼠标下带有缩略图的 CAD 插入 block

delphi - 在 Delphi 应用程序中查看 Autocad 绘图

android - 我们有什么解决方案可以在 Android 上读取和显示 Autocad DWG 文件?

c# - 从比屏幕高的控件绘制位图

c# - 构造函数注入(inject)和默认重载

c# - 加快在 WPF 中将对象添加到 Canvas

c# - .NET Web 服务引用生成的类不适用于 dateTime 类型