- UID
- 4746
- 积分
- 438
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-5-6
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
' 在屏幕上选择若干点,然后将其坐标保存到文件
' 演示了选择集的建立和选择集中图元的处理
Sub OutputPoint()
Dim PointObj As AcadPoint '点对象
Dim SsetObj As AcadSelectionSet '选择集对象
Dim x As Double, y As Double, z As Double
Dim i As Integer
Dim gpCode(0) As Integer
Dim dataValue(0) As Variant
Dim groupCode As Variant, dataCode As Variant
Open ThisDrawing.Path & "\points.txt" For Output As #1
' 设置选择集只能选择点对象
gpCode(0) = 0
dataValue(0) = "Point"
groupCode = gpCode
dataCode = dataValue
' 建立选择集并将用户在屏幕上选择的点加入选择集
Set SsetObj = ThisDrawing.SelectionSets.Add("PointSet")
SsetObj.SelectOnScreen groupCode, dataCode
MsgBox "你选择了" & SsetObj.Count & "个点,坐标存入文件:" & ThisDrawing.Path & "\points.txt"
For i = 1 To SsetObj.Count
Set PointObj = SsetObj.Item(i - 1)
x = PointObj.Coordinates(0)
y = PointObj.Coordinates(1)
z = PointObj.Coordinates(2)
Print #1, i; " "; Format(y, "0.000"); " "; Format(x, "0.000"); " "; Format(z, "0.000")
Next i
SsetObj.Delete '删除选择集
Close #1
End Sub
附件中是dvb文件。 |
|