Public Function OPEN_DATABASE(dwgFileName As String) As Database
Dim db As Database = Nothing
Dim acadHost As New DwgHost
Try
db = New Database
Catch ex As Exception
Return Nothing
End Try
HostApplicationServices.WorkingDatabase = db
Try
db.ReadDwgFile(dwgFileName, IO.FileShare.ReadWrite, False, Nothing)
Return db
Catch ex As System.Exception
MsgBox("Не могу прочесть данные из файла " & dwgFileName & vbCr & ex.Message)
db.Dispose()
Return Nothing
End Try
End Function
Public Class DwgHost
Inherits HostApplicationServices
Public Sub New()
RuntimeSystem.Initialize(Me, 1033)
End Sub
Protected Overrides Sub Finalize()
RuntimeSystem.Terminate()
MyBase.Finalize()
End Sub
Public Overrides Function FindFile(fileName As String, _
database As CAD_DBS.Database, _
hint As CAD_DBS.FindFileHint) As String
Return ""
End Function
End Class