Sunday, 20 March 2011

Opening and running the shipped Civil3d 2011 VB.net samples with VB Express 2008

There are a number of vb.net samples shipped and installed with Civil3d 2011 in the following directory.

<installation-directory>\Sample\Civil 3D API\DotNet\VB.NET\

These samples are a good place to start to see:-
1. How a vb.net project is written.
2. What happens when you build a project.
3. Practice stepping thru code watching what is happening and debugging it.

If you are using VB Express version like me then there are a number of things you have to do to get the shipped samples up and running.

Here is what I had to do to get the pipe sample up and running with VB Express 2008 and Civil3d 2011.

1. Copy the whole pipe sample file from
C:\Program Files\Autodesk\AutoCAD Civil 3D 2011\Sample\Civil 3D API\DotNet\VB.NET\PipeSample

to a new location to work with that you have full read and write access too.

2. Open VBExpress 2008 and goto File->Open Project Open browser to the sample file location and select the PipeSample.vbproj file.
3. On opening the file you will see alot of errors this is because the references need updated to you local ones.
1_001
Goto references by selecting the project name right click and select properties and then the references tab. You will see the references the program can not find highlighted in yellow below.
2

3
All of these references files are in the the program install directory click add goto the browser tab and browse to the program install directory and find them again. Make sure copy local is set to false.
5
4. Now if you insert a break point and press the green play button. You get an error

Tip turn on the line numbering in VB Express so that you can quickly find the lines with errors and easily communicate with other people which line of code you are talking about.7
This error in fact
6
5. This error is generated because you can not set the default program to be associated with the VBexpress .dll you have created with VB express to be launched and used during debugging.
6.To get around this issue you have to add a couple of lines to the PipeSample.vbproj file to allow VB Express to launch Civil3d during debugging so you can step thru the .dll file to see what is going on. Open the file and find the line highlighted in blue and add the lines highlighted in yellow.
2011-03-19_0008
For a more complete explanation of the process please refer to the DevTV video VBA_migration at the 28 minute mark onwards. 

7. Now go back to VB Express and press the green play button. The .dll file should build and Civil3d 2011 should be launched.
8. Once Civil3d has finished loading type the “netload” command and browse to the complied .dll file usually found in the following location

<ProjectFile>/bin/Debug/<Programfile>.dll

9. Now the .dll file is loaded into memory you have access to all the custom commands in the .dll file such as the command “Pipesample”.
10. Type the command “Pipesample”  and the custom command will start and immediately jump into the code in the .dll file at the position you inserted a break point at in step 4.
11. Now you can step thru the lines of the code in the .dll file by pressing the F8 button and you will be able to see what the code is doing. If you want to see what data is stored in a particular variable hold the mouse over the name of the variable and a pop box will come up displaying its current value.
Good luck with your coding.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...