The GetPoint method prompts the user for the specification of a point at the AutoCAD Command prompt.
This method accepts two parameters, an optional from point and the prompt string. If the from point is provided, AutoCAD draws a rubber-band line from that point. To control the user input, this method can be preceded by a call to the InitializeUserInput method.
The following example prompts the user for two points, then draws a line using those points as the start point and endpoint.
(vl-load-com)
(defun c:Ch3_GetPointsFromUser()
(setq acadObj (vlax-get-acad-object)
doc (vla-get-ActiveDocument acadObj)
moSpace (vla-get-ModelSpace doc)
utilityObj (vla-get-Utility doc))
(setq prompt1 "\nSpecify start point of line: "
prompt2 "\nSpecify end point of line: ")
;; Get the first point without entering a base point
(setq startPnt (vla-GetPoint utilityObj nil prompt1))
;; Use the point entered above as the base point
(setq endPnt (vla-GetPoint utilityObj startPnt prompt2))
;; Create a line using the two points entered
(vla-AddLine moSpace startPnt endPnt)
(vla-ZoomAll acadObj)
)
Sub Ch3_GetPointsFromUser() Dim startPnt As Variant Dim endPnt As Variant Dim prompt1 As String Dim prompt2 As String prompt1 = vbCrLf & "Specify start point of line: " prompt2 = vbCrLf & "Specify end point of line: " ' Get the first point without entering a base point startPnt = ThisDrawing.Utility.GetPoint(, prompt1) ' Use the point entered above as the base point endPnt = ThisDrawing.Utility.GetPoint(startPnt, prompt2) ' Create a line using the two points entered ThisDrawing.ModelSpace.AddLine startPnt, endPnt ThisDrawing.Application.ZoomAll End Sub