GetPoint 方法
From AutoCAD ActiveX/VBA
GetPoint 方法提示用户在 AutoCAD 命令提示下给出点的定义。该方法接收两个参数:可选的起始点和提示字符串。如果提供了起始点,AutoCAD 将从该点绘制一条拖引线。要控制用户输入,可以在使用该方法之前先调用 InitializeUserInput 方法。
下面的样例提示用户输入两个点,然后以这两个点为起点和端点绘制一条直线。
Sub Ch3_GetPointsFromUser()
Dim startPnt As Variant
Dim endPnt As Variant
Dim prompt1 As String
Dim prompt2 As String
prompt1 = vbCrLf & "Enter the start point of the line: "prompt2 = vbCrLf & "Enter the end point of the line: "' 在不输入基点的情况下获取第一点startPnt = ThisDrawing.Utility.GetPoint(, prompt1)' 使用上面输入的点作为基点endPnt = ThisDrawing.Utility.GetPoint(startPnt, prompt2)' 使用输入的两个点创建一条直线ThisDrawing.ModelSpace.AddLine startPnt, endPntThisDrawing.Application.ZoomAllEnd Sub