AutoCAD
Posted: Tue May 25, 2021 2:05 am
How can I do this with PureBasic?
I try to use COMatePLUS but unsuccessfully. Don't know how to transfer variable values (like the arrays for coordinates startPoint and endPoint).
Edit: Code tags added (Kiffi)
I try to use COMatePLUS but unsuccessfully. Don't know how to transfer variable values (like the arrays for coordinates startPoint and endPoint).
Code: Select all
Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument
Dim lineObj As AcadLine
Private Sub Command2_Click()
On Error Resume Next
Dim x As Long
Dim y As Long
Dim startPoint(0 To 2) As Double
Dim endPoint(0 To 2) As Double
' Connect to the AutoCAD drawing
Set acadDoc = acadApp.ActiveDocument
' Establish the endpoints of the line
startPoint(0) = 0
startPoint(1) = 0
startPoint(2) = 0
endPoint(0) = 50
endPoint(1) = 5
endPoint(2) = 0
ZoomWindow startPoint, endPoint
Label1.Caption = "Working..."
For x = 0 To 50
startPoint(0) = x
startPoint(1) = 0
startPoint(2) = 0
endPoint(0) = x + 5
endPoint(1) = 5
endPoint(2) = 0
' Create a Line object in model space
Set lineObj = acadDoc.ModelSpace.AddLine(startPoint, endPoint)
lineObj.Update
Next x
ZoomExtents
acadApp.Visible = True
Label1.Caption = "Done."
End Sub
Private Sub Form_Load()
On Error Resume Next
Set acadApp = GetObject(, "AutoCAD.Application.16")
If Err Then
Err.Clear
Set acadApp = CreateObject("AutoCAD.Application.16")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
End Sub