CurrentSpace vs. ModelSpace Question.....

CurrentSpace vs. ModelSpace Question.....

Anonymous
Not applicable
318 Views
1 Reply
Message 1 of 2

CurrentSpace vs. ModelSpace Question.....

Anonymous
Not applicable
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)
0 Likes
319 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
Caddie75,
Use db.currentspaceid in place of bt(BlockTableRecord.ModelSpace), I guess 🙂
0 Likes