This is along the same lines of the last post that I had about problems with ReadDwgFile, but I am encountering an unexpected behaviour.
When I run a sub that uses ReadDwgFile where the Command method calls it directly it works fine, but if I instantiate that class into the sub for a form button and then call that same sub that has ReadDwgFile in it, it doesn't work.
Solved! Go to Solution.
Almost all (maybe all) problems I've seen relating to running code from forms (modal or modeless) are caused by not locking the document. Where to put the document lock depends somewhat on how your code is arranged.
What is all this about 'locking the document'? I'm trying to learn this ridiculously complicated .Net API and I need to run from a form. Any help appreciated.
I feel you pain, I am in the same boat just a bit further upstream
I think the AutoCAD .Net Developer's Guide does a good job at explaining this:
If you type 'Lock Document' into the search it will be the first result.
Thanks! I had just come across this before your post came in.
It's really hard to believe that AutoDesk considers this setup a suitable replacement for VBA. Considering that, for most of us, I'd bet, customizing AutoCad is a sideline to our normal job, this takes an inordinate amount of time to learn. It is nowhere near as intuitive as VBA was.
Technically you can still download and install the VBA runtime for autocad, so you are not completely at a loss. I decided to just go with the flow and start learning the .net API instead of relying on the COM/Interop stuff from VBA. I rewrote soemthing that I had developed in VBA to .net code and it is much faster and plays nicer with some memory intensive fucntions.
Thanks for the help, guys.
Yes, I understand that programming in .Net is vastly more powerful than VBA. But VBA did what we needed it to do and was infinitely easier to use. With great power comes great... pain.
I can't just stick with VBA, because I need my application needs to continue working in AutoCAD 2012 and beyond, something I can't do with VBA. And our IT dept. has said that there is no way in heck they are allowing me to use VB6 (VBA's big brother) anymore. So, it is definitely VB.Net or Lisp. I'll take the less painful and more marketable route with .Net.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register