Ad

Saturday, February 21, 2009

Toggle TIN Triangle Visibility

I've been working on surfaces lately, hence the series of Parking Lot Surface posts from last week. I've noticed the need to turn on and off triangles for a surface, either by changing the surface style or changing the style of the surface to show triangles, quite often. It takes about 3 or 4 steps to change it. I thought that was about 2 to 3 clicks too many so I decided to create a VBA routine to cut those steps down.

The first thing to do is create a new VBA file from the VBAMAN dialog box.

image

Once created press the SaveAs button and save it to a location of your choosing. Next open the Visual Basic Editor and a new module from the Insert Menu and set the references for the Civil 3D Land Modules.

Next add Option Explicit and name the Sub what you want it to be.

image

Next we need to create some variables and prompt the user to select a surface object.

image

Now that we have the surface we need to make sure the user selected a surface.

image

If the user selected a surface we need to set the surface equal to a surface type variable and then check to see if the triangles are showing. If they are the code will turn them off, and if they are showing the code will turn them off.

image

So now just add some error catching to it, maybe an "On Error Resume Next" at the top of the macro or have the user try again at selecting a surface. So that's how I'm going to be toggling the tin triangles for a Surface Style while doing surface design.

9 comments:

Anonymous said...

:) :) :) :)

Many thanks.

John Mayo

Wes Ashworth said...

I'm a total nonprogramer. How do i set "option, explicit"? also I have a couple of vba routines running and they are all jumbled in the vbaman viewport.

I've been wanting a routine such as this for a long time, though.
Thanks!
Wes

Wes Ashworth said...

How do you set the "option/explicit"?. Also, I have a couple of other VBA routines autoloaded so it's all a jumble in VBAMAN.

Wes Ashworth said...

OK, Obviously I know nothing about programing. Apparently I just type it out and it seems OK, but when i debug, it tells me there is no aeccsurface. No aec... variables are available. Help?

Anonymous said...

For civil3d release 2008 it is
a bit different:

Sub SurfaceTriangleToggle(oSurf)
'Turn visible Triangles on or off for a surface.
'For civil3d release 2008'
If oSurf.ObjectName = "AeccDbSurfaceTin" Then
If oSurf.Style.TriangleStyle.DisplayStyle2d.Visible = True Then
oSurf.Style.TriangleStyle.DisplayStyle2d.Visible = False
Else
oSurf.Style.TriangleStyle.DisplayStyle2d.Visible = True
End If
End If
End Sub

Anonymous said...

For previous releases, it is
a bit different.

Sub SurfaceTriangleToggle(oSurf)
'Turn visible Triangles on or off for a surface.
'For civil3d release 2008'
If oSurf.ObjectName = "AeccDbSurfaceTin" Then
If oSurf.Style.TriangleStyle.DisplayStyle2d.Visible = True Then
oSurf.Style.TriangleStyle.DisplayStyle2d.Visible = False
Else
oSurf.Style.TriangleStyle.DisplayStyle2d.Visible = True
End If
End If
End Sub

Bob-Bo said...

How bout for civil 3d 2012?

Christopher Fugitt said...

How about lunch in exchange for the updating of the command?

Christopher Fugitt said...

Actually it's in the Civil 3D Reminders Pack 2012.

LinkWithin

Blog Widget by LinkWithin

Ad