Sub Ch2_AddLineVB()
On Error Resume Next
' Connect to the AutoCAD application
Dim acadApp As AcadApplication
Set acadApp = GetObject _
(, "AutoCAD.Application.18")
If Err Then
Err.Clear
Set acadApp = CreateObject _
("AutoCAD.Application.18")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
' Connect to the AutoCAD drawing
Dim acadDoc As AcadDocument
Set acadDoc = acadApp.ActiveDocument
' Establish the endpoints of the line
Dim lineObj As AcadLine
Dim startPoint(0 To 2) As Double
Dim endPoint(0 To 2) As Double
startPoint(0) = 1
startPoint(1) = 1
startPoint(2) = 0
endPoint(0) = 5
endPoint(1) = 5
endPoint(2) = 0
' Create a Line object in model space
Set lineObj = acadDoc.ModelSpace.AddLine _
(startPoint, endPoint)
ZoomAll
acadApp.visible = True
End Sub
Cette contribution était de : http://old.wdforge.org/newbb/viewtopic.php?forum=20&topic_id=6289&post_id=24955