I'm not going to comment on this, other than to say that you need to learn how to structure your app, as it relates to acquiring user input, and accessing the database.
Generally, you acquire all user input before you access the database or its contents, where that's possible. Once you've obtained the needed input successfully, only then do you start a transaction
and open objects.
Read the ObjectARX docs, and note where they discuss the patterns relating to opening and closing objects, and how you should keep objects open only as long as absolutely necessary and close them as soon as possible.
What you definitely should not do is open an object for write, and then acquire input. The chances that AutoCAD or another application may try to open an object while getting user input (e.g., for things like object snap, etc.), are very good, and in that case, if an object or one of its owners is currently open for write, kaboom.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
wrote in message news:5792878@discussion.autodesk.com...
I'm struggling with this too:
Imports Autodesk.AutoCAD
'Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.ApplicationServices
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myTransMan As DatabaseServices.TransactionManager
Dim myTrans As DatabaseServices.Transaction
Dim myDWG As Document
Dim myBT As BlockTable
Dim myBTR As BlockTableRecord
Dim myCylinder As Cylinder
Dim StartPoint As Geometry.Point3d
Dim EndPoint As Geometry.Point3d
myDWG = Application.DocumentManager.MdiActiveDocument
myTransMan = myDWG.TransactionManager
myTrans = myTransMan.StartTransaction
'open database for read
myBT = myDWG.Database.BlockTableId.GetObject(OpenMode.ForRead)
'open ModelSpace for write
myBTR = myBT(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)
StartPoint = myDWG.Editor.GetPoint("Select Start Point: ").Value
EndPoint = myDWG.Editor.GetPoint("Select End Point: ").Value
'create the cylinder
myCylinder = New Cylinder(7.723, StartPoint, EndPoint)
'Add cylinder to Modelspaces block table record
myBTR.AppendEntity(myCylinder)
'Add cylinder to the transaction
myTrans.AddNewlyCreatedDBObject(myCylinder, True)
'commit transaction
myTrans.Commit()
'dispose transaction
myTrans.Dispose()
myTransMan.Dispose()
End Sub