PDA

View Full Version : Updating VBa Code to .Net



tatchley
2005-12-14, 04:44 AM
I have some VBa code I'd like to port to .Net, but I'm lost as to how to make it work.

Here's the VBa code


Private Sub AcadDocument_BeginCommand(ByVal CommandName As String)
Call MySub
End Sub

I can ge the program to open AutoCAD, but it does not call MySub whenever I start a new command.

Any assistance, link, or hint would be appreciated.

I'm using Visual Studio 2002, and AutoCAD 2004.

dmarcotte4
2005-12-14, 12:33 PM
you need to use the command method

<Autodesk.AutoCAD.Runtime.CommandMethod("myCommand")>
Public Sub RunMyCommand()
your code
End Sub

I dont think .net apps run on 2004 though

Daniel

tatchley
2005-12-15, 05:24 AM
you need to use the command method

<Autodesk.AutoCAD.Runtime.CommandMethod("myCommand")>
Public Sub RunMyCommand()
your code
End Sub

I dont think .net apps run on 2004 though

Daniel

Daniel,

Kudos for the assist. Actually my .net app is running quite happily with 2004.

Thanks again. I'll change my subject line to RESOLVED!

vlee
2007-05-03, 02:21 PM
How did you load the .NET app in 2004? I am developing my first C# .NET app for cad but it need to run in 2004 and netload is not an option for 04. Your assistance is greatly appreciated.

Vito

Bobby C. Jones
2007-05-24, 02:34 AM
How did you load the .NET app in 2004? I am developing my first C# .NET app for cad but it need to run in 2004 and netload is not an option for 04. Your assistance is greatly appreciated.

Vito
Vito,
The only way to use .NET with versions prior to 2005 is via COM Interop.

vlee
2007-05-24, 01:35 PM
Hi Bobby,

BTW, learned a lot from your C# class in AU last year, hope you will be doing more classes on C# this year.

I am very new to the whole .NET scene, I am a LISPer so I am having a hard time absorbing some of the information. So if I compile the application into a dll, how would I load it using the COM Interop.

Thanks for your help.

Vito

Bobby C. Jones
2007-05-25, 01:06 AM
Hi Bobby,

BTW, learned a lot from your C# class in AU last year, hope you will be doing more classes on C# this year.

I am very new to the whole .NET scene, I am a LISPer so I am having a hard time absorbing some of the information. So if I compile the application into a dll, how would I load it using the COM Interop.

Thanks for your help.

VitoHi Vito,
I'm glad that you enjoyed the class. I always enjoy doing them. I learn something new every year! I will most likely be at AU this year, doing another class if I'm lucky :-)

My very first AU class back in 2003 was on this very topic. You can get the handout right here on AUGI.

http://www.augi.com/education/auhandouts.asp

Look for "AutoCAD Automation with C#". If I remember correctly there are some extraneous files in the download, but you can sort through them and find the handout. Let me know if it helps.