关于Teigha表格应用
大家好,我看了看帖子,好像有关于Teigha的介绍,现在是这个情况,写了几段代码测试,发现画其他诸如线条、文字之类的都可以,但是制作表格的时候出错,具体是在database.SaveAs时候报的:Teigha.Runtime.Exception: Null object Id代码如下:大侠们帮我看看呢,不知道哪里的问题
using (Services svcs = new Services())
{
Database db = new Database();
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt, OpenMode.ForWrite);
Teigha.DatabaseServices.Table tb = new Teigha.DatabaseServices.Table();
double fontWeight = 5;
double rowHeight = 10;
tb.NumRows = 3;
tb.NumColumns = 6;
tb.Position = new Point3d(0, 0, 0);
tb.SetAlignment(1, 5, CellAlignment.MiddleCenter);
tb.SetTextString(1, 5, "备注1");
tb.SetAlignment(2, 1, CellAlignment.MiddleCenter);
tb.SetTextString(2, 1, "备注2");
tb.SetAlignment(2, 2, CellAlignment.MiddleCenter);
tb.SetTextString(2, 2, "备注3");
tb.SetAlignment(2, 3, CellAlignment.MiddleCenter);
tb.SetTextString(2, 3, "备注4");
tb.SetAlignment(2, 4, CellAlignment.MiddleCenter);
tb.SetTextString(2, 4, "备注5");
ObjectId tbID = btr.AppendEntity(tb);
trans.AddNewlyCreatedDBObject(tb, true);
trans.Commit();
}
db.SaveAs("D:\\test.dwg", DwgVersion.Current);//此行报错:Teigha.Runtime.Exception: Null object Id
}
应该是有属性没设置? 或者teigha的库不完善? 搞不清楚唉,试过很多办法了
页:
[1]