Sparky,
In addition to what Bryco noted and MP suggests, here's an example of a few of the functions. Note that you do NOT need to do all of the hoop jumping when you use the CURVE.CLS.
In a Module:
'functions to find the midpoint, perpendicular point, and selected segment of a pline _
the mid & perp will work on ANY linear object (line, arc, spline, polyline) _
Authors are Jeff Mishler and Frank Oquendo, as noted
Option Explicit
Dim obj As Curve
'by Jeff Mishler
Function mid_Of(oEnt As AcadEntity) As Variant
Dim length As Double
Dim midPt As Variant
Set obj = New Curve
Set obj.Entity = oEnt
length = obj.length
midPt = obj.GetPointAtDistance(length / 2)
mid_Of = midPt
End Function
'by Jeff Mishler, based on the assumption (which is USUALLY correct) that the
'perpendicular point is the point on the object closest to the known point
Public Function PerpendicularTo(oEnt As AcadEntity, dPoint As Variant) As Variant
Dim perpPoint As Variant
Set obj = New Curve
Set obj.Entity = oEnt
perpPoint = obj.GetClosestPointTo(dPoint, True)
PerpendicularTo = perpPoint
End Function
'More code from Frank Oquendo
Public Function SelectedSegment(ent As AcadEntity, pt) As Integer
Dim dist As Double, i As Integer
Dim max As Integer, segment As Integer
Set obj = New Curve
Set obj.Entity = ent
dist = obj.GetDistanceAtPoint(obj.GetClosestPointTo(pt))
max = (UBound(ent.Coordinates) + 1) / 2
For i = 0 To max - 1
If obj.GetDistanceAtPoint(ent.Coordinate(i)) > dist Then Exit For
segment = segment + 1
Next
SelectedSegment = segment
End Function
'This is just a sample of how to use the mid & perp functions
Sub mid_perp_Sample()
Dim oEnt1 As AcadEntity
Dim oEnt2 As AcadEntity
Dim pick As Variant
Dim point1 As Variant
Dim point2 As Variant
ThisDrawing.Utility.GetEntity oEnt1, pick, vbCrLf & "Select entity to calc mid point of: "
ThisDrawing.Utility.GetEntity oEnt2, pick, vbCrLf & "Select entity to go perpendicular to: "
point1 = mid_Of(oEnt1)
point2 = PerpendicularTo(oEnt2, point1)
ThisDrawing.ModelSpace.AddLine point1, point2
End Sub
HTH