Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I just want to open the drawings database and add objects to it then save and close the database.
The code I have is getting the drawings database, it appears to be commiting the objects, but the objects are not there when I open the drawing.
dbPath is a string path to an exisiting drawing file and I do
myDB.Dispose() the drawing database at the end of the code.
Is it even possible to add objects to a drawing without actually opening it?
Using myDB As Database = New Database(False, False) myDB.ReadDwgFile(dbPath, FileOpenMode.OpenForReadAndWriteNoShare, True, "") Dim vptLL As Point3d = New Point3d(0, 0, 0) Dim vptUL As Point3d = New Point3d(vptLL.X, 12, 0) Dim vptUR As Point3d = New Point3d(12, vptUL.Y, 0) Dim vptLR As Point3d = New Point3d(vptUR.X, vptLL.Y, 0) Dim ptcoll As New Point3dCollection ptcoll.Add(vptLL) ptcoll.Add(vptLR) ptcoll.Add(vptUR) ptcoll.Add(vptUL) ' draw a rectangle on a no-plot layer ("defpoints") as a guide to the users for manual panel placement ' set "defpoints" layer current Dim acLyrTbl As LayerTable Dim acLyrTblRec As LayerTableRecord ' start transaction Using acTrans As Transaction = myDB.TransactionManager.StartTransaction() acLyrTbl = acTrans.GetObject(myDB.LayerTableId, OpenMode.ForRead) acLyrTblRec = acTrans.GetObject(acLyrTbl("0"), OpenMode.ForWrite) ' thaw layer acLyrTblRec.IsFrozen = False ' turn layer on acLyrTblRec.IsOff = False 'make layer current myDB.Clayer = acLyrTbl("0") '' Open the Block table record Model space for write Dim acBlkTbl As BlockTable Dim acBlkTblRec As BlockTableRecord acBlkTbl = acTrans.GetObject(myDB.BlockTableId, OpenMode.ForRead) acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite) Dim whoa As Integer whoa = 1 Do Until whoa = 50 ' draw the rectangle Dim rect As New DatabaseServices.Polyline2d(Poly2dType.SimplePoly, ptcoll, 0, True, 0, 0, Nothing) '' Add the new object to Model space and the transaction acBlkTblRec.AppendEntity(rect) acTrans.AddNewlyCreatedDBObject(rect, True) whoa = whoa + 1 Loop ' Commit the changes acTrans.Commit() End Using End Using
Solved! Go to Solution.