Doesnt work:( no error message, no inserted block, I call this method with:
CreateBlock(dataSet.Tables[0].Rows[intRadek]["sloupec"].ToString(), new Autodesk.AutoCAD.Geometry.Point3d(x, 0, 0));
private acadDb.ObjectId CreateBlock(string nameOfBlock, Autodesk.AutoCAD.Geometry.Point3d pos)
{
// get the current working database
acadDb.Database db = acadDb.HostApplicationServices.WorkingDatabase;
using (acadDb.Transaction trans = db.TransactionManager.StartTransaction())
{
acadDb.BlockTable bt = (acadDb.BlockTable)(trans.GetObject(db.BlockTableId, acadDb.OpenMode.ForWrite));
acadDb.BlockTableRecord btr = (acadDb.BlockTableRecord)trans.GetObject(bt[nameOfBlock], acadDb.OpenMode.ForWrite);
// Create the block reference...use the return from CreateEmployeeDefinition directly!
//acadDb.BlockReference br = new acadDb.BlockReference(pos, bt[nameOfBlock]);
acadDb.BlockReference br = new acadDb.BlockReference(pos, btr.ObjectId);
// Add the reference to ModelSpace
btr.AppendEntity(br);
// Add the attribute reference to the block reference
trans.AddNewlyCreatedDBObject(br, true);
acadDb.ObjectId retId = br.ObjectId;
trans.Commit();
return retId;
}
}