Hi,
Is the block defintion (BlockTableRecord) annotative ?
Here's a little snippet working for me.
If the block definition doesn't already exist in the drawing block table, it is created, and made annotative. Then the block is inserted at specified point according to the current annotative scale.
Code:
[CommandMethod("Test")]
public void Test()
{
Document doc = AcAp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForWrite);
// if the block table doesn't already contain the block definition, create it
if (!bt.Has("foo"))
{
BlockTableRecord btr = new BlockTableRecord();
btr.Name = "foo";
// make the block annotative
btr.Annotative = AnnotativeStates.True;
bt.Add(btr);
tr.AddNewlyCreatedDBObject(btr, true);
// add some entities to the block definition
Circle c = new Circle(Point3d.Origin, Vector3d.ZAxis, 1.0);
btr.AppendEntity(c);
tr.AddNewlyCreatedDBObject(c, true);
Line l = new Line(new Point3d(-1.2, 0.0, 0.0), new Point3d(1.2, 0.0, 0.0));
btr.AppendEntity(l);
tr.AddNewlyCreatedDBObject(l, true);
}
// insert the block in the current space
PromptPointResult ppr = ed.GetPoint("\nInsertion point: ");
if (ppr.Status != PromptStatus.OK)
return;
BlockTableRecord space =
(BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
ObjectContextCollection occ =
db.ObjectContextManager.GetContextCollection("ACDB_ANNOTATIONSCALES");
Matrix3d ucs = ed.CurrentUserCoordinateSystem;
Point3d pt = ppr.Value;
BlockReference br = new BlockReference(pt, bt["foo"]);
br.TransformBy(ucs);
br.AddContext(occ.CurrentContext);
space.AppendEntity(br);
tr.AddNewlyCreatedDBObject(br, true);
tr.Commit();
}
}