前回、直線2本のデータをワークシートに書き込みました。
これをテキストファイルに書き込みます。
このファイルが、DXFデータとしてJw_cadで読み込むことができます。
前回のコードに追加します。
Sub test7()
Dim i As Long, j As Long
Dim RowEnd As Long
Dim Row_Enti As Long
Dim Xcod_S, Ycod_S
Dim Xcod_E, Ycod_E
Dim cnt As Long
RowEnd = Range("A1").End(xlDown).Row
For j = 1 To RowEnd
If Cells(j, 1) = "ENTITIES" Then
Row_Enti = j
Exit For
End If
Next j
With Worksheets("座標と番号")
For i = 1 To 3
X(i) = .Cells(i, "A").Value
Y(i) = .Cells(i, "B").Value
Next i
For i = 1 To 2
Xcod_S = X(.Cells(i, "D").Value)
Ycod_S = Y(.Cells(i, "D").Value)
Xcod_E = X(.Cells(i, "E").Value)
Ycod_E = Y(.Cells(i, "E").Value)
Call LineDraw(RowEnd, Row_Enti, Xcod_S, Ycod_S, Xcod_E, Ycod_E)
RowEnd = Range("A1").End(xlDown).Row
Next i
End With
Open "D:test.dxf" For Output As #1
For i = 1 To RowEnd
Print #1, Worksheets("原紙").Cells(i, 1).Value
Next i
Close #1
End Sub
OPEN ・・・・・ 以降の部分を追加しました。
Print #1 ・・・で、テキストファイルに1行書き込みます。
書き込むデータは、前回ワークシートに作ったデータです。
これを1行目から最終行まで、1行づつ書き込んでいきます。
動画で、残りの部分も解説しましたので参考にして下さい。