Community
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<FletchMan> wrote in messageI've
href="news:6137198@discussion.autodesk.com">news:6137198@discussion.autodesk.com...
included the starting routine in this post. It won't give a lot of details
about what the routine is doing but illustrates how the transactions and
blocktable are being handled. Thanks for all your help, Tony. {code} public
void Create() { this.DeleteLog(); if (this.CopyMDBFile()) {
this.AddRegAppTableRecord(); this.trans =
this.dwgDB.TransactionManager.StartTransaction(); // Open the block table.
BlockTable bt = null; try { // Make sure a bold text style has been created
when needed. if (AppPrefs.HasBoldText &&
!this.DwgHasTextStyle(Constants.DataBox.BoldStyleName)) {
this.ed.WriteMessage("A bold textstyle must be defined."); this.trans.Abort();
} else { this.AddDataboxLayers(); this.InsertPointBlock();
this.FindCurrentPointBlocks(); // Get the list of well IDs. List
wellIDs = DataManager.GetUniqueValues(AppPrefs.DataSourceName,
AppPrefs.TableName, AppPrefs.TitleField); if (wellIDs.Count > 0) {
this.insertedBlocks = new List(wellIDs.Count); bt =
(BlockTable)this.trans.GetObject(this.dwgDB.BlockTableId, OpenMode.ForWrite);
DataBox currDataBox = new DataBox(this.dbLayers, this.trans, bt); //
Initialize and display the status form. StatusForm statusForm = new
StatusForm(); statusForm.TotalDataboxes = wellIDs.Count;
Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(statusForm);
// Create a databox for each well ID. foreach (string wellID in wellIDs) {
System.Windows.Forms.Application.DoEvents(); if (!statusForm.StopRequested) {
// Update the status form. statusForm.CurrDataboxID = wellID; // Initialize
the DataBox class. currDataBox.WellID = wellID; // Track the blocks that have
been inserted. this.insertedBlocks.Add(currDataBox.BlockName); // Create the
databox in AutoCAD. currDataBox.Draw();
this.InsertDataBoxPointBlock(currDataBox, bt); } else { break; } } if
(!statusForm.StopRequested) { // After all of the databoxes have been created,
check to see if // there are any leftover databoxes from a previous running of
// this routine and remove them. this.DeleteOrphans(bt); // Successful run of
databox creation, commit the transactions. this.trans.Commit(); // Zoom the
current view to the extents of the drawing.
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.SendStringToExecute("zoom
e\n", true, false, false); } else { this.trans.Abort(); } // Close the status
form. statusForm.Close(); } else { this.ed.WriteMessage("No IDs found for
specified title field."); this.trans.Abort(); } } } catch
(Autodesk.AutoCAD.Runtime.Exception aex) { this.ed.WriteMessage("AutoCAD
error: " + aex.Message); this.trans.Abort(); } catch (System.Exception ex) {
this.ed.WriteMessage("Error: " + ex.Message); this.trans.Abort(); } finally {
if (bt != null) { bt.Dispose(); } this.trans.Dispose(); } // Delete the copied
.mdb file. this.DeleteMDBFile(); } } {code}
Can't find what you're looking for? Ask the community or share your knowledge.