Public Sub zoomtotextandload(ByVal text As String, hndl As Int64)
'what if *.dwg is corrupt -try catch
'Try
If System.IO.File.Exists(text) Then
If Application.DocumentManager.CurrentDocument IsNot Nothing Then
Dim edbefore As Editor = Application.DocumentManager.MdiActiveDocument.Editor
If edbefore.Document.CommandInProgress.Length > 0 Then
edbefore.WriteMessage("Another command active")
Exit Sub
End If
If edbefore.IsDragging Then
edbefore.WriteMessage("Another command active")
Exit Sub
End If
End If
Dim doc As Document = Nothing
For Each d As Document In Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
If d.Name = text Then
doc = d
Exit For
End If
Next
If doc = Nothing Then doc = DocumentCollectionExtension.Open(Application.DocumentManager, text, False)
Application.DocumentManager.MdiActiveDocument = doc
'now we have open dwg and will try to find object
Dim ed As Editor = doc.Editor
Dim db As Database = doc.Database
Dim hn As Handle = New Handle(hndl)
Dim oid2 As ObjectId
If db.TryGetObjectId(hn, oid2) Then
If oid2.IsResident = True And Not oid2.IsErased Then
Dim tmp1 As New List(Of ObjectId)
tmp1.Add(oid2)
openLayoutAndViewport(oid2)
ZoomObjects(tmp1)
End If
End If
End If
'Catch ex As Exception
'End Try
End Sub