Newbie question

Newbie question

david_sexton
Contributor Contributor
1,882 Views
3 Replies
Message 1 of 4

Newbie question

david_sexton
Contributor
Contributor
I'm starting the transition from VBA to VB .Net, so this is probably incredibly easy. I haven't even started writing my own code yet, just pasting snippets to get a feel for everything. I've put in a sub routine to draw a single line in model space of AutoCAD. Works great. The problem occurs when I create a form and try to call the sub routine from a button. Then I get an "eLockViolation" when I try to open the model space "for write". I'm guessing that it is because AutoCAD is no longer active because this form is active? If that makes any sense? But, even if I hide the form before I call the sub routine, I still get the error.

Any suggestions would be appreciated.

Thanks

Dave

See attachment for the code.
0 Likes
1,883 Views
3 Replies
Replies (3)
Message 2 of 4

arcticad
Advisor
Advisor
Dim myDWG As Document = ApplicationServices.Application.DocumentManager.MdiActiveDocument

Using lock As DocumentLock = myDWG.LockDocument
' do stuff
End Using
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 3 of 4

david_sexton
Contributor
Contributor
That did it!! Thanks!
0 Likes
Message 4 of 4

arcticad
Advisor
Advisor
Your Welcome
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes