Hi John,
Here is a sample code that inserts a blockreference :
using AcadDB = Autodesk.AutoCAD.DatabaseServices;
using AcadRun = Autodesk.AutoCAD.Runtime;
using AcadGeom = Autodesk.AutoCAD.Geometry;
public void test()
{
string blockName = "MyBlock";
AcadDB.ObjectId blockId;
AcadDB.Database db = AcadDB.HostApplicationServices.WorkingDatabase;
AcadDB.Transaction trans = db.TransactionManager.StartTransaction();
AcadDB.BlockTable BT =
(AcadDB.BlockTable)trans.GetObject(db.BlockTableId,
AcadDB.OpenMode.ForRead);
foreach (AcadDB.ObjectId btrID in BT)
{
AcadDB.BlockTableRecord BTR =
(AcadDB.BlockTableRecord)trans.GetObject(btrID, AcadDB.OpenMode.ForRead);
if (BTR.Name.ToUpper() == blockName.ToUpper())
{
blockId = BTR.ObjectId;
AcadDB.BlockTableRecord modelSpaceRecord =
(AcadDB.BlockTableRecord)trans.GetObject(BT[AcadDB.BlockTableRecord.ModelSpace],
AcadDB.OpenMode.ForWrite);
AcadGeom.Point3d pt = new Autodesk.AutoCAD.Geometry.Point3d(4,4,0);
AcadDB.BlockReference blockRef = new
Autodesk.AutoCAD.DatabaseServices.BlockReference(pt, blockId);
modelSpaceRecord.AppendEntity(blockRef);
trans.AddNewlyCreatedDBObject(blockRef, true);
}
}
trans.Commit();
}
Cheers,
Tilz
wrote in message news:5090035@discussion.autodesk.com...
I'm writing an application that connects to an SQL database and displays
information much like design Center. One I get the records I need in a list
view I need to in insert a block related to that record. Can anybody help
me in inserting a block in to a drawing using managed DotNet code.