cad vba 如何获取多段线xyz 的坐标并存在一个txt文档里

来源:百度知道 编辑:UC知道 时间:2024/06/10 07:40:04
各位大侠帮帮忙,如何能得到一个图层中所有多段线的x,y,z坐标,并把这些坐标保存到txt文本里啊

Private Sub GetLWPOLYLINECoordinates()
Dim ss_dim As AcadSelectionSet, ent As AcadLWPolyline
Dim dxf_code() As Integer, dxf_value() As Variant
Dim i As Long, j As Long
Dim dbCor As Variant, x As Double, y As Double, z As Double

Set ss_dim = ThisDrawing.SelectionSets.Add("ssLine1")
ReDim dxf_code(0), dxf_value(0)
dxf_code(0) = 0: dxf_value(0) = "LWPOLYLINE"
ss_dim.Select acSelectionSetAll, , , dxf_code, dxf_value

Open "d:\aaaaa.txt" For Append As #1

For Each ent In ss_dim
For j = 0 To UBound(ent.Coordinates) \ 2
x = ent.Coordinates(j * 2)
y = ent.Coordinates(j * 2 + 1)
Print #1, "X" & x & ",Y" & y
Next
Next
Close #1
ss_dim.Clear
ss_dim.Delete
End Sub

没有Z就没有吧。polyline的坐标信息里好像就不包含Z,忍了吧。