明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1756|回复: 1

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

[复制链接]
发表于 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) = "oint"
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展点,不过应该会给你一点参考,有什么问题再告诉我!
发表于 2003-4-21 17:20:00 | 显示全部楼层

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

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-28 16:51 , Processed in 0.148220 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表