Ad

Monday, March 16, 2009

vb.Net Toggle TIN Triangle Visibility

In the last post I added a class to the project, in this post I'll finish the code.

The first thing that needs to be done is to make sure Civil 3D is running and get the Civil 3D objects. To do this I downloaded the dataset from this AU class. Since the AU class was done in Autocad 2008 I had to change the references to Civil 3D 2009. I also add the lines of code that called the class that was used from the AU class.

image

image

Now that we are sure Civil 3D is running and I have the Civil 3D document I can convert it to something that Civil 3D can modify/use.

image

So now that it’s been converted, I can see if the object is a surface object. You’ll notice the line of code is a tad bit more complicated than what it was in VBA. If it is then I’ll create a new surface variable and set the variable equal to the object selected.

image

So now that we know that the object is a surface I can toggle the TIN Triangle visibility, the same way that it was done in VBA.

image

So now that we made the change we need to commit the changes back to the drawings database. This is an important part of the code because if you don’t the changes won’t be reflected in the drawing. The line of code is highlighted below. Also I added an Else statement to notify the user if they didn’t select a surface.

image

Also note that the End Using line was added and this ends the use of the object. So now the code has been translated from VBA to vb.net. It’s a bit more complicated than VBA, but does have some advantages. One advantage (while not really applicable for this example) is the speed at which the code should work. It’s also a bit easier for the user to use since the code gives the command to use, in this case TIN. No need to add the command to the CUI. The completed dll file can be downloaded here. To run it type netload at the command line and select the file. Then type TIN at the command line to run the program. It will only run in Civil 3D 2009, so if you want it in another version you’ll either need to do the coding for your version yourself or making a compelling argument on why I should do it for you.

1 comment:

Network Management Service said...

Thanks for sharing useful blog.

LinkWithin

Blog Widget by LinkWithin

Ad