I found this GWBASIC Program from the internet...A good start to learn how to generate a DXF file in BASIC
1000 REM
1010 REM Polygon generator
1020 REM
1030 LINE INPUT "Drawing (DXF) file name: "; A$
1040 OPEN "o", 1, A$ + ".dxf"
1050 PRINT #1, 0
1060 PRINT #1, "SECTION"
1070 PRINT #1, 2
1080 PRINT #1, "ENTITIES"
1090 PI = ATN(1) * 4
1100 INPUT "Number of sides for polygon: "; S%
1110 INPUT "Starting point (X,Y): "; X, Y
1120 INPUT "Polygon side: "; D
1130 A1 = (2 * PI) / S%
1140 A = PI / 2
1150 FOR I% = 1 TO S%
1160 PRINT #1, 0
1170 PRINT #1, "LINE"
1180 PRINT #1, 8
1190 PRINT #1, "0"
1200 PRINT #1, 10
1210 PRINT #1, X
1220 PRINT #1, 20
1230 PRINT #1, Y
1240 PRINT #1, 30
1250 PRINT #1, 0.0
1260 NX = D * COS(A) + X
1270 NY = D * SIN(A) + Y
1280 PRINT #1, 11
1290 PRINT #1, NX
1300 PRINT #1, 21
1310 PRINT #1, NY
1320 PRINT #1, 31
1330 PRINT #1, 0.0
1340 X = NX
1350 Y = NY
1360 A = A + A1
1370 NEXT I%
1380 PRINT #1, 0
1390 PRINT #1, "ENDSEC"
1400 PRINT #1, 0
1410 PRINT #1, "EOF"
1420 CLOSE 1
No comments:
Post a Comment