while trivial, the equation of a line, y = mx + b is the starting point

Option Explicit
Sub testline()
Call connect_acad
Call eq_line1(-6, 6, 1, 1)
Call eq_line2(-6, 6, 2, 2)
Call eq_line3(-6, 6, 3, 3)
End Sub
'*************
Sub eq_line1(x1 As Double, x2 As Double, m As Double, b As Double)
'y=mx + b
Dim lineobj As AcadLine
Dim y1 As Double, y2 As Double
Dim pt1(0 To 2) As Double
Dim pt2(0 To 2) As Double
y1 = m * x1 + b
y2 = m * x2 + b
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)
'RetVal = object.AddLine(StartPoint, EndPoint)
' object is type Block, Modelspace, PaperSpace
' draw points are a three element array of doubles
ZoomAll
End Sub
'**************
Sub eq_line2(x1 As Double, x2 As Double, m As Double, b As Double)
Dim plineobj As AcadLWPolyline
Dim y1 As Double, y2 As Double
Dim pt() As Double
ReDim pt(1 To 4)
y1 = m * x1 + b
y2 = m * x2 + b
pt(1) = x1: pt(2) = y1
pt(3) = x2: pt(4) = y2
Set plineobj = acadDoc.ModelSpace.AddLightWeightPolyline(pt)
'RetVal = object.AddLightWeightPolyline(VerticesList)
' object is type Block, Modelspace, PaperSpace
' the point list is an array of doubles, a list of xy pairs
'the array size is always a multiple of 2
ZoomAll
End Sub
'****************
Sub eq_line3(x1 As Double, x2 As Double, m As Double, b As Double)
Dim plineobj As AcadPolyline
Dim y1 As Double, y2 As Double
Dim pt() As Double
ReDim pt(1 To 6)
y1 = m * x1 + b
y2 = m * x2 + b
pt(1) = x1: pt(2) = y1: pt(3) = 0
pt(4) = x2: pt(5) = y2: pt(6) = 0
Set plineobj = acadDoc.ModelSpace.AddPolyline(pt)
'RetVal = object.AddPolyline(VerticesList)
' object is type Block, Modelspace, PaperSpace
' the point list is an array of doubles, a list of xyz values
'the array size is always a multiple of 3
ZoomAll
End Sub

### Like this:

Like Loading...

*Related*