the standard equation for a parabola with Directrix horizontal and Vertex at the origin is

The Directrix and Focus are both specified as p distance from the vertex (0,0). A positive p value draws a parabola open up, a negative value open down.

The Autocad VBA AcadPoint is drawn at the focus, and AcadLine at the directrix. Both take the same type location array of 3 doubles (x,y,z). The point object is theoretically dimensionless. It takes two variables that control its visibility style and size, PDMODE and PDSIZE.

Sub draw_focus(X1 As Double, Y1 As Double) Dim pointobj As AcadPoint Call newlayer("Focus", 5, acLnWt035) acadDoc.SetVariable "PDMODE", 35 acadDoc.SetVariable "PDSIZE", -4 Dim pt1(0 To 2) As Double pt1(0) = X1: pt1(1) = Y1: pt1(2) = 0 Set pointobj = acadDoc.ModelSpace.AddPoint(pt1) pointobj.Layer = "Focus" End Sub Sub draw_directrix(X1 As Double, Y1 As Double, X2 As Double, Y2 As Double) Dim lineobj As AcadLine Call newlayer("Directrix", 5, acLnWt035) Dim pt1(0 To 2) As Double Dim pt2(0 To 2) As Double pt1(0) = X1: pt1(1) = Y1: pt1(2) = 0 pt2(0) = X2: pt2(1) = Y2: pt2(2) = 0 Set lineobj = acadDoc.ModelSpace.AddLine(pt1, pt2) lineobj.Layer = "Directrix" End Sub

The parabola as function with one and only one value for X is our standard VBA loop and structure. The form button calls its dedicated sub, which takes the values from the form, specifies the function to calculate Y, then calls the sub loop passing the function name.

Sub draw_pr03() 'Horiz Directrix Call init_parabola funcname = "PR_03" A = frm_parabola.txt_a3.Value strLabel = "X^2 = 4 * " & A & " * Y" Call draw_parabola(funcname) Call draw_focus(0, A) Call draw_directrix(Xmin, -A, Xmax, -A) acadApp.Update End Sub Function PR_03(X As Double) As Double 'Y = X^2 / 4P PR_03 = (X ^ 2) / (4 * A) End Function Sub init_parabola() Call connect_acad Xmin = frm_parabola.txt_xmin Xmax = frm_parabola.txt_xmax X_inc = frm_parabola.txt_xinc A = 0 B = 0 C = 0 End Sub Sub draw_parabola(funcname As String) Dim X As Double, Y As Double Dim plineobj As AcadLWPolyline Dim pt() As Double Dim i As Integer, numpts As Integer numpts = (Xmax - Xmin) / X_inc 'number of line segments numpts = numpts + 1 'one more pt than line segment ReDim pt(1 To numpts * 2) 'store x and y for one pt For i = 1 To numpts X = Xmin + ((i - 1) * X_inc) Y = Application.Run(funcname, X) pt(i * 2 - 1) = X: pt(i * 2) = Y Next i Set plineobj = acadDoc.ModelSpace.AddLightWeightPolyline(pt) Update If frm_parabola.chk_box_label_graph = True Then label_graph End If End Sub

The parabola with vertical directrix has standard equation

This is the same equation for both orientations but with X and Y transposed (switched). A standard rotation around the origin swaps values (X, Y) -> (Y,-X) , so that (2,1) when rotated clockwise, the graph viewed on its side, becomes (1, -2)

In this case with vertex at origin and rotation about origin, whether we rotate or just swap values, it may not matter. If we were producing point tables, which we will, we might be more aware of which end is the beginning of the curve. Our program increments X values from negative starting point to positive ending point. But it is convention to start with X horizontal. We could build a Y loop passing values that would look exactly the same. Or we can just swap values as the last step in the process.

When we make a more general parabola program and move the vertex off the origin, the curve is then rotated about the vertex, not the origin, and the kludge of just swapping x and y in existing programming will become more convoluted and even more of a kludge.

The function is the same input / output formula, so we don’t need to change that. Our loop where we write the values into the array that feeds the acad polyline is the only change to turn the standard parabola on its side.

Sub draw_pr04() 'Vert Directrix Call init_parabola A = frm_parabola.txt_a4.Value strLabel = "Y^2 = 4 * " & A & " * X" funcname = "PR_03" 'transpose x and y Call draw_parabola_yx(funcname) Call draw_focus(A, 0) Call draw_directrix(-A, -Xmin, -A, -Xmax) acadApp.Update End Sub Sub draw_parabola_yx(funcname As String) 'for horizontal axis of symmetry Dim X As Double, Y As Double Dim plineobj As AcadLWPolyline Dim pt() As Double Dim i As Integer, numpts As Integer numpts = (Xmax - Xmin) / X_inc 'number of line segments numpts = numpts + 1 'one more pt than line segment ReDim pt(1 To numpts * 2) 'store x and y for one pt For i = 1 To numpts X = Xmin + ((i - 1) * X_inc) Y = Application.Run(funcname, X) '(x,y) -> (y,x) transpose, not rotate pt(i * 2 - 1) = Y: pt(i * 2) = X Next i Set plineobj = acadDoc.ModelSpace.AddLightWeightPolyline(pt) Update If frm_parabola.chk_box_label_graph = True Then label_graph End If End Sub