myfreemind 发表于 2003-4-18 19:40:00

我忘了是哪个网友问的取屏幕直线端点坐标,并生成一个文件?现原代码如下

Sub createfile()

Dim outtxt As String
Dim pnt As AcadPoint
Dim dnr As String

Dim entity As AcadEntity
Dim ft(0) As Integer
Dim fd(0) As Variant
'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
dnr = ""
For i = 0 To sset.Count - 1
pnt_cord(i) = sset.Item(i).Coordinates
dnr = dnr & vbCrLf & (i + 1) & vbCrLf & "" & vbCrLf & pnt_cord(i)(0) & vbCrLf & pnt_cord(i)(1) & vbCrLf & "0"

Next
outtxt = sset.Count & dnr
Open "c:\output.dat" For Output As #1
Print #1, outtxt
Close #1

End Sub

但我写的这个程序并非取直线端点坐标,而是取点坐标,并排成展点格式,并生成文件可供CAD展点,不过应该会给你一点参考,有什么问题再告诉我!

efan2000 发表于 2003-4-21 17:20:00

只能处理轻量多段线,如果是其它线的话还要在选择集中分别处理

页: [1]
查看完整版本: 我忘了是哪个网友问的取屏幕直线端点坐标,并生成一个文件?现原代码如下