// CodeHimBelongaKdub
// [kdub 2009-09-08 12:37]
[CommandMethod("DOIT10")]
public static void Test_QueueForGraphicsFlush()
{
// Get the current document and database
Document doc = AcadApp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
// Create a reference to the
// Autodesk.AutoCAD.DatabaseServices Transaction Manager
AcDb.TransactionManager trMan = db.TransactionManager;
// Start a transaction
using (Transaction tr = trMan.StartTransaction())
{
// Open the Block table for read
BlockTable bt;
bt = tr.GetObject(db.BlockTableId,
OpenMode.ForRead) as BlockTable;
// Open the Block table record Model space for write
BlockTableRecord btr;
btr = tr.GetObject(bt[BlockTableRecord.ModelSpace],
OpenMode.ForWrite) as BlockTableRecord;
// Create a line that starts at 50,50 and ends at 100,75
Line acLine1
= new Line
(new Point3d
(50,
50,
0),
new Point3d
(100,
75,
0));
acLine1.SetDatabaseDefaults();
// Add the new object to the block table record and the transaction
btr.AppendEntity(acLine1);
tr.AddNewlyCreatedDBObject(acLine1, true);
// This line does the trick ...
// Shows the graphics inside the transaction.
// could use tr.TransactionManager.QueueForGraphicsFlush()
//
trMan.QueueForGraphicsFlush();
// Getpoint
PromptPointResult pPtRes;
PromptPointOptions pPtOpts
= new PromptPointOptions
("");
// Prompt for point
pPtOpts.Message = "\nEnter the start point of a New line: ";
pPtRes = doc.Editor.GetPoint(pPtOpts);
Point3d ptStart = pPtRes.Value;
//>>
// stuff happens here ....
//<<
// Save the new objects to the database
tr.Commit();
}
}