You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
The following Visual Basic subroutine constructs a DXF file representing a<br />
polygon.<br />
' WriteDXFPolygon creates a minimal DXF file that only contains<br />
' the ENTITIES section. This subroutine requires five parameters,<br />
' the DXF file name, the number of sides for the polygon, the X<br />
' and Y coordinates for the bottom end of the right-most side<br />
' (it starts in a vertical direction), and the length for each<br />
' side. Note that because this only requests 2D points, it does<br />
' not include the Z coordinates (codes 30 and 31). The lines are<br />
' placed on the layer "Polygon."<br />
'<br />
Sub WriteDXFPolygon( _<br />
dxfFile As String, iSides As Integer, _<br />
dblX As Double, dblY As Double, dblLen As Double)<br />
Dim i As Integer<br />
Dim dblA1, dblA, dblPI, dblNX, dblNY As Double<br />
Open dxfFile For Output As #1<br />
Print #1, 0<br />
Print #1, "SECTION"<br />
Print #1, 2<br />
Print #1, "ENTITIES"<br />
dblPI = Atn(1) * 4<br />
dblA1 = (2 * dblPI) / iSides<br />
dblA = dblPI / 2<br />
For i = 1 To iSides<br />
Print #1, 0<br />
Print #1, "LINE"<br />
Print #1, 8<br />
Print #1, "Polygon"<br />
Print #1, 10<br />
Print #1, dblX<br />
Print #1, 20<br />
Print #1, dblY<br />
dblNX = dblLen * Cos(dblA) + dblX<br />
dblNY = dblLen * Sin(dblA) + dblY<br />
Print #1, 11<br />
Print #1, dblNX<br />
Print #1, 21<br />
Print #1, dblNY<br />
dblX = dblNX<br />
dblY = dblNY<br />
dblA = dblA + dblA1<br />
Next i<br />
Print #1, 0<br />
Print #1, "ENDSEC"<br />
Print #1, 0<br />
Print #1, "EOF"<br />
Close #1<br />
End Sub<br />
As long as a properly formatted item appears on the line on which the data<br />
is expected, DXFIN accepts it. (Of course, string items should not have leading<br />
spaces unless these are intended to be part of the string.) This BASIC program<br />
ASCII DXF Files | 157