Wednesday, September 01, 2010

Visualization Boundaries

One of the problems with doing visualizations is needing to mask out or hide the portion of the existing surface which is above the proposed surface. I’m working on a quick way to accomplish the task that doesn’t include manually extracting the surface border of the proposed surface and adding it to the existing surface. The code below is a start, it only works with one proposed surface boundary. Maybe if I get ambitious I’ll look at adding the ability to account for more than one boundary. The code does do multiple boundaries, but it doesn’t do it correctly in all cases.

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.Civil.Roadway.DatabaseServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports AeccLandLib = Autodesk.AECC.Interop.Land
Imports Autodesk.AECC.Interop.UiLand
Imports Quux.C3DUtilities
Imports Autodesk.AutoCAD.Interop.Common
Imports Autodesk.Civil.Land.DatabaseServices

<Assembly: CommandClass(GetType(UpdatePolylineMaskBoundary))>

Public Class UpdatePolylineMaskBoundary

<CommandMethod("C3DRUpdatePolylineMaskBoundary")> _
Public Sub UpdatePolylineMask()
Dim oUtil As New Utilities
Dim oType(0) As Type
0) = GetType(TinSurface)
Dim oSurfSourceObjId As ObjectId = oUtil.GetEntityWithOptions("Select Proposed Surface: ", "Not a surface", oType)
Dim oSurfExistObjId As ObjectId = oUtil.GetEntityWithOptions("Select Existing Surface: ", "Not a surface", oType)
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = db.TransactionManager
Using myT As Transaction = tm.StartTransaction

'Get Civil 3D application, document and database
Dim oCivil As New AeccAppConnection

Dim obj As Object = oCivil.AeccDoc.ObjectIdToObject(CType(oSurfSourceObjId.OldIdPtr, Long))

If TypeOf obj Is Autodesk.AECC.Interop.Land.AeccSurface Then
Dim oSurface As AeccLandLib.AeccSurface = obj
Dim oSurfExist As AeccLandLib.AeccSurface = oCivil.AeccDoc.ObjectIdToObject(CType(oSurfExistObjId.OldIdPtr, Long))
Dim objs() As Object = Nothing
= oSurface.ExtractBorder(Autodesk.AECC.Interop.Land.AeccDisplayOrientation.aeccDisplayOrientationPlan)
Dim i As Integer = 1
For Each obj In objs
Dim oBoundary As AcadEntity = obj
"C3DRBoundary-" & i, Autodesk.AECC.Interop.Land.AeccBoundaryType.aeccBoundaryHide, True, 0.1)
= +1

End If
End Using

Catch ex As Exception
Dim oUtil As New Utilities
"Error in UpdatePolylineMask Sub")
End Try
End Sub

End Class

The program utilizes other code contained in the free version of the Sincpac and the Civil 3D Reminders Pack.

No comments:


Blog Widget by LinkWithin