你可以先创建一个记事本。先把坐标导入记事本在导入excel Dim us3 As Integer '左下角Y坐标 us1 = ThisDrawing.GetVariable("userr1") us2 = ThisDrawing.GetVariable("userr2") us3 = ThisDrawing.GetVariable("userr3") 'Dim pnt_cord(0 To 1) As Double Dim sset As AcadSelectionSet Dim i As Integer For i = 0 To ThisDrawing.SelectionSets.Count - 1 ThisDrawing.SelectionSets.Item(i).Clear ThisDrawing.SelectionSets.Item(i).Delete Next ft(0) = 0 fd(0) = "Point" Set sset = ThisDrawing.SelectionSets.Add("Sset_P") sset.Select acSelectionSetAll, , , ft, fd ReDim pnt_cord(sset.Count - 1) As Variant ReDim x(sset.Count - 1) ReDim y(sset.Count - 1) dnr = "" For i = 0 To sset.Count - 1 pnt_cord(i) = sset.Item(i).Coordinates Select Case us1 Case 500 If us2 = 0 And us3 = 0 Then x(i) = (pnt_cord(i)(1) - 100) / 2 y(i) = (pnt_cord(i)(0) - 100) / 2 ElseIf us2 = 100 And us3 = 100 Then x(i) = (pnt_cord(i)(1) + 100) / 2 y(i) = (pnt_cord(i)(0) + 100) / 2 End If Case 1000 If us2 = 0 And us3 = 0 Then x(i) = pnt_cord(i)(1) - 100 y(i) = pnt_cord(i)(0) - 100 ElseIf us2 = 100 And us3 = 100 Then x(i) = pnt_cord(i)(1) y(i) = pnt_cord(i)(0) End If End Select '*******按scs2000展点文件格式排列点 dnr = dnr & vbCrLf & (i + 1) & vbCrLf & "" & vbCrLf & y(i) & vbCrLf & x(i) & vbCrLf & pnt_cord(i)(2)
Next outtxt = sset.Count & dnr MsgBox "点导出成功,请保存文件!" End Sub |