.NET

Reply
Active Contributor
JasonSelf
Posts: 35
Registered: ‎08-30-2010
Message 1 of 9 (440 Views)
Accepted Solution

Functions not working when called from form

440 Views, 8 Replies
10-12-2010 10:10 AM

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.

 

Any ideas?

 

Thanks,

Jason

*Expert Elite*
chiefbraincloud
Posts: 752
Registered: ‎02-13-2008
Message 2 of 9 (434 Views)

Re: Functions not working when called from form

10-12-2010 10:41 AM in reply to: JasonSelf

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.

Dave O.                                                                  Sig-Logos32.png
Active Contributor
JasonSelf
Posts: 35
Registered: ‎08-30-2010
Message 3 of 9 (426 Views)

Re: Functions not working when called from form

10-12-2010 11:03 AM in reply to: chiefbraincloud

That did it.  Still much for me to learn :smileyhappy: thanks

Valued Mentor
stevenelliott3894
Posts: 474
Registered: ‎06-14-2010
Message 4 of 9 (341 Views)

Re: Functions not working when called from form

10-22-2010 06:31 AM in reply to: chiefbraincloud

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.

 

Steven Elliott

When I was a little bitty boy, my grandmother bought me a cute little toy. Silver bells hangin' on a string... she told me it was my ding-a-ling-a-ling!
Active Contributor
JasonSelf
Posts: 35
Registered: ‎08-30-2010
Message 5 of 9 (337 Views)

Re: Functions not working when called from form

10-22-2010 06:53 AM in reply to: stevenelliott3894

I feel you pain, I am in the same boat just a bit further upstream :smileyhappy:

 

I think the AutoCAD .Net Developer's Guide does a good job at explaining this:

http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer%27s%20Guide/index.html

If you type 'Lock Document' into the search it will be the first result.

 

Valued Mentor
stevenelliott3894
Posts: 474
Registered: ‎06-14-2010
Message 6 of 9 (334 Views)

Re: Functions not working when called from form

10-22-2010 07:14 AM in reply to: JasonSelf

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.

Steven Elliott

When I was a little bitty boy, my grandmother bought me a cute little toy. Silver bells hangin' on a string... she told me it was my ding-a-ling-a-ling!
Valued Mentor
Jeffrey_H
Posts: 372
Registered: ‎01-20-2010
Message 7 of 9 (329 Views)

Re: Functions not working when called from form

10-22-2010 08:29 AM in reply to: stevenelliott3894

Have a look at the arxdoc.chm

 

 

 

1350i488439DA21C6B39E

You can also find your answers @ TheSwamp
Active Contributor
JasonSelf
Posts: 35
Registered: ‎08-30-2010
Message 8 of 9 (325 Views)

Re: Functions not working when called from form

10-22-2010 08:55 AM in reply to: Jeffrey_H

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.

Valued Mentor
stevenelliott3894
Posts: 474
Registered: ‎06-14-2010
Message 9 of 9 (320 Views)

Re: Functions not working when called from form

10-22-2010 09:57 AM in reply to: JasonSelf

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.  :robottongue:

Steven Elliott

When I was a little bitty boy, my grandmother bought me a cute little toy. Silver bells hangin' on a string... she told me it was my ding-a-ling-a-ling!
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.