关于请求积分 (ActiveX)
该方法在 AutoCAD 命令提示符下提示用户指定点。GetPoint
此方法接受两个参数,可选的 from point 和提示字符串。如果提供了起始点,AutoCAD 将从该点绘制一条橡皮筋线。若要控制用户输入,可以在此方法之前调用该方法。InitializeUserInput
获取用户选择的点
下面的示例提示用户输入两个点,然后使用这些点作为起点和终结点绘制一条线。
- AutoLISP
-
(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)
)
- VBA(仅限 AutoCAD)
-
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
|