title="Mixing the Transaction Model with the Open and Close Mechanism ">Mixing
the Transaction Model with the Open and Close Mechanism
title="Mixing the Transaction Model with the Open and Close Mechanism ">The
transaction model coexists with the regular open and close mechanism described
in
href="mk:@MSITStore:C:\Documents%20and%20Settings\Administrator\Desktop\docs\arxdev.chm::/arxdev051...chapter
5,
href="mk:@MSITStore:C:\Documents%20and%20Settings\Administrator\Desktop\docs\arxdev.chm::/arxdev05....
However, if you are using the transaction model, it is recommended
that you do not mix it with the open and close mechanism. For example, if you
obtained a pointer to an object using
class=courier>AcTransaction::getObject(), you should
not call
close() on
the object pointer, which could cause unexpected results and may crash AutoCAD.
However, you are free to open and close a particular object even if transactions
are active. You can also instantiate new objects, add them to the database, and
close them while transactions are active. The primary purpose of having the
mixed model is to allow simultaneous execution of multiple applications where
some use transaction management and others do not, but all of them are operating
on the same objects.
title="Mixing the Transaction Model with the Open and Close Mechanism ">
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face=Verdana size=2>What really happens sometimes is that ACAD clugs and crashes
if I do not issue implicit Close() of an object. Here's a simple piece of code
utilizing above stated mechanism (sticking to DevGuide directives):
title="Mixing the Transaction Model with the Open and Close Mechanism ">
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New">Dim db
As Database =
Application.DocumentManager.MdiActiveDocument.Database()
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New">Dim trm
As
Autodesk.AutoCAD.DatabaseServices.TransactionManager =
db.TransactionManager
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New">Dim tr
As Transaction =
trm.StartTransaction
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New">Dim bt
As BlockTable =
tr.GetObject(db.BlockTableId, OpenMode.ForRead)
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New" size=2>
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New" color=#0000ff size=2>Try
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New"> For
size=2> Each ob
As ObjectId
color=#0000ff size=2>In bt
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New">
Dim btr As
size=2> BlockTableRecord = tr.GetObject(ob,
OpenMode.ForRead)
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New">
color=#0000ff> If UCase(btr.Name) = btr.ModelSpace
Then
title="Mixing the Transaction Model with the Open and Close Mechanism ">
color=#0000ff>
size=2>
color=#008080>'Inspect some ModelSpace properties...
title="Mixing the Transaction Model with the Open and Close Mechanism ">
size=2>
color=#0000ff> End
color=#0000ff>If
title="Mixing the Transaction Model with the Open and Close Mechanism ">
color=#0000ff>
face="Courier New" size=2>Next
title="Mixing the Transaction Model with the Open and Close Mechanism ">
size=2>
color=#0000ff>Finally
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New" size=2>
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New" size=2> bt.Dispose()
tr.Dispose()
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New" size=2> trm.Dispose()
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New" size=2>
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New" color=#0000ff size=2>
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face="Courier New" color=#000000 size=2>
db.Dispose()
End Try
title="Mixing the Transaction Model with the Open and Close Mechanism ">
color=#0000ff>
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face=Verdana>Thanks in advance for any suggestion or clarification.
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face=Verdana>
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face=Verdana>Regards,
title="Mixing the Transaction Model with the Open and Close Mechanism ">
face=Verdana>Maksim Sestic