View Full Version : Draw Lines
ctlo123
16-11-2004, 02:06 AM
I am a newbie in VBA and am looking for code to draw lines by picking points on screen. Any comments?
Eddie
16-11-2004, 02:22 AM
when you say picking points are refering to selecting node (actual point objects) ?
ctlo123
16-11-2004, 05:10 AM
Sorry, I have not said clearly. What I meant is pick any location on the screen display or input known coordinates.
Thanks
hendie
16-11-2004, 09:22 AM
this is straight from the Autocad help files ~ a very good reference if you care to browse through it
Sub Example_GetPoint()
' This example returns a point entered by the user.
Dim returnPnt As Variant
' Return a point using a prompt
returnPnt = ThisDrawing.Utility.GetPoint(, "Enter a point: ")
MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2) & vbCrLf & _
"(Enter the next value without prompting.)", , "GetPoint Example"
' Return a point, no prompt
returnPnt = ThisDrawing.Utility.GetPoint
MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2), , "GetPoint Example"
' Return a point using a base point and a prompt
Dim basePnt(0 To 2) As Double
basePnt(0) = 2#: basePnt(1) = 2#: basePnt(2) = 0#
returnPnt = ThisDrawing.Utility.GetPoint(basePnt, "Enter a point: ")
MsgBox "The WCS of the point is: " & returnPnt(0) & ", " & returnPnt(1) & ", " & returnPnt(2)
' Create a line from the base point and the last point entered
Dim lineObj As AcadLine
Set lineObj = ThisDrawing.ModelSpace.AddLine(basePnt, returnPnt)
ZoomAll
End Sub
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.