| 1 |
#include "dl_dxf.h" |
| 2 |
|
| 3 |
int main() { |
| 4 |
DL_Dxf dxf; |
| 5 |
DL_WriterA* dw = dxf.out("dimension.dxf", DL_Codes::AC1015); |
| 6 |
|
| 7 |
// section header: |
| 8 |
dxf.writeHeader(*dw); |
| 9 |
dw->sectionEnd(); |
| 10 |
|
| 11 |
// section tables: |
| 12 |
dw->sectionTables(); |
| 13 |
|
| 14 |
// VPORT: |
| 15 |
dxf.writeVPort(*dw); |
| 16 |
|
| 17 |
// LTYPE: |
| 18 |
dw->tableLinetypes(1); |
| 19 |
dxf.writeLinetype(*dw, DL_LinetypeData("CONTINUOUS", "Continuous", 0, 0, 0.0)); |
| 20 |
dxf.writeLinetype(*dw, DL_LinetypeData("BYLAYER", "", 0, 0, 0.0)); |
| 21 |
dxf.writeLinetype(*dw, DL_LinetypeData("BYBLOCK", "", 0, 0, 0.0)); |
| 22 |
dw->tableEnd(); |
| 23 |
|
| 24 |
// LAYER: |
| 25 |
dw->tableLayers(1); |
| 26 |
dxf.writeLayer( |
| 27 |
*dw, |
| 28 |
DL_LayerData("0", 0), |
| 29 |
DL_Attributes("", 1, 0x00ff0000, 15, "CONTINUOUS") |
| 30 |
); |
| 31 |
dw->tableEnd(); |
| 32 |
|
| 33 |
// STYLE: |
| 34 |
dw->tableStyle(1); |
| 35 |
DL_StyleData style("Standard", 0, 0.0, 1.0, 0.0, 0, 2.5, "txt", ""); |
| 36 |
style.bold = false; |
| 37 |
style.italic = false; |
| 38 |
dxf.writeStyle(*dw, style); |
| 39 |
dw->tableEnd(); |
| 40 |
|
| 41 |
// VIEW: |
| 42 |
dxf.writeView(*dw); |
| 43 |
|
| 44 |
// UCS: |
| 45 |
dxf.writeUcs(*dw); |
| 46 |
|
| 47 |
// APPID: |
| 48 |
dw->tableAppid(1); |
| 49 |
dxf.writeAppid(*dw, "ACAD"); |
| 50 |
dw->tableEnd(); |
| 51 |
|
| 52 |
// DIMSTYLE: |
| 53 |
dxf.writeDimStyle(*dw, 2.5, 0.625, 0.625, 0.625, 2.5); |
| 54 |
|
| 55 |
// BLOCK_RECORD: |
| 56 |
dxf.writeBlockRecord(*dw); |
| 57 |
dw->tableEnd(); |
| 58 |
|
| 59 |
dw->sectionEnd(); |
| 60 |
|
| 61 |
// BLOCK: |
| 62 |
dw->sectionBlocks(); |
| 63 |
dxf.writeBlock(*dw, DL_BlockData("*Model_Space", 0, 0.0, 0.0, 0.0)); |
| 64 |
dxf.writeEndBlock(*dw, "*Model_Space"); |
| 65 |
dxf.writeBlock(*dw, DL_BlockData("*Paper_Space", 0, 0.0, 0.0, 0.0)); |
| 66 |
dxf.writeEndBlock(*dw, "*Paper_Space"); |
| 67 |
dxf.writeBlock(*dw, DL_BlockData("*Paper_Space0", 0, 0.0, 0.0, 0.0)); |
| 68 |
dxf.writeEndBlock(*dw, "*Paper_Space0"); |
| 69 |
dw->sectionEnd(); |
| 70 |
|
| 71 |
// ENTITIES: |
| 72 |
dw->sectionEntities(); |
| 73 |
|
| 74 |
DL_Attributes attributes("0", 256, -1, -1, "BYLAYER"); |
| 75 |
|
| 76 |
// LINE: |
| 77 |
DL_LineData lineData(10, 5, 0, 30, 5, 0); |
| 78 |
dxf.writeLine(*dw, lineData, attributes); |
| 79 |
|
| 80 |
// DIMENSION: |
| 81 |
DL_DimensionData dimData(10.0, // def point (dimension line pos) |
| 82 |
50.0, |
| 83 |
0.0, |
| 84 |
0, // text pos (irrelevant if flag 0x80 (128) set for type |
| 85 |
0, |
| 86 |
0.0, |
| 87 |
0x1, // type: aligned with auto text pos (0x80 NOT set) |
| 88 |
8, // attachment point: bottom center |
| 89 |
2, // line spacing: exact |
| 90 |
1.0, // line spacing factor |
| 91 |
"", // text |
| 92 |
"Standard", // style |
| 93 |
0.0, // text angle |
| 94 |
1.0, // linear factor |
| 95 |
1.0); // dim scale |
| 96 |
|
| 97 |
DL_DimAlignedData dimAlignedData(10.0, // extension point 1 |
| 98 |
5.0, |
| 99 |
0.0, |
| 100 |
30.0, // extension point 2 |
| 101 |
5.0, |
| 102 |
0.0); |
| 103 |
|
| 104 |
dxf.writeDimAligned(*dw, dimData, dimAlignedData, attributes); |
| 105 |
|
| 106 |
// end section ENTITIES: |
| 107 |
dw->sectionEnd(); |
| 108 |
dxf.writeObjects(*dw, "MY_OBJECTS"); |
| 109 |
dxf.writeObjectsEnd(*dw); |
| 110 |
|
| 111 |
dw->dxfEOF(); |
| 112 |
dw->close(); |
| 113 |
delete dw; |
| 114 |
|
| 115 |
return 0; |
| 116 |
} |