Message 1 of 2
CurrentSpace vs. ModelSpace Question.....

Not applicable
04-03-2007
11:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi there all,
A Question:
In the AutoCAD sample about VB.NET they use the following:
-------------------->
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim tm As DBTransMan = db.TransactionManager
'start a transaction
Dim ta As Transaction = tm.StartTransaction
Try
Dim bt As BlockTable = tm.GetObject(db.BlockTableId, OpenMode.ForRead, False)
Dim btr As BlockTableRecord = tm.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite, False)
Circid = btr.AppendEntity(pcirc)
tm.AddNewlyCreatedDBObject(pcirc, True)
ta.Commit()
Finally
ta.Dispose()
End Try
<----------------------------------
This adds a Circle to the ModelSpace....but what if we want to use the space the user is in...??
I Use:
-------------------------------->
Using db As Database = HostApplicationServices.WorkingDatabase
Using tm As DatabaseServices.TransactionManager = db.TransactionManager
Using tr As Transaction = tm.StartTransaction
Dim BlockPointObject As New DBPoint
BlockPointObject.Position = BlockPoint
Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite, False), BlockTableRecord)
btr.AppendEntity(BlockPointObject)
tr.AddNewlyCreatedDBObject(BlockPointObject, True)
ReturnHandle = BlockPointObject.Handle.ToString
tr.Commit()
End Using
End Using
End Using
<----------------------------------
I'm just wondering if my approach is "Correct".
Also is it wise to use "Using"..?
Any Comments?
A Caddie.
(AutoCAD 2008, VS2005, Windows XP sp2)
A Question:
In the AutoCAD sample about VB.NET they use the following:
-------------------->
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim tm As DBTransMan = db.TransactionManager
'start a transaction
Dim ta As Transaction = tm.StartTransaction
Try
Dim bt As BlockTable = tm.GetObject(db.BlockTableId, OpenMode.ForRead, False)
Dim btr As BlockTableRecord = tm.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite, False)
Circid = btr.AppendEntity(pcirc)
tm.AddNewlyCreatedDBObject(pcirc, True)
ta.Commit()
Finally
ta.Dispose()
End Try
<----------------------------------
This adds a Circle to the ModelSpace....but what if we want to use the space the user is in...??
I Use:
-------------------------------->
Using db As Database = HostApplicationServices.WorkingDatabase
Using tm As DatabaseServices.TransactionManager = db.TransactionManager
Using tr As Transaction = tm.StartTransaction
Dim BlockPointObject As New DBPoint
BlockPointObject.Position = BlockPoint
Dim btr As BlockTableRecord = CType(tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite, False), BlockTableRecord)
btr.AppendEntity(BlockPointObject)
tr.AddNewlyCreatedDBObject(BlockPointObject, True)
ReturnHandle = BlockPointObject.Handle.ToString
tr.Commit()
End Using
End Using
End Using
<----------------------------------
I'm just wondering if my approach is "Correct".
Also is it wise to use "Using"..?
Any Comments?
A Caddie.
(AutoCAD 2008, VS2005, Windows XP sp2)