.NET

Reply
Contributor
Chumplybum
Posts: 25
Registered: ‎12-15-2003
Message 1 of 1 (159 Views)

ObjectDBX

159 Views, 0 Replies
04-25-2006 06:04 PM
hey, i'm just starting to write / convert code from vb6 to vb.net and i'm having some difficulty with ObjectDBX... i've had a look thru this discussion group and found an example, however, it didn't fit in with what i had already... i'm hoping someone can steer me in the right direction

Ok, first off... here is the code for a drawing open in the drawing editor, which seems to work fine:

Public Function Exists(ByVal sName As String) As Boolean

Dim db As Database = HostApplicationServices.WorkingDatabase
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Dim lt As LayerTable = trans.GetObject(db.LayerTableId, OpenMode.ForRead)
Dim ReturnValue As Boolean

If lt.Has(sName) Then
ReturnValue = True
Else
ReturnValue = False
End If

trans.Commit()
trans.Dispose()

Return ReturnValue

End Function


what i'm after is something that will handle both: drawings that are open in the editor and also via object dbx... so heres my attempt

Public Function Exists(ByVal sName As String, Optional ByVal bUseObjectDBX As Boolean = False, Optional ByVal sDrawingFilePathDBX As String = "") As Boolean

Dim ReturnValue As Boolean

If File.Exists(bUseObjectDBX) = False Then
Dim db As Database = HostApplicationServices.WorkingDatabase
Else
'check file exists
Dim db As Database = HostApplicationServices.WorkingDatabase
db.ReadDwgFile(HostApplicationServices.Current.FindFile(sDrawingFilePathDBX, Database.FromAcadDatabase(Application.DocumentManager.MdiActiveDocument), FindFileHint.Default), IO.FileShare.Read, True, "")
End If

Dim trans As Transaction = db.TransactionManager.StartTransaction()
Dim lt As LayerTable = trans.GetObject(db.LayerTableId, OpenMode.ForRead)

If lt.Has(sName) Then
ReturnValue = True
Else
ReturnValue = False
End If

trans.Commit()
trans.Dispose()

Return ReturnValue

End Function


the trouble i'm having is withing declaring / setting / assigning the database. Any help would be great

cheers

Mark
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.