>> acadDB.Dispose()
You might want to browse this newsgroup and
read some of the posts dealing with the subject
of disposing of things like databases that you
didn't create.
There's no harm in doing it because the managed
runtime is smart enough to catch the mistake,
and not allow it to do any damage. However, that
doesn't make it any less of a mistake.
There's a lot of confusion about what you are,
and are not suposed to dispose of, so the mstake
is fairly common and that's what seems to lead
others to believe its the right way to do things.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
wrote in message news:5639010@discussion.autodesk.com...
This might work for your purposes. I also have my own utility classes with plenty of code in them for common purposes (the most often used by me are different kinds of selection, adding entities to the database, working with blocks and attributes, getting input from the user, and transformations) so if there's a project to get a well formed library I'll be happy to contribute. It's all in VB by the way.
Dim lstLayerNames As New List(Of String)
Dim acadDB As Database = HostApplicationServices.WorkingDatabase
Dim acadTrans As Transaction = acadDB.TransactionManager.StartTransaction
Dim ltLayerTable As LayerTable = CType(acadTrans.GetObject(acadDB.LayerTableId, OpenMode.ForRead), LayerTable)
Dim ltrLayerRecord As LayerTableRecord
For Each id As ObjectId In ltLayerTable
ltrLayerRecord = CType(acadTrans.GetObject(id, OpenMode.ForRead), LayerTableRecord)
lstLayerNames.Add(ltrLayerRecord.Name)
Next
acadTrans.Commit()
acadTrans.Dispose()
acadDB.Dispose()
Return lstLayerNames