public void TestTrans() { try { //System.Windows.Forms.MessageBox.Show(string.Format(CultureInfo.InvariantCulture, "_test = {0}", _test)); //_test = 0; _AcDb.Database db = _AcAp.Application.DocumentManager.MdiActiveDocument.Database; _AcDb.TransactionManager dbTrans = db.TransactionManager; using (_AcDb.Transaction trans = dbTrans.StartTransaction()) { // create a line _AcDb.Line ln = new _AcDb.Line(new _AcGe.Point3d(0.0, 0.0, 0.0), new _AcGe.Point3d(1.0, 1.0, 0.0)); _AcDb.BlockTable bt = dbTrans.GetObject(db.BlockTableId, _AcDb.OpenMode.ForRead, false) as _AcDb.BlockTable; if (bt == null) { return; } //ObjectId id = bt[BlockTableRecord.ModelSpace]; _AcDb.BlockTableRecord btr = dbTrans.GetObject(bt[_AcDb.BlockTableRecord.ModelSpace], _AcDb.OpenMode.ForWrite, false) as _AcDb.BlockTableRecord; if (btr == null) { return; } //Add it to the model space block table record. btr.AppendEntity(ln); //Make sure that the transaction knows about this new object. tm.AddNewlyCreatedDBObject(line, True) dbTrans.AddNewlyCreatedDBObject(ln, true); //'Add some hyperlinks. Dim hyper As New HyperLink() hyper.Name = "www.autodesk.com" line.Hyperlinks.Add(hyper) _AcDb.HyperLink hyper = new _AcDb.HyperLink(); hyper.Name = "www.facebook.com"; ln.Hyperlinks.Add(hyper); if (ln.Hyperlinks.Contains(hyper)) { hyper.Name = "www.gotdotnet.com"; } ln.Hyperlinks.Add(hyper); foreach (var hl in ln.Hyperlinks) { System.Diagnostics.Debug.WriteLine(hl.ToString()); } trans.Commit(); } } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message); } }