Ad

Monday, March 09, 2009

vb.NET Adding a Class

In this post I'm going to try to add a Class to the VBDotNetClientSample from the last post. To add the Class right click on the project heading in Solution Explorer and choose Add and Class.

image

image

Next I need to add Acdbmgd.dll and Acmgd.dll to the project's References.

image

image 

Next we need to set up the various items needed to run code with vb.NET. There is a lot of extra things that need to be done usually done with Imports.

image

Now we can copy the code from the VBA Toggle TIN code.

image

The underlined items indicate errors in the code. Clicking the underlined words the Visual Studio (VS) gives you options on how to correct the code. In this case I'm choosing the option that the arrow is pointing to.

image

ThisDrawing doesn't have any suggestions. To get what it should be download the ObjectARX from the Autodesk website and then open the sample code provided for getting user input.

image

The sample code is in a C# file, you may need to download the Microsoft Visual Studio version for C# to open it up. The file name and location is \ObjectARX\samples\dotNet\Prompts\prompts.cs Since we are using the GetEntity do a search for it using Ctrl+F. Select the code and go to a site that will convert C# code to vb.NET. One site may be found here. As you can see below the code has grown quite a bit from the VBA version. I've commented out the code I haven't updated yet.

image

To comment out the code you can select the code and then use a button from a Toolbar in VS.

image 

Next change the Application type to Class Library. This will change the output from VS to a .dll file from an .exe.

image

Now I can compile the code and try it out in Civil 3D. The command to load the application is Netload and the typing TIN runs the program how it is currently created. I'm not sure if this will work, but you can download the dll and see if it works.

In the next post I'll try to finish the code. As you can see doing programming in vb.NET is a bit more complicated than using VBA.

No comments:

LinkWithin

Blog Widget by LinkWithin

Ad