FitPoints Example

Using Programming Languages other than VBA

Sub Example_FitPoints()
   ' This example creates a Spline object in model space, reads the fit points
   ' of the Spline and then modifies the fit points of the Spline.

	Dim splineObj As AcadSpline
	Dim startTan(0 To 2) As Double, endTan(0 To 2) As Double
	Dim FPoints(0 To 8) As Double
	Dim UserMessage As String
	Dim fitPoints As Variant
	Dim iCount As Long, iPoint As Integer
	Dim NewFP(0 To 2) As Double

	' Define the Spline object
	startTan(0) = 0.5: startTan(1) = 0.5: startTan(2) = 0
	endTan(0) = 0.5: endTan(1) = 0.5: endTan(2) = 0
	FPoints(0) = 0: FPoints(1) = 0: FPoints(2) = 0
	FPoints(3) = 5:   FPoints(4) = 5: FPoints(5) = 0
	FPoints(6) = 10: FPoints(7) = 0: FPoints(8) = 0

	' Create new Spline object
	Set splineObj = ThisDrawing.ModelSpace.AddSpline(FPoints, startTan, endTan)
	ThisDrawing.Application.ZoomAll

	' Display fit points for this Spline
	GoSub DISPLAYPOINTS

	' Modify an existing fit point for this Spline
	fitPoints(0) = 3
	splineObj.fitPoints = fitPoints

	' Now add a new fit point
	NewFP(0) = 15: NewFP(1) = 4: NewFP(2) = 0
	splineObj.AddFitPoint splineObj.NumberOfFitPoints + 1, NewFP
	
	ThisDrawing.Application.ZoomAll
		
	' Display new fit points for this Spline
	GoSub DISPLAYPOINTS
	
	Exit Sub

DISPLAYPOINTS:
	fitPoints = splineObj.fitPoints

	' Display in groups of three
	UserMessage = ""
	iPoint = 0
	For iCount = 0 To UBound(fitPoints) Step 3
		iPoint = iPoint + 1
		UserMessage = UserMessage & iPoint & ")" & vbTab
		UserMessage = UserMessage & fitPoints(iCount)
		UserMessage = UserMessage & ", " & fitPoints(iCount + 1)
		UserMessage = UserMessage & ", " & fitPoints(iCount + 2)
		UserMessage = UserMessage & vbCrLf
	Next

	MsgBox "The " & splineObj.NumberOfFitPoints & " Spline fit points are: " & vbCrLf & vbCrLf & UserMessage

	Return
End Sub





   Comments?