Sunday, March 08, 2009

Moving from VBA to vb.NET

VBA appears to be on the way out, it's not even going to be shipping with the base AutoCAD 2010 product (but it will ship with Civil 3D 2010). There is some rumors that VSTA will be provided for AutoCAD 2010 sometime this year. I think it may be time to put VBA to down and pick up vb.NET.

The first thing that I need to do is get a separate program to work with. Microsoft provides a free version called Microsoft Visual Studio Express (VS), make sure to download the version if you go with this option. I'm going to spend some extra cash and get the full blown version. I've used both in the past and if you do program more than occasionally I've found the extra money for the full blown version can be worth it. You can try the full version for 90 days. I think you can also use other programs, but I'm not familiar with any of them.

The next step is setting up VS to program with it to work with Civil 3D. While we could spend all of the work setting it up to work with Civil 3D it's probably easier to use the sample that comes with Civil 3D. To do this open up the solution (.sln) file in the following folder:

C:\Program Files (x86)\AutoCAD Civil 3D 2009\Sample\Civil 3D API\VB_NET\VbDotNetClient

If your using Vista you may want to copy the VB_NET folder to a location that will let you freely modify the code.

Next Build, or compile, the code by going to the Build Menu and choose Build VBDotNetClientSample.


VS will create an EXE file in the bin folder for the project. Double click it and it will open a dialog box asking you what to do, press the Launch Autodesk Civil 3D and Civil 3D should start up.


Once Civil 3D starts up the Project Details button should become available. Pressing the Project Details provides the number of Point Groups and Surfaces in the drawing.


I don't know about you, but I usually don't have much reason to create program to open Civil 3D up. I find the icons on the desktop sufficient. I guess that the Developers figure if your using vb.NET you already know how to create a program that runs within the program.

In the next posts I'll go over some resources that have more examples on how to run the commands within Civil 3D and use them to bring the Toggle TIN Triangle Visibility code to vb.NET.

No comments:


Blog Widget by LinkWithin