Nick Gilbert
Nick Gilbert

Reputation: 4240

Really small font in AutoCAD table

I'm trying to make a table that dynamically adds rows as users submit more data:

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

However what ends up happening is that the titles of the columns which are added when the table is created are formatted correctly (Center-aligned, good size font) but everything added after has really small font size. How do I make it so that the font size is the same with each entry added?

Upvotes: 2

Views: 1251

Answers (1)

Nick Gilbert
Nick Gilbert

Reputation: 4240

Figured it out. Turns out SetTextHeight's second parameter matters. The numbers 1-7 set different cells depending on their row type. To set the height of rows of type title, data, and header I needed to use

SetTextHeight(1, 7)

Upvotes: 1

Related Questions