我有这程序 代码如下: Sub xyz() Dim x As Double Dim y As Double Dim i Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.CreateTextFile("d:\查询结果.txt", True) i = 1 On Error Resume Next Dim keywordlist As String keywordlist = "o" nextreturnpnt: ThisDrawing.Utility.InitializeUserInput 128, keywordlist Dim returnpnt As Variant returnpnt = ThisDrawing.Utility.GetPoint(, "输入一个点[完成/(o)]:") If Err Then If StrComp(Err.Description, "用户输入的是关键字", 1) = 0 Then Dim inputstring As String Err.Clear inputstring = ThisDrawing.Utility.GetInput a.Close Exit Sub Else MsgBox "选择点时发生错误:" & Err.Description Err.Clear End If Else x = Format(Round(returnpnt(1), 4), "0.000") y = Format(Round(returnpnt(0), 4), "0.000") a.WriteLine (i & ",," & x & "," & y) i = i + 1 End If GoTo nextreturnpnt End Sub 在cad中运行上程序,结果保存在d:\查询结果.txt文件中,格式为:点号,X坐标,Y坐标 |