putting the curve drawing loop inside another loop.

Sub testparabola3()
Call connect_acad
Call parabola3(-2, 2, 3, 0.1)
End Sub
Sub parabola3(min_x As Double, max_x As Double, n2 As Integer, x_inc As Double)
'y = x^n
Dim x As Double, y As Double
Dim i As Integer, n As Integer
Dim plineobj As AcadLWPolyline
Dim pt() As Double
Dim numpts As Integer
numpts = (max_x - min_x) / x_inc 'this is the number of line segments
numpts = numpts + 1 'there is always one more pt than line segment
ReDim pt(1 To numpts * 2) 'to store both x and y for one pt
For n = 1 To n2
For i = 1 To numpts
x = min_x + ((i - 1) * x_inc)
'when i = 1 then x = min_x
y = x ^ n
pt(i * 2 - 1) = x: pt(i * 2) = y
'for each numpts there is an x and y pt(index)
Next i
Set plineobj = acadApp.ActiveDocument.ModelSpace.AddLightWeightPolyline(pt)
Next n
ZoomAll
End Sub

### Like this:

Like Loading...

*Related*