cad画表格(C#)
用C#画表格。我知道有个DataTable,但具体怎么用没弄明白,也许我的问题很简单,但真的弄不明白,希望各位大神指点,谢谢。命名 张拉方式 张拉应力 钢束型号
1 2 3 3
a b c d
22 32 3 23
类似这样的表格,谢谢了,我写了一个程序,运行后没反应,希望各位大侠给指点下:
public void createTable()
{
Autodesk.AutoCAD.DatabaseServices.DataTable dt = new Autodesk.AutoCAD.DatabaseServices.DataTable();
dt.TableName = "GSTable";
dt.AppendColumn(CellType.CharPtr, "命名");
dt.AppendColumn(CellType.CharPtr, "张拉方式");
dt.AppendColumn(CellType.CharPtr, "张拉应力");
dt.AppendColumn(CellType.CharPtr, "钢束型号");
DataCellCollection Row = new DataCellCollection();
DataCell a = new DataCell();
DataCell b = new DataCell();
DataCell c = new DataCell();
DataCell d = new DataCell();
a.SetString("A");
b.SetString("B");
c.SetString("C");
d.SetString("D");
Row.Add(a);
Row.Add(b);
Row.Add(c);
Row.Add(d);
dt.AppendRow(Row, true);
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Polyline pl = new Polyline();
using (Transaction tran = db.TransactionManager.StartTransaction())
{
DBDictionary extensionDic = tran.GetObject(db.NamedObjectsDictionaryId,OpenMode.ForWrite) as DBDictionary;
extensionDic.SetAt("GSTable", dt);
tran.AddNewlyCreatedDBObject(dt, true);
tran.Commit();
}
}
是不是我问的太简单了,没人回答啊 Autocad中有AcDbTable
页:
[1]