@mlightcad/libredwg-converter 3.4.8 → 3.4.9

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.
@@ -1,5 +1,5 @@
1
- import { AcDbFace as M, AcDbArc as L, AcGeVector3d as D, AcDbCircle as S, AcDbEllipse as C, AcDbLine as x, AcGePoint3d as I, AcDbSpline as w, AcDbPoint as v, AcDbTrace as O, AcDbPolyline as R, AcGePoint2d as y, AcDbPoly2dType as A, AcDb2dPolyline as k, AcDbPoly3dType as b, AcDb3dPolyline as m, AcDbHatch as V, AcGePolyline2d as N, AcGeLoop2d as F, AcGeLine2d as B, AcGeCircArc2d as j, AcGeVector2d as z, AcGeEllipseArc2d as W, AcGeSpline3d as T, AcDbTable as H, AcDbText as X, AcDbMText as G, AcDbLeader as U, AcDbAlignedDimension as Y, AcDb3PointAngularDimension as Z, AcDbOrdinateDimension as _, AcDbRadialDimension as K, AcDbDiametricDimension as q, AcDbRasterImage as J, AcDbWipeout as Q, AcDbViewport as $, AcDbRay as ee, AcDbXline as ne, AcDbBlockReference as te, AcCmTransparency as oe, AcDbDatabaseConverter as se, createWorkerApi as re, AcDbLinetypeTableRecord as ie, AcDbTextStyleTableRecord as ce, AcDbDimStyleTableRecord as ae, AcCmColor as le, AcDbLayerTableRecord as de, AcDbViewportTableRecord as pe, AcDbBlockTableRecord as ue, AcDbBatchProcessing as fe, AcDbLayout as he, AcDbRasterImageDef as De } from "@mlightcad/data-model";
2
- class E {
1
+ import { AcDbFace as S, AcDbArc as C, AcGeVector3d as D, AcDbCircle as x, AcDbEllipse as v, AcDbLine as O, AcGePoint3d as y, AcDbSpline as T, AcDbPoint as k, AcDbTrace as m, AcDbPolyline as R, AcGePoint2d as b, AcDbPoly2dType as A, AcDb2dPolyline as V, AcDbPoly3dType as w, AcDb3dPolyline as F, AcDbHatch as N, AcGePolyline2d as B, AcGeLoop2d as j, AcGeLine2d as z, AcGeCircArc2d as W, AcGeVector2d as H, AcGeEllipseArc2d as X, AcGeSpline3d as P, AcDbTable as G, AcDbText as U, AcDbMText as Y, AcDbLeader as Z, AcDbAlignedDimension as _, AcDb3PointAngularDimension as K, AcDbOrdinateDimension as q, AcDbRadialDimension as J, AcDbDiametricDimension as Q, AcDbRasterImage as $, AcDbWipeout as ee, AcDbViewport as ne, AcDbRay as te, AcDbXline as oe, AcDbAttributeFlags as I, AcDbAttributeMTextFlag as E, AcDbAttribute as se, AcDbAttributeDefinition as re, AcDbBlockReference as ie, AcCmTransparency as ce, AcDbDatabaseConverter as ae, createWorkerApi as le, AcDbLinetypeTableRecord as de, AcDbTextStyleTableRecord as pe, AcDbDimStyleTableRecord as ue, AcCmColor as fe, AcDbLayerTableRecord as he, AcDbViewportTableRecord as De, AcDbBlockTableRecord as ge, AcDbBatchProcessing as Ae, AcDbLayout as Ie, AcDbRasterImageDef as we } from "@mlightcad/data-model";
2
+ class M {
3
3
  convert(e) {
4
4
  const n = this.createEntity(e);
5
5
  return n && this.processCommonAttrs(e, n), n;
@@ -10,14 +10,14 @@ class E {
10
10
  * @returns Return the converted drawing database entity
11
11
  */
12
12
  createEntity(e) {
13
- return e.type == "3DFACE" ? this.convertFace(e) : e.type == "ARC" ? this.convertArc(e) : e.type == "CIRCLE" ? this.convertCirle(e) : e.type == "DIMENSION" ? this.convertDimension(e) : e.type == "ELLIPSE" ? this.convertEllipse(e) : e.type == "HATCH" ? this.convertHatch(e) : e.type == "IMAGE" ? this.convertImage(e) : e.type == "LEADER" ? this.convertLeader(e) : e.type == "LINE" ? this.convertLine(e) : e.type == "LWPOLYLINE" ? this.convertLWPolyline(e) : e.type == "MTEXT" ? this.convertMText(e) : e.type == "POINT" ? this.convertPoint(e) : e.type == "POLYLINE2D" ? this.convertPolyline2d(e) : e.type == "POLYLINE3D" ? this.convertPolyline3d(e) : e.type == "RAY" ? this.convertRay(e) : e.type == "SPLINE" ? this.convertSpline(e) : e.type == "ACAD_TABLE" ? this.convertTable(e) : e.type == "TEXT" ? this.convertText(e) : e.type == "SOLID" ? this.convertSolid(e) : e.type == "VIEWPORT" ? this.convertViewport(e) : e.type == "WIPEOUT" ? this.convertWipeout(e) : e.type == "XLINE" ? this.convertXline(e) : e.type == "INSERT" ? this.convertBlockReference(e) : null;
13
+ return e.type == "3DFACE" ? this.convertFace(e) : e.type == "ARC" ? this.convertArc(e) : e.type == "ATTDEF" ? this.convertAttributeDefinition(e) : e.type == "CIRCLE" ? this.convertCirle(e) : e.type == "DIMENSION" ? this.convertDimension(e) : e.type == "ELLIPSE" ? this.convertEllipse(e) : e.type == "HATCH" ? this.convertHatch(e) : e.type == "IMAGE" ? this.convertImage(e) : e.type == "LEADER" ? this.convertLeader(e) : e.type == "LINE" ? this.convertLine(e) : e.type == "LWPOLYLINE" ? this.convertLWPolyline(e) : e.type == "MTEXT" ? this.convertMText(e) : e.type == "POINT" ? this.convertPoint(e) : e.type == "POLYLINE2D" ? this.convertPolyline2d(e) : e.type == "POLYLINE3D" ? this.convertPolyline3d(e) : e.type == "RAY" ? this.convertRay(e) : e.type == "SPLINE" ? this.convertSpline(e) : e.type == "ACAD_TABLE" ? this.convertTable(e) : e.type == "TEXT" ? this.convertText(e) : e.type == "SOLID" ? this.convertSolid(e) : e.type == "VIEWPORT" ? this.convertViewport(e) : e.type == "WIPEOUT" ? this.convertWipeout(e) : e.type == "XLINE" ? this.convertXline(e) : e.type == "INSERT" ? this.convertBlockReference(e) : null;
14
14
  }
15
15
  convertFace(e) {
16
- const n = new M();
16
+ const n = new S();
17
17
  return e.corner1 && n.setVertexAt(0, e.corner1), e.corner2 && n.setVertexAt(1, e.corner2), e.corner3 && n.setVertexAt(2, e.corner3), e.corner4 && n.setVertexAt(3, e.corner4), n.setEdgeInvisibilities(e.flag), n;
18
18
  }
19
19
  convertArc(e) {
20
- return new L(
20
+ return new C(
21
21
  e.center,
22
22
  e.radius,
23
23
  e.startAngle,
@@ -26,35 +26,35 @@ class E {
26
26
  );
27
27
  }
28
28
  convertCirle(e) {
29
- return new S(
29
+ return new x(
30
30
  e.center,
31
31
  e.radius,
32
32
  e.extrusionDirection ?? D.Z_AXIS
33
33
  );
34
34
  }
35
35
  convertEllipse(e) {
36
- const n = new D(e.majorAxisEndPoint), s = n.length();
37
- return new C(
36
+ const n = new D(e.majorAxisEndPoint), o = n.length();
37
+ return new v(
38
38
  e.center,
39
39
  e.extrusionDirection ?? D.Z_AXIS,
40
40
  n,
41
- s,
42
- s * e.axisRatio,
41
+ o,
42
+ o * e.axisRatio,
43
43
  e.startAngle,
44
44
  e.endAngle
45
45
  );
46
46
  }
47
47
  convertLine(e) {
48
- const n = e.startPoint, s = e.endPoint;
49
- return new x(
50
- new I(n.x, n.y, n.z),
51
- new I(s.x, s.y, s.z)
48
+ const n = e.startPoint, o = e.endPoint;
49
+ return new O(
50
+ new y(n.x, n.y, n.z),
51
+ new y(o.x, o.y, o.z)
52
52
  );
53
53
  }
54
54
  convertSpline(e) {
55
55
  try {
56
56
  if (e.numberOfControlPoints > 0 && e.numberOfKnots > 0)
57
- return new w(
57
+ return new T(
58
58
  e.controlPoints,
59
59
  e.knots,
60
60
  e.weights,
@@ -62,7 +62,7 @@ class E {
62
62
  !!(e.flag & 1)
63
63
  );
64
64
  if (e.numberOfFitPoints > 0)
65
- return new w(
65
+ return new T(
66
66
  e.fitPoints,
67
67
  "Uniform",
68
68
  e.degree,
@@ -74,11 +74,11 @@ class E {
74
74
  return null;
75
75
  }
76
76
  convertPoint(e) {
77
- const n = new v();
77
+ const n = new k();
78
78
  return n.position = e.position, n;
79
79
  }
80
80
  convertSolid(e) {
81
- const n = new O();
81
+ const n = new m();
82
82
  return n.setPointAt(0, { ...e.corner1, z: 0 }), n.setPointAt(1, { ...e.corner2, z: 0 }), n.setPointAt(2, { ...e.corner3, z: 0 }), n.setPointAt(
83
83
  3,
84
84
  e.corner4 ? { ...e.corner4, z: 0 } : { ...e.corner3, z: 0 }
@@ -86,29 +86,29 @@ class E {
86
86
  }
87
87
  convertLWPolyline(e) {
88
88
  const n = new R();
89
- return n.closed = !!(e.flag & 512), e.vertices.forEach((s, t) => {
89
+ return n.closed = !!(e.flag & 512), e.vertices.forEach((o, t) => {
90
90
  n.addVertexAt(
91
91
  t,
92
- new y(s.x, s.y),
93
- s.bulge,
94
- s.startWidth,
95
- s.endWidth
92
+ new b(o.x, o.y),
93
+ o.bulge,
94
+ o.startWidth,
95
+ o.endWidth
96
96
  );
97
97
  }), n;
98
98
  }
99
99
  convertPolyline2d(e) {
100
- const n = !!(e.flag & 1), s = [], t = [];
100
+ const n = !!(e.flag & 1), o = [], t = [];
101
101
  e.vertices.map((r) => {
102
- r.flag & 16 || (s.push({
102
+ r.flag & 16 || (o.push({
103
103
  x: r.x,
104
104
  y: r.y,
105
105
  z: r.z
106
106
  }), t.push(r.bulge ?? 0));
107
107
  });
108
- let o = A.SimplePoly;
109
- return e.flag & 2 ? o = A.FitCurvePoly : e.flag & 4 && (e.smoothType == 6 ? o = A.CubicSplinePoly : e.smoothType == 5 && (o = A.QuadSplinePoly)), new k(
110
- o,
108
+ let s = A.SimplePoly;
109
+ return e.flag & 2 ? s = A.FitCurvePoly : e.flag & 4 && (e.smoothType == 6 ? s = A.CubicSplinePoly : e.smoothType == 5 && (s = A.QuadSplinePoly)), new V(
111
110
  s,
111
+ o,
112
112
  0,
113
113
  n,
114
114
  e.startWidth,
@@ -117,30 +117,30 @@ class E {
117
117
  );
118
118
  }
119
119
  convertPolyline3d(e) {
120
- const n = !!(e.flag & 1), s = [];
121
- e.vertices.map((o) => {
122
- o.flag & 16 || s.push({
123
- x: o.x,
124
- y: o.y,
125
- z: o.z
120
+ const n = !!(e.flag & 1), o = [];
121
+ e.vertices.map((s) => {
122
+ s.flag & 16 || o.push({
123
+ x: s.x,
124
+ y: s.y,
125
+ z: s.z
126
126
  });
127
127
  });
128
- let t = b.SimplePoly;
129
- return e.flag & 4 && (e.smoothType == 6 ? t = b.CubicSplinePoly : e.smoothType == 5 && (t = b.QuadSplinePoly)), new m(t, s, n);
128
+ let t = w.SimplePoly;
129
+ return e.flag & 4 && (e.smoothType == 6 ? t = w.CubicSplinePoly : e.smoothType == 5 && (t = w.QuadSplinePoly)), new F(t, o, n);
130
130
  }
131
131
  convertHatch(e) {
132
132
  var t;
133
- const n = new V();
134
- return (t = e.definitionLines) == null || t.forEach((o) => {
133
+ const n = new N();
134
+ return (t = e.definitionLines) == null || t.forEach((s) => {
135
135
  n.definitionLines.push({
136
- angle: o.angle,
137
- base: o.base,
138
- offset: o.offset,
139
- dashLengths: o.numberOfDashLengths > 0 ? o.dashLengths : []
136
+ angle: s.angle,
137
+ base: s.base,
138
+ offset: s.offset,
139
+ dashLengths: s.numberOfDashLengths > 0 ? s.dashLengths : []
140
140
  });
141
- }), n.isSolidFill = e.solidFill == 1, n.hatchStyle = e.hatchStyle, n.patternName = e.patternName, n.patternType = e.patternType, n.patternAngle = e.patternAngle == null ? 0 : e.patternAngle, n.patternScale = e.patternScale == null ? 0 : e.patternScale, e.boundaryPaths.forEach((o) => {
142
- if (o.boundaryPathTypeFlag & 2) {
143
- const a = o, i = new N();
141
+ }), n.isSolidFill = e.solidFill == 1, n.hatchStyle = e.hatchStyle, n.patternName = e.patternName, n.patternType = e.patternType, n.patternAngle = e.patternAngle == null ? 0 : e.patternAngle, n.patternScale = e.patternScale == null ? 0 : e.patternScale, e.boundaryPaths.forEach((s) => {
142
+ if (s.boundaryPathTypeFlag & 2) {
143
+ const a = s, i = new B();
144
144
  i.closed = a.isClosed, a.vertices.forEach((l, c) => {
145
145
  i.addVertexAt(c, {
146
146
  x: l.x,
@@ -149,16 +149,16 @@ class E {
149
149
  });
150
150
  }), n.add(i);
151
151
  } else {
152
- const a = o, i = new F();
152
+ const a = s, i = new j();
153
153
  a.edges.forEach((l) => {
154
154
  if (l != null) {
155
155
  if (l.type == 1) {
156
156
  const c = l;
157
- i.add(new B(c.start, c.end));
157
+ i.add(new z(c.start, c.end));
158
158
  } else if (l.type == 2) {
159
159
  const c = l;
160
160
  i.add(
161
- new j(
161
+ new W(
162
162
  c.center,
163
163
  c.radius,
164
164
  c.startAngle,
@@ -168,14 +168,14 @@ class E {
168
168
  );
169
169
  } else if (l.type == 3) {
170
170
  const c = l;
171
- new z().subVectors(c.end, c.center);
171
+ new H().subVectors(c.end, c.center);
172
172
  const p = Math.sqrt(
173
173
  Math.pow(c.end.x, 2) + Math.pow(c.end.y, 2)
174
174
  ), f = p * c.lengthOfMinorAxis;
175
175
  let d = c.startAngle, h = c.endAngle;
176
176
  const g = Math.atan2(c.end.y, c.end.x);
177
177
  c.isCCW || (d = Math.PI * 2 - d, h = Math.PI * 2 - h), i.add(
178
- new W(
178
+ new X(
179
179
  { ...c.center, z: 0 },
180
180
  p,
181
181
  f,
@@ -198,7 +198,7 @@ class E {
198
198
  let p = !0;
199
199
  const f = c.controlPoints.map((d) => (d.weight == null && (p = !1), d.weight || 1));
200
200
  i.add(
201
- new T(
201
+ new P(
202
202
  u,
203
203
  c.knots,
204
204
  p ? f : void 0
@@ -210,7 +210,7 @@ class E {
210
210
  y: p.y,
211
211
  z: 0
212
212
  }));
213
- i.add(new T(u, "Uniform"));
213
+ i.add(new P(u, "Uniform"));
214
214
  }
215
215
  }
216
216
  }
@@ -219,79 +219,79 @@ class E {
219
219
  }), n;
220
220
  }
221
221
  convertTable(e) {
222
- const n = new H(
222
+ const n = new G(
223
223
  e.name,
224
224
  e.rowCount,
225
225
  e.columnCount
226
226
  );
227
227
  return n.attachmentPoint = e.attachmentPoint, n.position.copy(e.startPoint), e.columnWidthArr.forEach(
228
- (s, t) => n.setColumnWidth(t, s)
228
+ (o, t) => n.setColumnWidth(t, o)
229
229
  ), e.rowHeightArr.forEach(
230
- (s, t) => n.setRowHeight(t, s)
231
- ), e.cells.forEach((s, t) => {
232
- n.setCell(t, s);
230
+ (o, t) => n.setRowHeight(t, o)
231
+ ), e.cells.forEach((o, t) => {
232
+ n.setCell(t, o);
233
233
  }), n;
234
234
  }
235
235
  convertText(e) {
236
- const n = new X();
236
+ const n = new U();
237
237
  return n.textString = e.text, n.styleName = e.styleName, n.height = e.textHeight, n.position.copy(e.startPoint), n.rotation = e.rotation, n.oblique = e.obliqueAngle ?? 0, n.thickness = e.thickness, n.horizontalMode = e.halign, n.verticalMode = e.valign, n.widthFactor = e.xScale ?? 1, n;
238
238
  }
239
239
  convertMText(e) {
240
- const n = new G();
240
+ const n = new Y();
241
241
  return n.contents = e.text, e.styleName != null && (n.styleName = e.styleName), n.height = e.textHeight, n.width = e.rectWidth, n.rotation = e.rotation || 0, n.location = e.insertionPoint, n.attachmentPoint = e.attachmentPoint, e.direction && (n.direction = new D(e.direction)), n.drawingDirection = e.drawingDirection, n;
242
242
  }
243
243
  convertLeader(e) {
244
- const n = new U();
245
- return e.vertices.forEach((s) => {
246
- n.appendVertex(s);
244
+ const n = new Z();
245
+ return e.vertices.forEach((o) => {
246
+ n.appendVertex(o);
247
247
  }), n.hasArrowHead = e.isArrowheadEnabled, n.hasHookLine = e.isHooklineExists, n.isSplined = e.isSpline, n.dimensionStyle = e.styleName, n.annoType = e.leaderCreationFlag, n;
248
248
  }
249
249
  convertDimension(e) {
250
250
  if (e.subclassMarker == "AcDbAlignedDimension" || e.subclassMarker == "AcDbRotatedDimension") {
251
- const n = e, s = new Y(
251
+ const n = e, o = new _(
252
252
  n.subDefinitionPoint1,
253
253
  n.subDefinitionPoint2,
254
254
  n.definitionPoint
255
255
  );
256
- return n.insertionPoint && (s.dimBlockPosition = {
256
+ return n.insertionPoint && (o.dimBlockPosition = {
257
257
  x: n.insertionPoint.x,
258
258
  y: n.insertionPoint.y,
259
259
  z: 0
260
- }), s.rotation = n.rotationAngle, this.processDimensionCommonAttrs(e, s), s;
260
+ }), o.rotation = n.rotationAngle, this.processDimensionCommonAttrs(e, o), o;
261
261
  } else if (e.subclassMarker == "AcDb3PointAngularDimension") {
262
- const n = e, s = new Z(
262
+ const n = e, o = new K(
263
263
  n.centerPoint,
264
264
  n.subDefinitionPoint1,
265
265
  n.subDefinitionPoint2,
266
266
  n.definitionPoint
267
267
  );
268
- return this.processDimensionCommonAttrs(e, s), s;
268
+ return this.processDimensionCommonAttrs(e, o), o;
269
269
  } else if (e.subclassMarker == "AcDbOrdinateDimension") {
270
- const n = e, s = new _(
270
+ const n = e, o = new q(
271
271
  n.subDefinitionPoint1,
272
272
  n.subDefinitionPoint2
273
273
  );
274
- return this.processDimensionCommonAttrs(e, s), s;
274
+ return this.processDimensionCommonAttrs(e, o), o;
275
275
  } else if (e.subclassMarker == "AcDbRadialDimension") {
276
- const n = e, s = new K(
276
+ const n = e, o = new J(
277
277
  n.definitionPoint,
278
278
  n.centerPoint,
279
279
  n.leaderLength
280
280
  );
281
- return this.processDimensionCommonAttrs(e, s), s;
281
+ return this.processDimensionCommonAttrs(e, o), o;
282
282
  } else if (e.subclassMarker == "AcDbDiametricDimension") {
283
- const n = e, s = new q(
283
+ const n = e, o = new Q(
284
284
  n.definitionPoint,
285
285
  n.centerPoint,
286
286
  n.leaderLength
287
287
  );
288
- return this.processDimensionCommonAttrs(e, s), s;
288
+ return this.processDimensionCommonAttrs(e, o), o;
289
289
  }
290
290
  return null;
291
291
  }
292
292
  processImage(e, n) {
293
- n.position.copy(e.position), n.brightness = e.brightness, n.contrast = e.contrast, n.fade = e.fade, n.imageDefId = e.imageDefHandle, n.isClipped = e.clipping > 0, n.isShownClipped = (e.flags | 4) > 0, n.isImageShown = (e.flags | 3) > 0, n.isImageTransparent = (e.flags | 8) > 0, e.clippingBoundaryPath.forEach((s) => {
294
- n.clipBoundary.push(new y(s));
293
+ n.position.copy(e.position), n.brightness = e.brightness, n.contrast = e.contrast, n.fade = e.fade, n.imageDefId = e.imageDefHandle, n.isClipped = e.clipping > 0, n.isShownClipped = (e.flags | 4) > 0, n.isImageShown = (e.flags | 3) > 0, n.isImageTransparent = (e.flags | 8) > 0, e.clippingBoundaryPath.forEach((o) => {
294
+ n.clipBoundary.push(new b(o));
295
295
  }), n.clipBoundaryType = e.clippingBoundaryType, n.width = Math.sqrt(
296
296
  e.uPixel.x ** 2 + e.uPixel.y ** 2 + e.uPixel.z ** 2
297
297
  ) * e.imageSize.x, n.height = Math.sqrt(
@@ -299,55 +299,70 @@ class E {
299
299
  ) * e.imageSize.y, n.rotation = Math.atan2(e.uPixel.y, e.uPixel.x);
300
300
  }
301
301
  convertImage(e) {
302
- const n = new J();
302
+ const n = new $();
303
303
  return this.processImage(e, n), n;
304
304
  }
305
305
  convertWipeout(e) {
306
- const n = new Q();
306
+ const n = new ee();
307
307
  return this.processImage(e, n), n;
308
308
  }
309
309
  convertViewport(e) {
310
- const n = new $();
310
+ const n = new ne();
311
311
  return n.number = e.viewportId, n.centerPoint.copy(e.viewportCenter), n.height = e.height, n.width = e.width, n.viewCenter.copy(e.displayCenter), n.viewHeight = e.viewHeight, n;
312
312
  }
313
313
  convertRay(e) {
314
- const n = new ee();
314
+ const n = new te();
315
315
  return n.basePoint.copy(e.firstPoint), n.unitDir.copy(e.unitDirection), n;
316
316
  }
317
317
  convertXline(e) {
318
- const n = new ne();
318
+ const n = new oe();
319
319
  return n.basePoint.copy(e.firstPoint), n.unitDir.copy(e.unitDirection), n;
320
320
  }
321
+ convertAttributeCommon(e, n) {
322
+ const o = e.text;
323
+ n.textString = o.text, n.styleName = o.styleName, n.height = o.textHeight, n.position.copy(o.startPoint), n.rotation = o.rotation, n.oblique = o.obliqueAngle ?? 0, n.thickness = o.thickness, n.horizontalMode = o.halign, n.verticalMode = o.valign, n.widthFactor = o.xScale ?? 1, n.tag = e.tag, n.fieldLength = e.fieldLength, n.isInvisible = (e.flags & I.Invisible) !== 0, n.isConst = (e.flags & I.Const) !== 0, n.isVerifiable = (e.flags & I.Verifiable) !== 0, n.isPreset = (e.flags & I.Preset) !== 0, n.lockPositionInBlock = e.lockPositionFlag, n.isReallyLocked = e.isReallyLocked, n.isMTextAttribute = (e.mtextFlag & E.MultiLine) !== 0, n.isConstMTextAttribute = (e.mtextFlag & E.ConstMultiLine) !== 0;
324
+ }
325
+ convertAttribute(e) {
326
+ const n = new se();
327
+ return this.convertAttributeCommon(e, n), n;
328
+ }
329
+ convertAttributeDefinition(e) {
330
+ const n = new re();
331
+ return this.convertAttributeCommon(e, n), n.prompt = e.prompt, n;
332
+ }
321
333
  convertBlockReference(e) {
322
- const n = new te(e.name);
323
- return e.insertionPoint && n.position.copy(e.insertionPoint), n.scaleFactors.x = e.xScale, n.scaleFactors.y = e.yScale, n.scaleFactors.z = e.zScale, n.rotation = e.rotation, n.normal.copy(e.extrusionDirection), n;
334
+ const n = new ie(e.name);
335
+ return e.insertionPoint && n.position.copy(e.insertionPoint), n.scaleFactors.x = e.xScale, n.scaleFactors.y = e.yScale, n.scaleFactors.z = e.zScale, n.rotation = e.rotation, n.normal.copy(e.extrusionDirection), e.attribs.forEach((o) => {
336
+ const t = this.convertAttribute(o);
337
+ n.appendAttributes(t);
338
+ }), n;
324
339
  }
325
340
  processDimensionCommonAttrs(e, n) {
326
341
  n.dimBlockId = e.name, n.textPosition.copy(e.textPoint), n.textRotation = e.textRotation || 0, e.textLineSpacingFactor && (n.textLineSpacingFactor = e.textLineSpacingFactor), e.textLineSpacingStyle && (n.textLineSpacingStyle = e.textLineSpacingStyle), n.dimensionStyleName = e.styleName, n.dimensionText = e.text || "", n.measurement = e.measurement;
327
342
  }
328
343
  processCommonAttrs(e, n) {
329
344
  if (n.layer = e.layer || "0", n.objectId = e.handle, n.ownerId = e.ownerBlockRecordSoftId, e.lineType != null && (n.lineType = e.lineType), e.lineweight != null && (n.lineWeight = e.lineweight), e.lineTypeScale != null && (n.linetypeScale = e.lineTypeScale), e.color != null && n.color.setRGBValue(e.color), e.colorIndex != null && (n.color.colorIndex = e.colorIndex), e.colorName && (n.color.colorName = e.colorName), e.isVisible != null && (n.visibility = e.isVisible), e.transparency != null) {
330
- const s = new oe();
331
- s.method = e.transparencyType, (s.isByBlock || s.isByBlock) && (s.alpha = e.transparency), n.transparency = s;
345
+ const o = new ce();
346
+ o.method = e.transparencyType, (o.isByBlock || o.isByBlock) && (o.alpha = e.transparency), n.transparency = o;
332
347
  }
333
348
  }
334
349
  }
335
- const ge = "*MODEL_SPACE";
336
- class be extends se {
350
+ const ye = "*MODEL_SPACE";
351
+ class be extends ae {
337
352
  constructor(e = {}) {
338
353
  super(e), e.useWorker = !0, e.parserWorkerUrl || (e.parserWorkerUrl = "/assets/libredwg-parser-worker.js");
339
354
  }
340
355
  async parse(e) {
341
356
  if (this.config.useWorker && this.config.parserWorkerUrl) {
342
- const n = re({
357
+ const n = le({
343
358
  workerUrl: this.config.parserWorkerUrl,
344
359
  // One concurrent worker needed for parser
345
360
  maxConcurrentWorkers: 1
346
- }), s = await n.execute(e);
347
- if (n.destroy(), s.success)
348
- return s.data;
361
+ }), o = await n.execute(e);
362
+ if (n.destroy(), o.success)
363
+ return o.data;
349
364
  throw new Error(
350
- `Failed to parse drawing due to error: '${s.error}'`
365
+ `Failed to parse drawing due to error: '${o.error}'`
351
366
  );
352
367
  } else
353
368
  throw new Error("dwg converter can run in web worker only!");
@@ -362,7 +377,7 @@ class be extends se {
362
377
  e.tables.BLOCK_RECORD.entries.forEach((r) => {
363
378
  n.set(r.name, r);
364
379
  });
365
- const s = /* @__PURE__ */ new Map(), t = (r) => {
380
+ const o = /* @__PURE__ */ new Map(), t = (r) => {
366
381
  if (r) {
367
382
  const a = r.lastIndexOf(".");
368
383
  return a >= 0 ? r.substring(0, a).toLowerCase() : r.toLowerCase();
@@ -371,54 +386,54 @@ class be extends se {
371
386
  e.tables.STYLE.entries.forEach((r) => {
372
387
  const a = [];
373
388
  let i = t(r.font);
374
- i && a.push(i), i = t(r.bigFont), i && a.push(i), s.set(r.name, a);
389
+ i && a.push(i), i = t(r.bigFont), i && a.push(i), o.set(r.name, a);
375
390
  });
376
- const o = /* @__PURE__ */ new Set();
377
- return this.getFontsInBlock(e.entities, n, s, o), Array.from(o);
391
+ const s = /* @__PURE__ */ new Set();
392
+ return this.getFontsInBlock(e.entities, n, o, s), Array.from(s);
378
393
  }
379
394
  /**
380
395
  * Iterate entities in model space to get fonts used by text, mtext and insert entities
381
396
  */
382
- getFontsInBlock(e, n, s, t) {
383
- const o = /\\f(.*?)\|/g;
397
+ getFontsInBlock(e, n, o, t) {
398
+ const s = /\\f(.*?)\|/g;
384
399
  e.forEach((r) => {
385
400
  if (r.type == "MTEXT") {
386
401
  const a = r;
387
- [...a.text.matchAll(o)].forEach((l) => {
402
+ [...a.text.matchAll(s)].forEach((l) => {
388
403
  t.add(l[1].toLowerCase());
389
404
  });
390
- const i = s.get(a.styleName);
405
+ const i = o.get(a.styleName);
391
406
  i == null || i.forEach((l) => t.add(l));
392
407
  } else if (r.type == "TEXT") {
393
- const a = r, i = s.get(a.styleName);
408
+ const a = r, i = o.get(a.styleName);
394
409
  i == null || i.forEach((l) => t.add(l));
395
410
  } else if (r.type == "INSERT") {
396
411
  const a = r, i = n.get(a.name);
397
- i && this.getFontsInBlock(i.entities, n, s, t);
412
+ i && this.getFontsInBlock(i.entities, n, o, t);
398
413
  }
399
414
  });
400
415
  }
401
416
  processLineTypes(e, n) {
402
417
  e.tables.LTYPE.entries.forEach((t) => {
403
- const o = {
418
+ const s = {
404
419
  name: t.name,
405
420
  description: t.description,
406
421
  standardFlag: t.standardFlag,
407
422
  totalPatternLength: t.totalPatternLength,
408
423
  pattern: t.pattern
409
- }, r = new ie(o);
424
+ }, r = new de(s);
410
425
  this.processCommonTableEntryAttrs(t, r), r.name = t.name, n.tables.linetypeTable.add(r);
411
426
  });
412
427
  }
413
428
  processTextStyles(e, n) {
414
429
  e.tables.STYLE.entries.forEach((t) => {
415
- const o = new ce(t);
416
- this.processCommonTableEntryAttrs(t, o), n.tables.textStyleTable.add(o);
430
+ const s = new pe(t);
431
+ this.processCommonTableEntryAttrs(t, s), n.tables.textStyleTable.add(s);
417
432
  });
418
433
  }
419
434
  processDimStyles(e, n) {
420
435
  e.tables.DIMSTYLE.entries.forEach((t) => {
421
- const o = {
436
+ const s = {
422
437
  name: t.name,
423
438
  ownerId: t.ownerHandle,
424
439
  dimpost: t.DIMPOST || "",
@@ -492,21 +507,21 @@ class be extends se {
492
507
  // TODO: Set correct value
493
508
  dimlwd: t.DIMLWD,
494
509
  dimlwe: t.DIMLWE
495
- }, r = new ae(o);
510
+ }, r = new ue(s);
496
511
  this.processCommonTableEntryAttrs(t, r), n.tables.dimStyleTable.add(r);
497
512
  });
498
513
  }
499
514
  processLayers(e, n) {
500
515
  e.tables.LAYER.entries.forEach((t) => {
501
- const o = new le();
502
- o.colorIndex = t.colorIndex;
503
- const r = new de({
516
+ const s = new fe();
517
+ s.colorIndex = t.colorIndex;
518
+ const r = new he({
504
519
  name: t.name,
505
520
  standardFlags: t.standardFlag,
506
521
  linetype: t.lineType,
507
522
  lineWeight: t.lineweight,
508
523
  isOff: t.off,
509
- color: o,
524
+ color: s,
510
525
  isPlottable: t.plotFlag != 0
511
526
  });
512
527
  this.processCommonTableEntryAttrs(t, r), n.tables.layerTable.add(r);
@@ -514,41 +529,41 @@ class be extends se {
514
529
  }
515
530
  processViewports(e, n) {
516
531
  e.tables.VPORT.entries.forEach((t) => {
517
- const o = new pe();
518
- this.processCommonTableEntryAttrs(t, o), t.circleSides && (o.circleSides = t.circleSides), o.standardFlag = t.standardFlag, o.center.copy(t.center), o.lowerLeftCorner.copy(t.lowerLeftCorner), o.upperRightCorner.copy(t.upperRightCorner), t.snapBasePoint && o.snapBase.copy(t.snapBasePoint), t.snapRotationAngle && (o.snapAngle = t.snapRotationAngle), t.snapSpacing && o.snapIncrements.copy(t.snapSpacing), t.majorGridLines && (o.gridMajor = t.majorGridLines), t.gridSpacing && o.gridIncrements.copy(t.gridSpacing), t.backgroundObjectId && (o.backgroundObjectId = t.backgroundObjectId), o.gsView.center.copy(t.center), o.gsView.viewDirectionFromTarget.copy(t.viewDirectionFromTarget), o.gsView.viewTarget.copy(t.viewTarget), t.lensLength && (o.gsView.lensLength = t.lensLength), t.frontClippingPlane && (o.gsView.frontClippingPlane = t.frontClippingPlane), t.backClippingPlane && (o.gsView.backClippingPlane = t.backClippingPlane), t.viewHeight && (o.gsView.viewHeight = t.viewHeight), t.viewTwistAngle && (o.gsView.viewTwistAngle = t.viewTwistAngle), t.frozenLayers && (o.gsView.frozenLayers = t.frozenLayers), t.styleSheet && (o.gsView.styleSheet = t.styleSheet), t.renderMode && (o.gsView.renderMode = t.renderMode), t.viewMode && (o.gsView.viewMode = t.viewMode), t.ucsIconSetting && (o.gsView.ucsIconSetting = t.ucsIconSetting), t.ucsOrigin && o.gsView.ucsOrigin.copy(t.ucsOrigin), t.ucsXAxis && o.gsView.ucsXAxis.copy(t.ucsXAxis), t.ucsYAxis && o.gsView.ucsYAxis.copy(t.ucsYAxis), t.orthographicType && (o.gsView.orthographicType = t.orthographicType), t.shadePlotSetting && (o.gsView.shadePlotSetting = t.shadePlotSetting), t.shadePlotObjectId && (o.gsView.shadePlotObjectId = t.shadePlotObjectId), t.visualStyleObjectId && (o.gsView.visualStyleObjectId = t.visualStyleObjectId), t.isDefaultLightingOn && (o.gsView.isDefaultLightingOn = t.isDefaultLightingOn), t.defaultLightingType && (o.gsView.defaultLightingType = t.defaultLightingType), t.brightness && (o.gsView.brightness = t.brightness), t.contrast && (o.gsView.contrast = t.contrast), t.ambientColor && (o.gsView.ambientColor = t.ambientColor), n.tables.viewportTable.add(o);
532
+ const s = new De();
533
+ this.processCommonTableEntryAttrs(t, s), t.circleSides && (s.circleSides = t.circleSides), s.standardFlag = t.standardFlag, s.center.copy(t.center), s.lowerLeftCorner.copy(t.lowerLeftCorner), s.upperRightCorner.copy(t.upperRightCorner), t.snapBasePoint && s.snapBase.copy(t.snapBasePoint), t.snapRotationAngle && (s.snapAngle = t.snapRotationAngle), t.snapSpacing && s.snapIncrements.copy(t.snapSpacing), t.majorGridLines && (s.gridMajor = t.majorGridLines), t.gridSpacing && s.gridIncrements.copy(t.gridSpacing), t.backgroundObjectId && (s.backgroundObjectId = t.backgroundObjectId), s.gsView.center.copy(t.center), s.gsView.viewDirectionFromTarget.copy(t.viewDirectionFromTarget), s.gsView.viewTarget.copy(t.viewTarget), t.lensLength && (s.gsView.lensLength = t.lensLength), t.frontClippingPlane && (s.gsView.frontClippingPlane = t.frontClippingPlane), t.backClippingPlane && (s.gsView.backClippingPlane = t.backClippingPlane), t.viewHeight && (s.gsView.viewHeight = t.viewHeight), t.viewTwistAngle && (s.gsView.viewTwistAngle = t.viewTwistAngle), t.frozenLayers && (s.gsView.frozenLayers = t.frozenLayers), t.styleSheet && (s.gsView.styleSheet = t.styleSheet), t.renderMode && (s.gsView.renderMode = t.renderMode), t.viewMode && (s.gsView.viewMode = t.viewMode), t.ucsIconSetting && (s.gsView.ucsIconSetting = t.ucsIconSetting), t.ucsOrigin && s.gsView.ucsOrigin.copy(t.ucsOrigin), t.ucsXAxis && s.gsView.ucsXAxis.copy(t.ucsXAxis), t.ucsYAxis && s.gsView.ucsYAxis.copy(t.ucsYAxis), t.orthographicType && (s.gsView.orthographicType = t.orthographicType), t.shadePlotSetting && (s.gsView.shadePlotSetting = t.shadePlotSetting), t.shadePlotObjectId && (s.gsView.shadePlotObjectId = t.shadePlotObjectId), t.visualStyleObjectId && (s.gsView.visualStyleObjectId = t.visualStyleObjectId), t.isDefaultLightingOn && (s.gsView.isDefaultLightingOn = t.isDefaultLightingOn), t.defaultLightingType && (s.gsView.defaultLightingType = t.defaultLightingType), t.brightness && (s.gsView.brightness = t.brightness), t.contrast && (s.gsView.contrast = t.contrast), t.ambientColor && (s.gsView.ambientColor = t.ambientColor), n.tables.viewportTable.add(s);
519
534
  });
520
535
  }
521
536
  processBlockTables(e, n) {
522
537
  e.tables.BLOCK_RECORD.entries.forEach((t) => {
523
- let o = n.tables.blockTable.getAt(t.name);
524
- o || (o = new ue(), o.objectId = t.handle, o.name = t.name, o.ownerId = t.ownerHandle, o.origin.copy(t.basePoint), o.layoutId = t.layout, n.tables.blockTable.add(o)), !o.isModelSapce && t.entities && t.entities.length > 0 && this.processEntitiesInBlock(t.entities, o);
538
+ let s = n.tables.blockTable.getAt(t.name);
539
+ s || (s = new ge(), s.objectId = t.handle, s.name = t.name, s.ownerId = t.ownerHandle, s.origin.copy(t.basePoint), s.layoutId = t.layout, n.tables.blockTable.add(s)), !s.isModelSapce && t.entities && t.entities.length > 0 && this.processEntitiesInBlock(t.entities, s);
525
540
  });
526
541
  }
527
542
  processBlocks(e, n) {
528
543
  }
529
544
  async processEntitiesInBlock(e, n) {
530
- const s = new E(), t = e.length, o = [];
545
+ const o = new M(), t = e.length, s = [];
531
546
  for (let r = 0; r < t; r++) {
532
- const a = e[r], i = s.convert(a);
533
- i && o.push(i);
547
+ const a = e[r], i = o.convert(a);
548
+ i && s.push(i);
534
549
  }
535
- n.appendEntity(o);
550
+ n.appendEntity(s);
536
551
  }
537
552
  /**
538
553
  * Breaks up the work into smaller chunks that are executed asynchronously. This is often referred to
539
554
  * as "batch processing" or "cooperative multitasking," where the time-consuming task is broken into
540
555
  * smaller pieces and executed in small intervals to allow the UI to remain responsive.
541
556
  */
542
- async processEntities(e, n, s, t, o) {
543
- const r = new E();
557
+ async processEntities(e, n, o, t, s) {
558
+ const r = new M();
544
559
  let a = [];
545
560
  e.tables.BLOCK_RECORD.entries.forEach((u) => {
546
561
  this.isModelSpace(u.name) && (a = u.entities);
547
562
  });
548
- const i = a.length, l = new fe(
563
+ const i = a.length, l = new Ae(
549
564
  i,
550
565
  100 - t.value,
551
- s
566
+ o
552
567
  );
553
568
  this.config.convertByEntityType && (a = this.groupAndFlattenByType(a));
554
569
  const c = n.tables.blockTable.modelSpace;
@@ -558,15 +573,15 @@ class be extends se {
558
573
  const h = a[d], g = r.convert(h);
559
574
  g && f.push(g);
560
575
  }
561
- if (c.appendEntity(f), o) {
576
+ if (c.appendEntity(f), s) {
562
577
  let d = t.value + p / i * (100 - t.value);
563
- d > 100 && (d = 100), await o(d, "ENTITY", "IN-PROGRESS");
578
+ d > 100 && (d = 100), await s(d, "ENTITY", "IN-PROGRESS");
564
579
  }
565
580
  });
566
581
  }
567
582
  processHeader(e, n) {
568
- const s = e.header;
569
- s.CECOLOR && (s.CECOLOR.index >= 0 && s.CECOLOR.index <= 256 ? n.cecolor.colorIndex = s.CECOLOR.index : n.cecolor.setRGBValue(s.CECOLOR.rgb)), n.angBase = s.ANGBASE ?? 0, n.angDir = s.ANGDIR ?? 0, n.aunits = s.AUNITS ?? 0, n.celtscale = s.CELTSCALE ?? 1, n.ltscale = s.LTSCALE ?? 1, s.EXTMAX && (n.extmax = s.EXTMAX), s.EXTMIN && (n.extmin = s.EXTMIN), n.insunits = s.INSUNITS ?? 1, n.pdmode = s.PDMODE ?? 0, n.pdsize = s.PDSIZE ?? 0;
583
+ const o = e.header;
584
+ o.CECOLOR && (o.CECOLOR.index >= 0 && o.CECOLOR.index <= 256 ? n.cecolor.colorIndex = o.CECOLOR.index : n.cecolor.setRGBValue(o.CECOLOR.rgb)), n.angBase = o.ANGBASE ?? 0, n.angDir = o.ANGDIR ?? 0, n.aunits = o.AUNITS ?? 0, n.celtscale = o.CELTSCALE ?? 1, n.ltscale = o.LTSCALE ?? 1, o.EXTMAX && (n.extmax = o.EXTMAX), o.EXTMIN && (n.extmin = o.EXTMIN), n.insunits = o.INSUNITS ?? 1, n.pdmode = o.PDMODE ?? 0, n.pdsize = o.PDSIZE ?? 0;
570
585
  }
571
586
  processCommonTableEntryAttrs(e, n) {
572
587
  n.name = e.name, n.objectId = e.handle, n.ownerId = e.ownerHandle;
@@ -575,25 +590,25 @@ class be extends se {
575
590
  this.processLayouts(e, n), this.processImageDefs(e, n);
576
591
  }
577
592
  processLayouts(e, n) {
578
- const s = n.dictionaries.layouts;
579
- e.objects.LAYOUT.forEach((o) => {
580
- const r = new he();
581
- r.layoutName = o.layoutName, r.tabOrder = o.tabOrder;
593
+ const o = n.dictionaries.layouts;
594
+ e.objects.LAYOUT.forEach((s) => {
595
+ const r = new Ie();
596
+ r.layoutName = s.layoutName, r.tabOrder = s.tabOrder;
582
597
  const a = n.tables.blockTable.newIterator();
583
- r.objectId = o.handle;
598
+ r.objectId = s.handle;
584
599
  for (const i of a)
585
600
  if (i.layoutId === r.objectId) {
586
601
  r.blockTableRecordId = i.objectId;
587
602
  break;
588
603
  }
589
- r.blockTableRecordId || o.layoutName === "Model" && (r.blockTableRecordId = n.tables.blockTable.modelSpace.objectId), r.limits.min.copy(o.minLimit), r.limits.max.copy(o.maxLimit), r.extents.min.copy(o.minExtent), r.extents.max.copy(o.maxExtent), this.processCommonObjectAttrs(o, r), s.setAt(r.layoutName, r);
604
+ r.blockTableRecordId || s.layoutName === "Model" && (r.blockTableRecordId = n.tables.blockTable.modelSpace.objectId), r.limits.min.copy(s.minLimit), r.limits.max.copy(s.maxLimit), r.extents.min.copy(s.minExtent), r.extents.max.copy(s.maxExtent), this.processCommonObjectAttrs(s, r), o.setAt(r.layoutName, r);
590
605
  });
591
606
  }
592
607
  processImageDefs(e, n) {
593
- const s = n.dictionaries.imageDefs;
594
- e.objects.IMAGEDEF.forEach((o) => {
595
- const r = new De();
596
- r.sourceFileName = o.fileName, this.processCommonObjectAttrs(o, r), s.setAt(r.objectId, r);
608
+ const o = n.dictionaries.imageDefs;
609
+ e.objects.IMAGEDEF.forEach((s) => {
610
+ const r = new we();
611
+ r.sourceFileName = s.fileName, this.processCommonObjectAttrs(s, r), o.setAt(r.objectId, r);
597
612
  });
598
613
  }
599
614
  processCommonObjectAttrs(e, n) {
@@ -613,13 +628,13 @@ class be extends se {
613
628
  * @returns A new array of entities grouped by their `type` property.
614
629
  */
615
630
  groupAndFlattenByType(e) {
616
- const n = {}, s = [];
631
+ const n = {}, o = [];
617
632
  for (const t of e)
618
- n[t.type] || (n[t.type] = [], s.push(t.type)), n[t.type].push(t);
619
- return s.flatMap((t) => n[t]);
633
+ n[t.type] || (n[t.type] = [], o.push(t.type)), n[t.type].push(t);
634
+ return o.flatMap((t) => n[t]);
620
635
  }
621
636
  isModelSpace(e) {
622
- return e && e.toUpperCase() == ge;
637
+ return e && e.toUpperCase() == ye;
623
638
  }
624
639
  }
625
640
  export {