cad里的多段线坐标怎么导出
操作方法
- 01
'按下ALT+F11组合键,将下面的代码拷贝进去,执行即可。坐标导出到“E:\多段线坐标.txT”文件里面 Sub cad里的多段线坐标怎么导出() Dim element As AcadObject '选择集合中的元素 Dimc1 as acadPolyline '处理前的曲线 Dim sset As AcadSelectionSet '选择集合Dim A(0) As IntegerDim B(0) As Variant ' 选择曲线,多段线在选择前需要先将要导出坐标的的线曲线化一下 If ThisDrawing.SelectionSets.Count < 1 Then Set sset = ThisDrawing.SelectionSets.Add("ss01") Else 'On Error Resume Next Set sset = ThisDrawing.SelectionSets.Item("ss01") End If sset.Clear A(0) = 0 B(0)="POLYLINE" sset.SelectOnScreen A, B '完成曲线选择(后选方式) 'Exit Sub If sset.Count > 0 Then For Each element In sset '在选择集中进行循环 Set c1 = element On Error Resume Next o1 = easyArry(c1.Coordinates) ' c1.Delete Next Else MsgBox "操作错误: 未选择对象" End If ' NextEnd Sub Function easyArry(ByRef arry As Variant) As VariantDim i As Integer, j As Integer '新旧曲线节点数Dim po() As Double '返回数列Open "E:\多段线坐标.txt" For Append As #1j = 1i = 1ReDim po(2)po(0) = arry(0) po(1) = arry(1): po(2) = arry(2) Write #1, po(0), po(1)Do pi(0) = arry(i * 3)'为前节点赋值 j = j + 1 i = i + 1 Write #1, pi(0), pi(1) Loop While i < (UBound(arry) + 1) / 3Print #1, Close #1End Function