How do I draw a spline?

How do I draw a spline?

Anonymous
Not applicable
476 Views
2 Replies
Message 1 of 3

How do I draw a spline?

Anonymous
Not applicable

Im really sorry, Im sure this has been answered elsewhere but Ive been trying and searching for days for a solution. My problem is as follows:

 

Ive created four lines and want to spline the end points. Heres my code:

 

Public Sub CommandButton4_Click()

Dim pt1 As Variant
Dim pt2 As Variant
Dim pt3 As Variant
Dim pt4 As Variant
Dim pt5 As Variant


pi = 3.14159265358979
myform.Hide

pt1 = ThisDrawing.Utility.GetPoint(, "click tree position")
pt2 = ThisDrawing.Utility.PolarPoint(pt1, pi / 2, Val(TextBox3.Text * 1000))
pt3 = ThisDrawing.Utility.PolarPoint(pt1, 0, Val(TextBox4.Text * 1000))
pt4 = ThisDrawing.Utility.PolarPoint(pt1, pi / -2, Val(TextBox5.Text * 1000))
pt5 = ThisDrawing.Utility.PolarPoint(pt1, pi / 1, Val(TextBox6.Text * 1000))



ThisDrawing.ModelSpace.AddLine pt1, pt2
ThisDrawing.ModelSpace.AddLine pt1, pt3
ThisDrawing.ModelSpace.AddLine pt1, pt4
ThisDrawing.ModelSpace.AddLine pt1, pt5

        Dim splineObj As AcadSpline
        Dim startTan As Double
        Dim endTan As Double
        Dim fitPoints(0 To 2) As Double

        ' Define the variables
        startTan = 0
        endTan = 0
        fitPoints(0) = pt1: fitPoints(1) = pt2: fitPoints(2) = pt3


        ' Create the spline
        splineObj = ThisDrawing.ModelSpace.AddSpline(fitPoints, startTan, endTan)
  Debug.Print (splineObj.Degree)
        Debug.Print (splineObj.NumberOfControlPoints)

End Sub

 

 

I get a runtime error - this should be straight forward.. and yes Im new to this, but any help would be appreciated.

 

Thanks

Jonny

0 Likes
477 Views
2 Replies
Replies (2)
Message 2 of 3

truss_85
Advocate
Advocate

assign like that

 

Dim fitPoints(0 To 8) As Double

fitPoints(0) = pt1(0): fitPoints(1) = pt1(1):fitPoints(2) = pt1(2)
fitPoints(3) = pt2(0): fitPoints(4) = pt2(1):fitPoints(5) = pt2(2)
fitPoints(6) = pt3(0): fitPoints(7) = pt3(1):fitPoints(8) = pt3(2)

 

0 Likes
Message 3 of 3

Hallex
Advisor
Advisor
Another possible problem is to define start and end tangents,
use instead
Dim startTan(0 to 2) as double
because of this is a vector not a digit
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes