@mlightcad/data-model 1.8.1 → 1.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,168 @@
1
+ import { AcGeBox3d, AcGeMatrix3d, AcGePoint3d, AcGePoint3dLike, AcGeVector3d, AcGeVector3dLike } from '@mlightcad/geometry-engine';
2
+ import { AcGiEntity, AcGiRenderer, AcGiTextStyle } from '@mlightcad/graphic-interface';
3
+ import { AcDbDxfFiler } from '../base';
4
+ import { AcDbOsnapMode } from '../misc';
5
+ import { AcDbEntity } from './AcDbEntity';
6
+ import { AcDbEntityProperties } from './AcDbEntityProperties';
7
+ /**
8
+ * Represents a shape entity in AutoCAD.
9
+ *
10
+ * A shape is a planar geometric object that references a shape definition from an
11
+ * SHX font file. Shapes are positioned by an insertion point, scaled by {@link size}
12
+ * and {@link widthFactor}, and oriented by {@link rotation}, {@link oblique}, and
13
+ * {@link normal}. This class mirrors {@link AcDbShape} in ObjectARX.
14
+ *
15
+ * @see https://help.autodesk.com/view/OARX/2024/ENU/?guid=OARX-RefGuide-AcDbShape
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const shape = new AcDbShape();
20
+ * shape.name = 'ARROW';
21
+ * shape.position = new AcGePoint3d(10, 20, 0);
22
+ * shape.size = 2.5;
23
+ * shape.rotation = Math.PI / 4;
24
+ * ```
25
+ */
26
+ export declare class AcDbShape extends AcDbEntity {
27
+ /** The entity type name */
28
+ static typeName: string;
29
+ get dxfTypeName(): string;
30
+ /** The insertion point of the shape in WCS coordinates. */
31
+ private _position;
32
+ /** The height of the shape. */
33
+ private _size;
34
+ /** The name of the shape within the associated SHX font. */
35
+ private _name;
36
+ /** The rotation angle relative to the shape OCS X axis, in radians. */
37
+ private _rotation;
38
+ /** The relative X-scale factor (width factor). */
39
+ private _widthFactor;
40
+ /** The oblique angle relative to the shape vertical, in radians. */
41
+ private _oblique;
42
+ /** The thickness along {@link normal}. */
43
+ private _thickness;
44
+ /** The normal vector of the plane containing the shape, in WCS coordinates. */
45
+ private _normal;
46
+ /** The numeric shape code within the SHX font. */
47
+ private _shapeNumber;
48
+ /** The text style name that references the SHX font for this shape. */
49
+ private _styleName;
50
+ /**
51
+ * Creates a new shape entity at the origin with unit size and no rotation.
52
+ */
53
+ constructor();
54
+ /**
55
+ * Gets the insertion point of this shape in WCS coordinates.
56
+ *
57
+ * Mirrors `AcDbShape::position()` in ObjectARX.
58
+ */
59
+ get position(): AcGePoint3d;
60
+ /** Sets the insertion point of this shape in WCS coordinates. */
61
+ set position(value: AcGePoint3dLike);
62
+ /**
63
+ * Gets the height of this shape.
64
+ *
65
+ * Mirrors `AcDbShape::size()` in ObjectARX.
66
+ */
67
+ get size(): number;
68
+ /** Sets the height of this shape. */
69
+ set size(value: number);
70
+ /**
71
+ * Gets the name of the shape within the associated SHX font.
72
+ *
73
+ * Mirrors `AcDbShape::name()` in ObjectARX.
74
+ */
75
+ get name(): string;
76
+ /** Sets the name of the shape within the associated SHX font. */
77
+ set name(value: string);
78
+ /**
79
+ * Gets the rotation angle of this shape in radians.
80
+ *
81
+ * The angle is relative to the X axis of the shape OCS, with positive angles
82
+ * going counterclockwise when looking down the Z axis toward the origin.
83
+ *
84
+ * Mirrors `AcDbShape::rotation()` in ObjectARX.
85
+ */
86
+ get rotation(): number;
87
+ /** Sets the rotation angle of this shape in radians. */
88
+ set rotation(value: number);
89
+ /**
90
+ * Gets the width factor applied to this shape.
91
+ *
92
+ * Mirrors `AcDbShape::widthFactor()` in ObjectARX.
93
+ */
94
+ get widthFactor(): number;
95
+ /** Sets the width factor applied to this shape. */
96
+ set widthFactor(value: number);
97
+ /**
98
+ * Gets the oblique angle of this shape in radians.
99
+ *
100
+ * Mirrors `AcDbShape::oblique()` in ObjectARX.
101
+ */
102
+ get oblique(): number;
103
+ /** Sets the oblique angle of this shape in radians. */
104
+ set oblique(value: number);
105
+ /**
106
+ * Gets the thickness of this shape along {@link normal}.
107
+ *
108
+ * Mirrors `AcDbShape::thickness()` in ObjectARX.
109
+ */
110
+ get thickness(): number;
111
+ /** Sets the thickness of this shape. */
112
+ set thickness(value: number);
113
+ /**
114
+ * Gets the normal vector of the plane containing this shape.
115
+ *
116
+ * Mirrors `AcDbShape::normal()` in ObjectARX.
117
+ */
118
+ get normal(): AcGeVector3d;
119
+ /** Sets the normal vector of the plane containing this shape. */
120
+ set normal(value: AcGeVector3dLike);
121
+ /**
122
+ * Gets the numeric shape code within the SHX font.
123
+ *
124
+ * Mirrors `AcDbShape::shapeNumber()` in ObjectARX.
125
+ */
126
+ get shapeNumber(): number;
127
+ /** Sets the numeric shape code within the SHX font. */
128
+ set shapeNumber(value: number);
129
+ /**
130
+ * Gets the object ID of the text style table record that references this
131
+ * shape's SHX font.
132
+ *
133
+ * Mirrors `AcDbShape::styleId()` in ObjectARX.
134
+ */
135
+ get styleId(): string;
136
+ /**
137
+ * Sets the text style table record by object ID.
138
+ *
139
+ * Mirrors `AcDbShape::setStyleId()` in ObjectARX.
140
+ */
141
+ set styleId(value: string);
142
+ /**
143
+ * Gets the text style name associated with this shape.
144
+ *
145
+ * Used when reading or writing DXF group code 3 (shape file/style name).
146
+ */
147
+ get styleName(): string;
148
+ /** Sets the text style name associated with this shape. */
149
+ set styleName(value: string);
150
+ /**
151
+ * Gets whether this shape is planar.
152
+ *
153
+ * Mirrors `AcDbShape::isPlanar()` in ObjectARX.
154
+ */
155
+ get isPlanar(): boolean;
156
+ get geometricExtents(): AcGeBox3d;
157
+ subGetGripPoints(): AcGePoint3d[];
158
+ subGetOsnapPoints(osnapMode: AcDbOsnapMode, _pickPoint: AcGePoint3dLike, _lastPoint: AcGePoint3dLike, snapPoints: AcGePoint3dLike[]): void;
159
+ transformBy(matrix: AcGeMatrix3d): this;
160
+ get properties(): AcDbEntityProperties;
161
+ subWorldDraw(renderer: AcGiRenderer, delay?: boolean): AcGiEntity | undefined;
162
+ /**
163
+ * Gets the text style that references the SHX font for this shape.
164
+ */
165
+ protected getTextStyle(): AcGiTextStyle;
166
+ dxfOutFields(filer: AcDbDxfFiler): this;
167
+ }
168
+ //# sourceMappingURL=AcDbShape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcDbShape.d.ts","sourceRoot":"","sources":["../../src/entity/AcDbShape.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,518 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ import { AcGeBox3d, AcGeMatrix3d, AcGePoint3d, AcGeVector3d } from '@mlightcad/geometry-engine';
28
+ import { AcDbOsnapMode } from '../misc';
29
+ import { AcDbEntity } from './AcDbEntity';
30
+ /**
31
+ * Represents a shape entity in AutoCAD.
32
+ *
33
+ * A shape is a planar geometric object that references a shape definition from an
34
+ * SHX font file. Shapes are positioned by an insertion point, scaled by {@link size}
35
+ * and {@link widthFactor}, and oriented by {@link rotation}, {@link oblique}, and
36
+ * {@link normal}. This class mirrors {@link AcDbShape} in ObjectARX.
37
+ *
38
+ * @see https://help.autodesk.com/view/OARX/2024/ENU/?guid=OARX-RefGuide-AcDbShape
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const shape = new AcDbShape();
43
+ * shape.name = 'ARROW';
44
+ * shape.position = new AcGePoint3d(10, 20, 0);
45
+ * shape.size = 2.5;
46
+ * shape.rotation = Math.PI / 4;
47
+ * ```
48
+ */
49
+ var AcDbShape = /** @class */ (function (_super) {
50
+ __extends(AcDbShape, _super);
51
+ /**
52
+ * Creates a new shape entity at the origin with unit size and no rotation.
53
+ */
54
+ function AcDbShape() {
55
+ var _this = _super.call(this) || this;
56
+ _this._position = new AcGePoint3d();
57
+ _this._size = 1;
58
+ _this._name = '';
59
+ _this._rotation = 0;
60
+ _this._widthFactor = 1;
61
+ _this._oblique = 0;
62
+ _this._thickness = 0;
63
+ _this._normal = new AcGeVector3d(0, 0, 1);
64
+ _this._shapeNumber = 0;
65
+ _this._styleName = '';
66
+ return _this;
67
+ }
68
+ Object.defineProperty(AcDbShape.prototype, "dxfTypeName", {
69
+ get: function () {
70
+ return 'SHAPE';
71
+ },
72
+ enumerable: false,
73
+ configurable: true
74
+ });
75
+ Object.defineProperty(AcDbShape.prototype, "position", {
76
+ /**
77
+ * Gets the insertion point of this shape in WCS coordinates.
78
+ *
79
+ * Mirrors `AcDbShape::position()` in ObjectARX.
80
+ */
81
+ get: function () {
82
+ return this._position;
83
+ },
84
+ /** Sets the insertion point of this shape in WCS coordinates. */
85
+ set: function (value) {
86
+ this._position.copy(value);
87
+ },
88
+ enumerable: false,
89
+ configurable: true
90
+ });
91
+ Object.defineProperty(AcDbShape.prototype, "size", {
92
+ /**
93
+ * Gets the height of this shape.
94
+ *
95
+ * Mirrors `AcDbShape::size()` in ObjectARX.
96
+ */
97
+ get: function () {
98
+ return this._size;
99
+ },
100
+ /** Sets the height of this shape. */
101
+ set: function (value) {
102
+ this._size = value;
103
+ },
104
+ enumerable: false,
105
+ configurable: true
106
+ });
107
+ Object.defineProperty(AcDbShape.prototype, "name", {
108
+ /**
109
+ * Gets the name of the shape within the associated SHX font.
110
+ *
111
+ * Mirrors `AcDbShape::name()` in ObjectARX.
112
+ */
113
+ get: function () {
114
+ return this._name;
115
+ },
116
+ /** Sets the name of the shape within the associated SHX font. */
117
+ set: function (value) {
118
+ this._name = value;
119
+ },
120
+ enumerable: false,
121
+ configurable: true
122
+ });
123
+ Object.defineProperty(AcDbShape.prototype, "rotation", {
124
+ /**
125
+ * Gets the rotation angle of this shape in radians.
126
+ *
127
+ * The angle is relative to the X axis of the shape OCS, with positive angles
128
+ * going counterclockwise when looking down the Z axis toward the origin.
129
+ *
130
+ * Mirrors `AcDbShape::rotation()` in ObjectARX.
131
+ */
132
+ get: function () {
133
+ return this._rotation;
134
+ },
135
+ /** Sets the rotation angle of this shape in radians. */
136
+ set: function (value) {
137
+ this._rotation = value;
138
+ },
139
+ enumerable: false,
140
+ configurable: true
141
+ });
142
+ Object.defineProperty(AcDbShape.prototype, "widthFactor", {
143
+ /**
144
+ * Gets the width factor applied to this shape.
145
+ *
146
+ * Mirrors `AcDbShape::widthFactor()` in ObjectARX.
147
+ */
148
+ get: function () {
149
+ return this._widthFactor;
150
+ },
151
+ /** Sets the width factor applied to this shape. */
152
+ set: function (value) {
153
+ this._widthFactor = value;
154
+ },
155
+ enumerable: false,
156
+ configurable: true
157
+ });
158
+ Object.defineProperty(AcDbShape.prototype, "oblique", {
159
+ /**
160
+ * Gets the oblique angle of this shape in radians.
161
+ *
162
+ * Mirrors `AcDbShape::oblique()` in ObjectARX.
163
+ */
164
+ get: function () {
165
+ return this._oblique;
166
+ },
167
+ /** Sets the oblique angle of this shape in radians. */
168
+ set: function (value) {
169
+ this._oblique = value;
170
+ },
171
+ enumerable: false,
172
+ configurable: true
173
+ });
174
+ Object.defineProperty(AcDbShape.prototype, "thickness", {
175
+ /**
176
+ * Gets the thickness of this shape along {@link normal}.
177
+ *
178
+ * Mirrors `AcDbShape::thickness()` in ObjectARX.
179
+ */
180
+ get: function () {
181
+ return this._thickness;
182
+ },
183
+ /** Sets the thickness of this shape. */
184
+ set: function (value) {
185
+ this._thickness = value;
186
+ },
187
+ enumerable: false,
188
+ configurable: true
189
+ });
190
+ Object.defineProperty(AcDbShape.prototype, "normal", {
191
+ /**
192
+ * Gets the normal vector of the plane containing this shape.
193
+ *
194
+ * Mirrors `AcDbShape::normal()` in ObjectARX.
195
+ */
196
+ get: function () {
197
+ return this._normal;
198
+ },
199
+ /** Sets the normal vector of the plane containing this shape. */
200
+ set: function (value) {
201
+ this._normal.copy(value);
202
+ },
203
+ enumerable: false,
204
+ configurable: true
205
+ });
206
+ Object.defineProperty(AcDbShape.prototype, "shapeNumber", {
207
+ /**
208
+ * Gets the numeric shape code within the SHX font.
209
+ *
210
+ * Mirrors `AcDbShape::shapeNumber()` in ObjectARX.
211
+ */
212
+ get: function () {
213
+ return this._shapeNumber;
214
+ },
215
+ /** Sets the numeric shape code within the SHX font. */
216
+ set: function (value) {
217
+ this._shapeNumber = value;
218
+ },
219
+ enumerable: false,
220
+ configurable: true
221
+ });
222
+ Object.defineProperty(AcDbShape.prototype, "styleId", {
223
+ /**
224
+ * Gets the object ID of the text style table record that references this
225
+ * shape's SHX font.
226
+ *
227
+ * Mirrors `AcDbShape::styleId()` in ObjectARX.
228
+ */
229
+ get: function () {
230
+ var _a, _b, _c, _d;
231
+ var record = (_c = (_b = (_a = this.database) === null || _a === void 0 ? void 0 : _a.tables) === null || _b === void 0 ? void 0 : _b.textStyleTable) === null || _c === void 0 ? void 0 : _c.resolveAt(this._styleName);
232
+ return (_d = record === null || record === void 0 ? void 0 : record.objectId) !== null && _d !== void 0 ? _d : '';
233
+ },
234
+ /**
235
+ * Sets the text style table record by object ID.
236
+ *
237
+ * Mirrors `AcDbShape::setStyleId()` in ObjectARX.
238
+ */
239
+ set: function (value) {
240
+ var _a, _b, _c;
241
+ var record = (_c = (_b = (_a = this.database) === null || _a === void 0 ? void 0 : _a.tables) === null || _b === void 0 ? void 0 : _b.textStyleTable) === null || _c === void 0 ? void 0 : _c.getIdAt(value);
242
+ if (record) {
243
+ this._styleName = record.name;
244
+ }
245
+ },
246
+ enumerable: false,
247
+ configurable: true
248
+ });
249
+ Object.defineProperty(AcDbShape.prototype, "styleName", {
250
+ /**
251
+ * Gets the text style name associated with this shape.
252
+ *
253
+ * Used when reading or writing DXF group code 3 (shape file/style name).
254
+ */
255
+ get: function () {
256
+ return this._styleName;
257
+ },
258
+ /** Sets the text style name associated with this shape. */
259
+ set: function (value) {
260
+ this._styleName = value;
261
+ },
262
+ enumerable: false,
263
+ configurable: true
264
+ });
265
+ Object.defineProperty(AcDbShape.prototype, "isPlanar", {
266
+ /**
267
+ * Gets whether this shape is planar.
268
+ *
269
+ * Mirrors `AcDbShape::isPlanar()` in ObjectARX.
270
+ */
271
+ get: function () {
272
+ return true;
273
+ },
274
+ enumerable: false,
275
+ configurable: true
276
+ });
277
+ Object.defineProperty(AcDbShape.prototype, "geometricExtents", {
278
+ get: function () {
279
+ var half = Math.abs(this._size) / 2;
280
+ var extents = new AcGeBox3d();
281
+ extents.expandByPoint(this._position);
282
+ if (half > 0) {
283
+ extents.expandByPoint(new AcGePoint3d(this._position.x - half, this._position.y - half, this._position.z));
284
+ extents.expandByPoint(new AcGePoint3d(this._position.x + half, this._position.y + half, this._position.z));
285
+ }
286
+ return extents;
287
+ },
288
+ enumerable: false,
289
+ configurable: true
290
+ });
291
+ AcDbShape.prototype.subGetGripPoints = function () {
292
+ return [this._position];
293
+ };
294
+ AcDbShape.prototype.subGetOsnapPoints = function (osnapMode, _pickPoint, _lastPoint, snapPoints) {
295
+ if (osnapMode === AcDbOsnapMode.Insertion) {
296
+ snapPoints.push(this._position);
297
+ }
298
+ };
299
+ AcDbShape.prototype.transformBy = function (matrix) {
300
+ var extrusion = new AcGeMatrix3d().setFromExtrusionDirection(this._normal);
301
+ var rotation = new AcGeMatrix3d().makeRotationZ(this._rotation);
302
+ var localToWcs = new AcGeMatrix3d().multiplyMatrices(extrusion, rotation);
303
+ var origin = this._position.clone();
304
+ var xAxisPoint = new AcGePoint3d(this._widthFactor, 0, 0)
305
+ .applyMatrix4(localToWcs)
306
+ .add(origin);
307
+ var yAxisPoint = new AcGePoint3d(0, 1, 0)
308
+ .applyMatrix4(localToWcs)
309
+ .add(origin);
310
+ var zAxisPoint = new AcGePoint3d(0, 0, 1)
311
+ .applyMatrix4(localToWcs)
312
+ .add(origin);
313
+ origin.applyMatrix4(matrix);
314
+ xAxisPoint.applyMatrix4(matrix);
315
+ yAxisPoint.applyMatrix4(matrix);
316
+ zAxisPoint.applyMatrix4(matrix);
317
+ var xAxis = new AcGeVector3d(xAxisPoint).sub(origin);
318
+ var yAxis = new AcGeVector3d(yAxisPoint).sub(origin);
319
+ var zAxis = new AcGeVector3d(zAxisPoint).sub(origin);
320
+ var normal = new AcGeVector3d().crossVectors(xAxis, yAxis);
321
+ if (normal.lengthSq() === 0) {
322
+ normal = this._normal.clone().transformDirection(matrix);
323
+ }
324
+ else {
325
+ normal.normalize();
326
+ }
327
+ var extrusionMatrix = new AcGeMatrix3d().setFromExtrusionDirection(normal);
328
+ var ocsInverse = extrusionMatrix.clone().invert();
329
+ var localXAxis = xAxis.clone().applyMatrix4(ocsInverse);
330
+ var yScale = yAxis.length();
331
+ var xScale = xAxis.length();
332
+ this._position.copy(origin);
333
+ this._normal.copy(normal);
334
+ if (xScale > 0) {
335
+ this._rotation = Math.atan2(localXAxis.y, localXAxis.x);
336
+ }
337
+ if (yScale > 0) {
338
+ this._size *= yScale;
339
+ if (xScale > 0) {
340
+ this._widthFactor *= xScale / yScale;
341
+ }
342
+ }
343
+ var zScale = zAxis.length();
344
+ if (zScale > 0) {
345
+ this._thickness *= zScale;
346
+ }
347
+ return this;
348
+ };
349
+ Object.defineProperty(AcDbShape.prototype, "properties", {
350
+ get: function () {
351
+ var _this = this;
352
+ return {
353
+ type: this.type,
354
+ groups: [
355
+ this.getGeneralProperties(),
356
+ {
357
+ groupName: 'shape',
358
+ properties: [
359
+ {
360
+ name: 'name',
361
+ type: 'string',
362
+ editable: true,
363
+ accessor: {
364
+ get: function () { return _this.name; },
365
+ set: function (v) {
366
+ _this.name = v;
367
+ }
368
+ }
369
+ },
370
+ {
371
+ name: 'size',
372
+ type: 'float',
373
+ editable: true,
374
+ accessor: {
375
+ get: function () { return _this.size; },
376
+ set: function (v) {
377
+ _this.size = v;
378
+ }
379
+ }
380
+ },
381
+ {
382
+ name: 'rotation',
383
+ type: 'float',
384
+ editable: true,
385
+ accessor: {
386
+ get: function () { return _this.rotation; },
387
+ set: function (v) {
388
+ _this.rotation = v;
389
+ }
390
+ }
391
+ },
392
+ {
393
+ name: 'widthFactor',
394
+ type: 'float',
395
+ editable: true,
396
+ accessor: {
397
+ get: function () { return _this.widthFactor; },
398
+ set: function (v) {
399
+ _this.widthFactor = v;
400
+ }
401
+ }
402
+ },
403
+ {
404
+ name: 'oblique',
405
+ type: 'float',
406
+ editable: true,
407
+ accessor: {
408
+ get: function () { return _this.oblique; },
409
+ set: function (v) {
410
+ _this.oblique = v;
411
+ }
412
+ }
413
+ },
414
+ {
415
+ name: 'shapeNumber',
416
+ type: 'int',
417
+ editable: true,
418
+ accessor: {
419
+ get: function () { return _this.shapeNumber; },
420
+ set: function (v) {
421
+ _this.shapeNumber = v;
422
+ }
423
+ }
424
+ }
425
+ ]
426
+ },
427
+ {
428
+ groupName: 'geometry',
429
+ properties: [
430
+ {
431
+ name: 'positionX',
432
+ type: 'float',
433
+ editable: true,
434
+ accessor: {
435
+ get: function () { return _this.position.x; },
436
+ set: function (v) {
437
+ _this.position.x = v;
438
+ }
439
+ }
440
+ },
441
+ {
442
+ name: 'positionY',
443
+ type: 'float',
444
+ editable: true,
445
+ accessor: {
446
+ get: function () { return _this.position.y; },
447
+ set: function (v) {
448
+ _this.position.y = v;
449
+ }
450
+ }
451
+ },
452
+ {
453
+ name: 'positionZ',
454
+ type: 'float',
455
+ editable: true,
456
+ accessor: {
457
+ get: function () { return _this.position.z; },
458
+ set: function (v) {
459
+ _this.position.z = v;
460
+ }
461
+ }
462
+ }
463
+ ]
464
+ }
465
+ ]
466
+ };
467
+ },
468
+ enumerable: false,
469
+ configurable: true
470
+ });
471
+ AcDbShape.prototype.subWorldDraw = function (renderer, delay) {
472
+ var textStyle = this.getTextStyle();
473
+ var style = __assign(__assign({}, textStyle), { widthFactor: this.widthFactor,
474
+ // MText renderer stores oblique in degrees on the text style.
475
+ obliqueAngle: (this.oblique * 180) / Math.PI });
476
+ var shapeData = {
477
+ name: this._name.trim() || undefined,
478
+ shapeNumber: this._shapeNumber !== 0 ? this._shapeNumber : undefined,
479
+ size: this.size,
480
+ position: this._position,
481
+ rotation: this._rotation,
482
+ directionVector: this._normal,
483
+ widthFactor: this.widthFactor
484
+ };
485
+ return renderer.shape(shapeData, style, delay);
486
+ };
487
+ /**
488
+ * Gets the text style that references the SHX font for this shape.
489
+ */
490
+ AcDbShape.prototype.getTextStyle = function () {
491
+ var style = this.database.tables.textStyleTable.resolveAt(this.styleName);
492
+ if (!style) {
493
+ throw new Error('No valid text style found in text style table.');
494
+ }
495
+ return style.textStyle;
496
+ };
497
+ AcDbShape.prototype.dxfOutFields = function (filer) {
498
+ _super.prototype.dxfOutFields.call(this, filer);
499
+ filer.writeSubclassMarker('AcDbShape');
500
+ filer.writePoint3d(10, this.position);
501
+ filer.writeDouble(40, this.size);
502
+ filer.writeString(2, this.name);
503
+ filer.writeAngle(50, this.rotation);
504
+ filer.writeDouble(41, this.widthFactor);
505
+ filer.writeAngle(51, this.oblique);
506
+ filer.writeDouble(39, this.thickness);
507
+ if (this._styleName) {
508
+ filer.writeString(3, this._styleName);
509
+ }
510
+ filer.writeVector3d(210, this.normal);
511
+ return this;
512
+ };
513
+ /** The entity type name */
514
+ AcDbShape.typeName = 'Shape';
515
+ return AcDbShape;
516
+ }(AcDbEntity));
517
+ export { AcDbShape };
518
+ //# sourceMappingURL=AcDbShape.js.map