Tuesday, September 08, 2009

VBA IntersectPointWithSurface

In the Civil 3D API it is possible to find an intersection with a surface at a point. To use the method uses a start point and a direction from the point. The direction is a vector. The key to using the code, which took me a while to figure out, is to create an array of doubles, give them the values and then assign the arrays to a variant.

        Dim vStartPoint As Variant
Dim vDirection As Variant
Dim vIntPoint As Variant
Dim dStartPoint(0 To 2) As Double
Dim dDirection(0 To 2) As Double

dStartPoint(0) = 2500: dStartPoint(1) = 2500: dStartPoint(2) = 305
dDirection(0) = 0.6: dDirection(1) = 0.4: dDirection(2) = -0.5

vStartPoint = dStartPoint
vDirection = dDirection

vIntPoint = oSurface.IntersectPointWithSurface(vStartPoint, vDirection)

The code then returns a point on the surface where the direction intersects the surface.

No comments:


Blog Widget by LinkWithin