Option Explicit
Sub Test2 ()
On the Error Resume Next
Dim ele As AcadLine
Dim ele1 As AcadLWPolyline
Dim I, j, index As an Integer
Dim get3Dpts As the Variant
Dim astr As String
Open "F: \ EleData. TXT" For the Output As the # 1 'file path, Append is added, the Output is cover
The index=0
For I=0 To ThisDrawing. ModelSpace. Count - 1
If (ThisDrawing. ModelSpace. Item (I). The ObjectName="AcDbline") And (InStr (1, ThisDrawing. ModelSpace. Item (I) Layer, "the first curve") & gt; 0 Or InStr (1, ThisDrawing. ModelSpace. Item (I) Layer, the "curve") & gt; 0) Then '41, the Index is the name of the layer, need to change according to actual condition
The index line
=index + 1 'The Set ele=ThisDrawing. ModelSpace. Item (I)
Astr=FormatNumber (ele. The StartPoint (0), 2, vbFalse, vbFalse, vbFalse) + "" + FormatNumber (ele. The StartPoint (1), 2, vbFalse, vbFalse, vbFalse) +" "+ FormatNumber (ele. The StartPoint (2), 2, vbFalse, vbFalse, vbFalse)
The index=index + 1
Astr=astr + vbCrLf + FormatNumber (ele. The EndPoint (0), 2, vbFalse, vbFalse, vbFalse) + ", "+ FormatNumber (ele. The EndPoint (1), 2, vbFalse, vbFalse, vbFalse) +", "+ FormatNumber (ele. The EndPoint (2), 2, vbFalse, vbFalse, vbFalse)
Print # 1, astr
ElseIf (ThisDrawing. ModelSpace. Item (I). The ObjectName="AcDbPolyline") And (InStr (1, ThisDrawing. ModelSpace. Item (I) Layer, "the first curve") & gt; 0 Or InStr (1, ThisDrawing. ModelSpace. Item (I) Layer, the "curve") & gt; 0) Then '41, the Index is the name of the layer, need to change according to actual condition
The Set ele1=ThisDrawing. ModelSpace. Item (I) 'section of the line more
Get3Dpts=ele1. Coordinates
Astr=""
For j=LBound (get3Dpts, 1) To UBound (get3Dpts, 1) - 1 Step 2
The index=index + 1
Astr=astr + vbCrLf + FormatNumber (get3Dpts (j), 2, vbFalse, vbFalse, vbFalse) + "" + FormatNumber (get3Dpts (j + 1), 2, vbFalse, vbFalse, vbFalse) +" "+ Str (ele1. Elevation)
Next j
Print # 1, astr
End the If
Next I
Close # 1
End Sub
CodePudding user response:
Ask for help,,,CodePudding user response:
A, for help.Astr=astr + vbCrLf + FormatNumber (get3Dpts (j), 2, vbFalse, vbFalse, vbFalse) + "" + FormatNumber (get3Dpts (j + 1), 2, vbFalse, vbFalse, vbFalse) +" "+ Str (ele1. Elevation) into astr=astr + vbCrLf + FormatNumber (get3Dpts (j), 2, vbFalse, vbFalse, vbFalse) +" "+ FormatNumber (get3Dpts (j + 1), 2, vbFalse, vbFalse, vbFalse) +" "+ FormatNumber (get3Dpts (j + 2), 2, vbFalse, vbFalse, vbFalse) is that ok?