|
| 1 | +--- |
| 2 | +layout: doc |
| 3 | +--- |
| 4 | + |
| 5 | +# Header |
| 6 | + |
| 7 | +## Variables |
| 8 | + |
| 9 | +Variables contains settings associated with the drawing, defined in the `HEADER` section. |
| 10 | +> All possible [variables](https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-A85E8E67-27CD-4C59-BE61-4DC9FADBE74A) |
| 11 | +
|
| 12 | +:::info |
| 13 | + |
| 14 | +By default these variables are set automatically: |
| 15 | + |
| 16 | +- `$ACADVER` The AutoCAD drawing database version number: AC1021 = AutoCAD 2007. |
| 17 | +- `$HANDSEED` Next available handle. |
| 18 | +- `$INSUNITS` Default drawing units for AutoCAD DesignCenter blocks: 0 = Unitless. |
| 19 | +- `$VIEWCTR` XY center of current view on screen. |
| 20 | +- `$CLAYER` Save the current layer name. |
| 21 | +- `$LASTSAVEDBY` Sets to the package name. |
| 22 | + |
| 23 | +::: |
| 24 | + |
| 25 | +## Adding variables |
| 26 | + |
| 27 | +Each variable is specified by a 9 group code giving the variable's name, followed by groups that supply the variable's value: |
| 28 | + |
| 29 | +```txt |
| 30 | + 9 |
| 31 | +$NAME // The name of the variable. |
| 32 | + 10 // First group code |
| 33 | +20 // The value assocoated |
| 34 | + 20 // Second group code |
| 35 | +20 // The value assocoated |
| 36 | +// And so on... |
| 37 | +
|
| 38 | +// These values are random. |
| 39 | +``` |
| 40 | + |
| 41 | +Javascript code : |
| 42 | + |
| 43 | +```js |
| 44 | +import { DxfWriter } from "@tarikjabiri/dxf"; |
| 45 | +const dxf = new DxfWriter(); |
| 46 | +dxf.setVariable("$ATTMODE", { 70: 2 }); |
| 47 | +// $ATTMODE is the name of the variable |
| 48 | +// 70 is the group code |
| 49 | +// 2 is the value to be set. |
| 50 | +dxf.setVariable("$PLIMMAX", { |
| 51 | + 10: 20, |
| 52 | + 20: 30, |
| 53 | +}); // This variable accept tow group codes and tow values |
| 54 | +``` |
| 55 | + |
| 56 | +:::info |
| 57 | + |
| 58 | +- The object passed as values is key value paired, the key is the group code and value associated with it. |
| 59 | +- If you try to add a variable already added, its values will be updated. |
| 60 | + |
| 61 | +::: |
| 62 | + |
| 63 | +## Setting Units |
| 64 | + |
| 65 | +To set units use the convenient method `setUnits()`: |
| 66 | + |
| 67 | +```js |
| 68 | +import { DxfWriter, Units } from '@tarikjabiri/dxf'; |
| 69 | + |
| 70 | +const dxf = new DxfWriter(); |
| 71 | +dxf.setUnits(Units.Meters); |
| 72 | + |
| 73 | +``` |
0 commit comments