13
13
* @see (RU) http://help.autodesk.com/view/ACD/2015/RUS/?guid=GUID-235B22E0-A567-4CF6-92D3-38A2306D73F3
14
14
*
15
15
* @example <code>
16
- * $dxf = new \adamasantares\dxf\Creator();
16
+ * $dxf = new \adamasantares\dxf\Creator( \adamasantares\dxf\Creator::INCHES );
17
17
* $dxf->addText(26, 46, 0, 'DXF testing', 8)
18
18
* ->setLayer('cyan', $color::CYAN)
19
19
* ->addLine(25, 0, 0, 100, 0, 0)
46
46
*/
47
47
class Creator {
48
48
49
+ // units codes
50
+ const UNITLESS = 0 ;
51
+ const INCHES = 1 ;
52
+ const FEET = 2 ;
53
+ const MILES = 3 ;
54
+ const MILLIMETERS = 4 ;
55
+ const CENTIMETERS = 5 ;
56
+ const METERS = 6 ;
57
+ const KILOMETERS = 7 ;
58
+ const MICROINCHES = 8 ;
59
+ const MILS = 9 ;
60
+ const YARDS = 10 ;
61
+ const ANGSTROMS = 11 ;
62
+ const NANOMETERS = 12 ;
63
+ const MICRONS = 13 ;
64
+ const DECIMETERS = 14 ;
65
+ const DECAMETERS = 15 ;
66
+ const HECTOMETERS = 16 ;
67
+ const GIGAMETERS = 17 ;
68
+ const ASTRONOMICAL_UNITS = 18 ;
69
+ const LIGHT_YEARS = 19 ;
70
+ const PARSECS = 20 ;
71
+
49
72
/**
50
73
* @var null Last error description
51
74
*/
@@ -72,12 +95,18 @@ class Creator {
72
95
*/
73
96
private $ offset = [0 , 0 , 0 ];
74
97
98
+ /**
99
+ * @var int Units
100
+ */
101
+ private $ units = 1 ;
102
+
75
103
76
104
/**
77
105
* Create new DXF document
78
106
*/
79
- function __construct ()
107
+ function __construct ($ units )
80
108
{
109
+ $ this ->units = $ units ;
81
110
// add default layout
82
111
$ this ->addLayer ($ this ->layerName );
83
112
}
@@ -133,7 +162,7 @@ private function getString() {
133
162
* @return string
134
163
*/
135
164
private function getHeaderString () {
136
- $ str = "0 \nSECTION \n 2 \nHEADER \n 9 \n\$ACADVER \n 1 \nAC1006 \n 0 \n ENDSEC \n 0 \n" ;
165
+ $ str = "0 \nSECTION \n 2 \nHEADER \n 9 \n\$ACADVER \n 1 \nAC1006 \n 9 \n $ " . " INSUNITS \n 70 \n{ $ this -> units }\n 0 \n ENDSEC \n 0 \n" ;
137
166
//layers
138
167
$ str .= "SECTION \n 2 \nTABLES \n 0 \nTABLE \n2 \n" ;
139
168
$ str .= $ this ->getLayersString ();
@@ -374,6 +403,21 @@ public function addArc($x, $y, $z, $radius, $startAngle = 0.1, $endAngle = 90.0)
374
403
return $ this ;
375
404
}
376
405
406
+
407
+ /**
408
+ * Add Ellipse to current layer.
409
+ *
410
+ * @return $this
411
+ * @see http://www.autodesk.com/techpubs/autocad/acad2000/dxf/ellipse_dxf_06.htm
412
+ */
413
+ // TODO todo...
414
+ // public function addEllipse(/* ... */)
415
+ // {
416
+ //
417
+ // return $this;
418
+ // }
419
+
420
+
377
421
/**
378
422
* Add 2D polyline to current layer.
379
423
* @param array[float] $points Points array: [x, y, x2, y2, x3, y3, ...]
0 commit comments