如何获得块中点的坐标
我初学vba不久,我遇到一个问题,一个块有几百个点,如何利用vba获得点的坐标呢???并利用.txt文件存储呢?? 可以先把块炸开获得对象集,然后就可以取得点的数据了! 我刚开始学习vba,我比较菜,怎么炸开呢??有没有代码一类的呢?? 有命令呀, Sub test()
Dim SelObj As AcadObject
Dim SelP, Obj As Variant
Dim n
Dim Pnt As AcadPoint
Dim x, yThisDrawing.Utility.GetEntity SelObj, SelP, "选择块:"Obj = SelObj.Explode
n = UBound(Obj) '得到块中图元个数
For i = 0 To n
If Obj(i).EntityName = "AcDbPoint" Then
Set Pnt = Obj(i)
x = Pnt.Coordinates(0) '点x坐标
y = Pnt.Coordinates(1) '点y坐标
Open "D:\test.txt" For Append As #1 '写入点到文件
Print #1, "X=" & Str(x) & " " & "Y=" & Str(y)
Close #1 End If
NextFor i = 0 To n '删除炸开的图元
Obj(i).Delete
NextEnd Sub
页:
[1]