eLockViolation while using ReadDwgFile on database object

eLockViolation while using ReadDwgFile on database object

Anonymous
Not applicable
1,483 Views
1 Reply
Message 1 of 2

eLockViolation while using ReadDwgFile on database object

Anonymous
Not applicable

I used the code below last night on files local to the computer, and everything worked fine. This morning, i tried it and network files and it throws an error on the ReadDwgFile line saying "Cannot convert eLockViolation to integer". I then tried it on local files as well, and I also get this error. Any help would be appreciated.

 

 

Public Shared Sub BatchBlock(ByVal fileName As String, ByVal blockName As String, ByVal reportFile As String)
        If Not System.IO.File.Exists(fileName) Then
            Return
        End If

        Dim db As New Database(False, False)

        Try
            db.ReadDwgFile(fileName, System.IO.FileShare.ReadWrite, True, "")
        Catch ex As Exception
            db.Dispose()
            Throw New Exception(CType(ex.Message, ErrorStatus))
        End Try

 

 

0 Likes
1,484 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

After another 10 minutes of searching on these forums, the lovely new search feature decided to show me what I wanted...

 

I guess somehow this is affected by document locking. I wrapped all of the code with:

 

Using lock As DocumentLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument

 

End Using

 

This seems to make it work. But if anyone can explain to me why I need to lock the current document if all I'm doing is reading an external file into a database variable. If i tried to modify the active document I could understand having to lock it, but I'm not.

0 Likes