@mlightcad/libredwg-converter 3.5.34 → 3.5.35
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.
- package/dist/libredwg-converter.js +86 -82
- package/dist/libredwg-converter.umd.cjs +1 -1
- package/dist/libredwg-parser-worker.js +196 -193
- package/lib/AcDbEntitiyConverter.d.ts.map +1 -1
- package/lib/AcDbEntitiyConverter.js +1 -3
- package/lib/AcDbEntitiyConverter.js.map +1 -1
- package/lib/AcDbLibreDwgConverter.d.ts.map +1 -1
- package/lib/AcDbLibreDwgConverter.js +16 -9
- package/lib/AcDbLibreDwgConverter.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AcDbFace as j, AcGeVector3d as A, AcDbArc as z, transformOcsPointToWcs as
|
|
2
|
-
class
|
|
1
|
+
import { AcDbFace as j, AcGeVector3d as A, AcDbArc as z, transformOcsPointToWcs as x, AcDbCircle as U, AcDbEllipse as X, AcDbLine as _, AcGePoint3d as S, AcDbSpline as M, AcDbPoint as G, AcDbTrace as Y, AcDbPolyline as Z, AcGePoint2d as m, AcDbPolygonMesh as K, AcDbPolyFaceMesh as q, AcDbPoly2dType as b, AcDb2dPolyline as J, AcDbPoly3dType as I, AcDb3dPolyline as Q, AcDbHatch as $, AcGePolyline2d as ee, AcGeLine2d as te, AcGeCircArc2d as ne, AcGeVector2d as oe, AcGeEllipseArc2d as re, AcGeSpline3d as v, AcGeLoop2d as O, AcDbHatchObjectType as ie, AcDbTable as se, AcDbText as ce, AcDbMText as ae, AcDbLeader as le, AcDbMLine as de, AcDbMLeader as fe, AcDbMLeaderLineType as pe, AcDbMLeaderContentType as T, AcDbAlignedDimension as ue, AcDbRotatedDimension as ge, AcDb3PointAngularDimension as he, AcDbOrdinateDimension as De, AcDbRadialDimension as ye, AcDbDiametricDimension as Ae, AcDbRasterImage as be, AcDbWipeout as Pe, AcDbViewport as Ie, AcDbRay as Te, AcDbXline as Le, AcDbAttributeFlags as P, AcDbAttributeMTextFlag as k, AcDbAttribute as N, AcDbAttributeDefinition as we, AcDbBlockReference as Ce, AcCmColor as B, AcCmTransparency as Ee, AcDbDatabaseConverter as xe, createWorkerApi as Se, AcDbLinetypeTableRecord as Me, AcDbTextStyleTableRecord as me, DEFAULT_TEXT_STYLE as R, AcDbDimStyleTableRecord as ve, AcDbLayerTableRecord as Oe, AcDbViewportTableRecord as ke, VPORT_FALLBACK_CENTER_2D as V, VPORT_FALLBACK_LLC as Ne, VPORT_FALLBACK_URC as Re, VPORT_FALLBACK_VIEW_DIR as Ve, VPORT_FALLBACK_VIEW_TARGET as Fe, AcDbBlockTableRecord as Be, AcDbBatchProcessing as He, ByLayer as We, AcDbLayout as je, AcDbRasterImageDef as ze } from "@mlightcad/data-model";
|
|
2
|
+
class F {
|
|
3
3
|
convert(e) {
|
|
4
4
|
const t = this.createEntity(e);
|
|
5
5
|
return t && this.processCommonAttrs(e, t), t;
|
|
@@ -14,7 +14,7 @@ class V {
|
|
|
14
14
|
convertArc(e) {
|
|
15
15
|
const t = e.extrusionDirection ?? A.Z_AXIS;
|
|
16
16
|
return new z(
|
|
17
|
-
|
|
17
|
+
x(e.center, t),
|
|
18
18
|
e.radius,
|
|
19
19
|
e.startAngle,
|
|
20
20
|
e.endAngle,
|
|
@@ -23,8 +23,8 @@ class V {
|
|
|
23
23
|
}
|
|
24
24
|
convertCirle(e) {
|
|
25
25
|
const t = e.extrusionDirection ?? A.Z_AXIS;
|
|
26
|
-
return new
|
|
27
|
-
|
|
26
|
+
return new U(
|
|
27
|
+
x(e.center, t),
|
|
28
28
|
e.radius,
|
|
29
29
|
t
|
|
30
30
|
);
|
|
@@ -43,7 +43,7 @@ class V {
|
|
|
43
43
|
}
|
|
44
44
|
convertLine(e) {
|
|
45
45
|
const t = e.startPoint, o = e.endPoint;
|
|
46
|
-
return new
|
|
46
|
+
return new _(
|
|
47
47
|
new S(t.x, t.y, t.z),
|
|
48
48
|
new S(o.x, o.y, o.z)
|
|
49
49
|
);
|
|
@@ -117,13 +117,13 @@ class V {
|
|
|
117
117
|
}), a.push(c.bulge ?? 0);
|
|
118
118
|
}), o) {
|
|
119
119
|
const c = e.meshMVertexCount ?? 2, d = e.meshNVertexCount ?? 2;
|
|
120
|
-
return new
|
|
120
|
+
return new K(c, d, i, t, r);
|
|
121
121
|
} else {
|
|
122
122
|
if (n)
|
|
123
|
-
return new
|
|
123
|
+
return new q(i, s);
|
|
124
124
|
{
|
|
125
125
|
let c = b.SimplePoly;
|
|
126
|
-
return e.flag & 2 ? c = b.FitCurvePoly : e.flag & 4 && (e.smoothType == 6 ? c = b.CubicSplinePoly : e.smoothType == 5 && (c = b.QuadSplinePoly)), new
|
|
126
|
+
return e.flag & 2 ? c = b.FitCurvePoly : e.flag & 4 && (e.smoothType == 6 ? c = b.CubicSplinePoly : e.smoothType == 5 && (c = b.QuadSplinePoly)), new J(
|
|
127
127
|
c,
|
|
128
128
|
i,
|
|
129
129
|
0,
|
|
@@ -144,12 +144,12 @@ class V {
|
|
|
144
144
|
z: r.z
|
|
145
145
|
});
|
|
146
146
|
});
|
|
147
|
-
let n =
|
|
148
|
-
return e.flag & 4 && (e.smoothType == 6 ? n =
|
|
147
|
+
let n = I.SimplePoly;
|
|
148
|
+
return e.flag & 4 && (e.smoothType == 6 ? n = I.CubicSplinePoly : e.smoothType == 5 && (n = I.QuadSplinePoly)), new Q(n, o, t);
|
|
149
149
|
}
|
|
150
150
|
convertHatch(e) {
|
|
151
151
|
var n;
|
|
152
|
-
const t = new
|
|
152
|
+
const t = new $();
|
|
153
153
|
if ((n = e.definitionLines) == null || n.forEach((r) => {
|
|
154
154
|
t.definitionLines.push({
|
|
155
155
|
angle: r.angle,
|
|
@@ -159,7 +159,7 @@ class V {
|
|
|
159
159
|
});
|
|
160
160
|
}), t.isSolidFill = e.solidFill == 1, t.hatchStyle = e.hatchStyle, t.patternName = e.patternName, t.patternType = e.patternType, t.patternAngle = e.patternAngle == null ? 0 : e.patternAngle, t.patternScale = e.patternScale == null ? 0 : e.patternScale, e.boundaryPaths.forEach((r) => {
|
|
161
161
|
if (r.boundaryPathTypeFlag & 2) {
|
|
162
|
-
const a = r, s = new
|
|
162
|
+
const a = r, s = new ee();
|
|
163
163
|
s.closed = a.isClosed, a.vertices.forEach((c, d) => {
|
|
164
164
|
s.addVertexAt(d, {
|
|
165
165
|
x: c.x,
|
|
@@ -173,11 +173,11 @@ class V {
|
|
|
173
173
|
if (d != null) {
|
|
174
174
|
if (d.type == 1) {
|
|
175
175
|
const l = d;
|
|
176
|
-
s.push(new
|
|
176
|
+
s.push(new te(l.start, l.end));
|
|
177
177
|
} else if (d.type == 2) {
|
|
178
178
|
const l = d;
|
|
179
179
|
s.push(
|
|
180
|
-
new
|
|
180
|
+
new ne(
|
|
181
181
|
l.center,
|
|
182
182
|
l.radius,
|
|
183
183
|
l.startAngle,
|
|
@@ -187,18 +187,18 @@ class V {
|
|
|
187
187
|
);
|
|
188
188
|
} else if (d.type == 3) {
|
|
189
189
|
const l = d;
|
|
190
|
-
new
|
|
190
|
+
new oe().subVectors(l.end, l.center);
|
|
191
191
|
const p = Math.sqrt(
|
|
192
192
|
Math.pow(l.end.x, 2) + Math.pow(l.end.y, 2)
|
|
193
|
-
),
|
|
194
|
-
let
|
|
193
|
+
), u = p * l.lengthOfMinorAxis;
|
|
194
|
+
let g = l.startAngle, y = l.endAngle;
|
|
195
195
|
const h = Math.atan2(l.end.y, l.end.x);
|
|
196
|
-
l.isCCW || (
|
|
197
|
-
new
|
|
196
|
+
l.isCCW || (g = Math.PI * 2 - g, y = Math.PI * 2 - y), s.push(
|
|
197
|
+
new re(
|
|
198
198
|
{ ...l.center, z: 0 },
|
|
199
199
|
p,
|
|
200
|
-
g,
|
|
201
200
|
u,
|
|
201
|
+
g,
|
|
202
202
|
y,
|
|
203
203
|
!l.isCCW,
|
|
204
204
|
h
|
|
@@ -208,19 +208,19 @@ class V {
|
|
|
208
208
|
const l = d;
|
|
209
209
|
if (l.numberOfControlPoints > 0 && l.numberOfKnots > 0) {
|
|
210
210
|
const f = l.controlPoints.map(
|
|
211
|
-
(
|
|
212
|
-
x:
|
|
213
|
-
y:
|
|
211
|
+
(g) => ({
|
|
212
|
+
x: g.x,
|
|
213
|
+
y: g.y,
|
|
214
214
|
z: 0
|
|
215
215
|
})
|
|
216
216
|
);
|
|
217
217
|
let p = !0;
|
|
218
|
-
const
|
|
218
|
+
const u = l.controlPoints.map((g) => (g.weight == null && (p = !1), g.weight || 1));
|
|
219
219
|
s.push(
|
|
220
220
|
new v(
|
|
221
221
|
f,
|
|
222
222
|
l.knots,
|
|
223
|
-
p ?
|
|
223
|
+
p ? u : void 0
|
|
224
224
|
)
|
|
225
225
|
);
|
|
226
226
|
} else if (l.numberOfFitData > 0) {
|
|
@@ -234,12 +234,12 @@ class V {
|
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
});
|
|
237
|
-
const c =
|
|
238
|
-
c.length == 0 && s.length > 0 ? t.add(new
|
|
237
|
+
const c = O.buildFromEdges(s);
|
|
238
|
+
c.length == 0 && s.length > 0 ? t.add(new O(s)) : c.forEach((d) => t.add(d));
|
|
239
239
|
}
|
|
240
240
|
}), e.gradientFlag) {
|
|
241
241
|
const r = e;
|
|
242
|
-
if (t.hatchObjectType =
|
|
242
|
+
if (t.hatchObjectType = ie.GradientObject, t.gradientName = r.gradientName, t.gradientAngle = r.gradientRotation ?? 0, t.gradientShift = r.gradientDefinition ?? 0, t.gradientOneColorMode = r.gradientColorFlag == 1, t.shadeTintValue = r.colorTint ?? 0, r.gradientColors) {
|
|
243
243
|
const i = r.gradientColors.length;
|
|
244
244
|
i > 1 ? (t.gradientStartColor = r.gradientColors[0].rgb, t.gradientEndColor = r.gradientColors[1].rgb) : i > 0 && (t.gradientStartColor = r.gradientColors[0].rgb);
|
|
245
245
|
}
|
|
@@ -247,7 +247,7 @@ class V {
|
|
|
247
247
|
return t;
|
|
248
248
|
}
|
|
249
249
|
convertTable(e) {
|
|
250
|
-
const t = new
|
|
250
|
+
const t = new se(
|
|
251
251
|
e.name,
|
|
252
252
|
e.rowCount,
|
|
253
253
|
e.columnCount
|
|
@@ -261,23 +261,23 @@ class V {
|
|
|
261
261
|
}), t;
|
|
262
262
|
}
|
|
263
263
|
convertText(e) {
|
|
264
|
-
const t = new
|
|
264
|
+
const t = new ce();
|
|
265
265
|
t.textString = e.text, t.styleName = e.styleName, t.height = e.textHeight, t.position.copy(e.startPoint);
|
|
266
266
|
const o = !e.endPoint || e.endPoint.x === 0 && e.endPoint.y === 0 && (e.endPoint.z ?? 0) === 0;
|
|
267
267
|
return e.endPoint && !o ? t.alignmentPoint.copy(e.endPoint) : t.alignmentPoint.copy(e.startPoint), t.rotation = e.rotation, t.oblique = e.obliqueAngle ?? 0, t.thickness = e.thickness, t.horizontalMode = e.halign, t.verticalMode = e.valign, t.widthFactor = e.xScale ?? 1, t;
|
|
268
268
|
}
|
|
269
269
|
convertMText(e) {
|
|
270
|
-
const t = new
|
|
270
|
+
const t = new ae();
|
|
271
271
|
return t.contents = e.text, e.styleName != null && (t.styleName = e.styleName), t.height = e.textHeight, t.width = e.rectWidth, t.rotation = e.rotation || 0, t.location = e.insertionPoint, t.attachmentPoint = e.attachmentPoint, e.direction && (t.direction = new A(e.direction)), t.drawingDirection = e.drawingDirection, t;
|
|
272
272
|
}
|
|
273
273
|
convertLeader(e) {
|
|
274
|
-
const t = new
|
|
274
|
+
const t = new le();
|
|
275
275
|
return e.vertices.forEach((o) => {
|
|
276
276
|
t.appendVertex(o);
|
|
277
277
|
}), t.hasArrowHead = e.isArrowheadEnabled, t.hasHookLine = e.isHooklineExists, t.isSplined = e.isSpline, t.dimensionStyle = e.styleName, t.annoType = e.leaderCreationFlag, t;
|
|
278
278
|
}
|
|
279
279
|
convertMLine(e) {
|
|
280
|
-
const t = new
|
|
280
|
+
const t = new de();
|
|
281
281
|
return t.styleName = e.mlineStyle || "STANDARD", t.scale = e.scale, t.flags = e.flags, t.justification = e.justification, t.startPosition = e.startPoint, t.normal = e.extrusionDirection ?? A.Z_AXIS, t.styleCount = e.numberOfLines ?? 0, t.segments = (e.vertices ?? []).map((o) => ({
|
|
282
282
|
position: o.vertex,
|
|
283
283
|
direction: o.vertexDirection,
|
|
@@ -291,14 +291,14 @@ class V {
|
|
|
291
291
|
})), t;
|
|
292
292
|
}
|
|
293
293
|
convertMLeader(e) {
|
|
294
|
-
var p,
|
|
295
|
-
const t = new
|
|
294
|
+
var p, u, g, y;
|
|
295
|
+
const t = new fe(), o = e;
|
|
296
296
|
t.leaderLineType = this.readNumber(o, [
|
|
297
297
|
"multileaderType",
|
|
298
298
|
"leaderLineType",
|
|
299
299
|
"leaderType"
|
|
300
|
-
]) ??
|
|
301
|
-
const n = this.readNumber(o, ["contentType"]) ?? (e.textContent ?
|
|
300
|
+
]) ?? pe.StraightLeader;
|
|
301
|
+
const n = this.readNumber(o, ["contentType"]) ?? (e.textContent ? T.MTextContent : e.blockContent ? T.BlockContent : T.NoneContent);
|
|
302
302
|
t.contentType = n, t.doglegEnabled = this.readBoolean(o, ["doglegEnabled", "enableDogleg"]) ?? !1, t.doglegLength = this.readNumber(o, ["doglegLength"]) ?? 0, e.landingPoint && (t.landingPoint = e.landingPoint), e.doglegVector && (t.doglegVector = e.doglegVector);
|
|
303
303
|
const r = this.readString(o, [
|
|
304
304
|
"mleaderStyleId",
|
|
@@ -350,7 +350,7 @@ class V {
|
|
|
350
350
|
]);
|
|
351
351
|
h != null && D && (t.mtextContent = { text: h, anchorPoint: D });
|
|
352
352
|
}
|
|
353
|
-
if ((
|
|
353
|
+
if ((u = e.blockContent) != null && u.blockHandle && e.blockContent.position)
|
|
354
354
|
t.blockContent = {
|
|
355
355
|
blockHandle: e.blockContent.blockHandle,
|
|
356
356
|
position: e.blockContent.position
|
|
@@ -369,21 +369,21 @@ class V {
|
|
|
369
369
|
position: D
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
|
-
return (
|
|
373
|
-
var
|
|
372
|
+
return (g = e.leaders) == null || g.forEach((h) => {
|
|
373
|
+
var L;
|
|
374
374
|
const D = t.addLeader({
|
|
375
375
|
landingPoint: h.landingPoint ?? e.landingPoint,
|
|
376
376
|
doglegVector: h.doglegVector ?? e.doglegVector,
|
|
377
377
|
doglegLength: h.doglegLength ?? e.doglegLength
|
|
378
378
|
});
|
|
379
|
-
(
|
|
380
|
-
var
|
|
381
|
-
const
|
|
379
|
+
(L = h.leaderLines) == null || L.forEach((w) => {
|
|
380
|
+
var C;
|
|
381
|
+
const W = t.addLeaderLine(
|
|
382
382
|
D,
|
|
383
|
-
|
|
383
|
+
w.vertices ?? []
|
|
384
384
|
);
|
|
385
|
-
(
|
|
386
|
-
t.addBreak(D,
|
|
385
|
+
(C = w.breaks) == null || C.forEach((E) => {
|
|
386
|
+
t.addBreak(D, W, E.start, E.end);
|
|
387
387
|
});
|
|
388
388
|
});
|
|
389
389
|
}), t.numberOfLeaders === 0 && ((y = this.readLeaderLineArray(o)) == null || y.forEach((h) => {
|
|
@@ -397,7 +397,7 @@ class V {
|
|
|
397
397
|
}
|
|
398
398
|
convertDimension(e) {
|
|
399
399
|
if (e.subclassMarker == "AcDbAlignedDimension") {
|
|
400
|
-
const t = e, o = new
|
|
400
|
+
const t = e, o = new ue(
|
|
401
401
|
t.subDefinitionPoint1,
|
|
402
402
|
t.subDefinitionPoint2,
|
|
403
403
|
t.definitionPoint
|
|
@@ -419,7 +419,7 @@ class V {
|
|
|
419
419
|
z: 0
|
|
420
420
|
}), o.rotation = t.rotationAngle, this.processDimensionCommonAttrs(e, o), o;
|
|
421
421
|
} else if (e.subclassMarker == "AcDb3PointAngularDimension") {
|
|
422
|
-
const t = e, o = new
|
|
422
|
+
const t = e, o = new he(
|
|
423
423
|
t.centerPoint,
|
|
424
424
|
t.subDefinitionPoint1,
|
|
425
425
|
t.subDefinitionPoint2,
|
|
@@ -427,20 +427,20 @@ class V {
|
|
|
427
427
|
);
|
|
428
428
|
return this.processDimensionCommonAttrs(e, o), o;
|
|
429
429
|
} else if (e.subclassMarker == "AcDbOrdinateDimension") {
|
|
430
|
-
const t = e, o = new
|
|
430
|
+
const t = e, o = new De(
|
|
431
431
|
t.subDefinitionPoint1,
|
|
432
432
|
t.subDefinitionPoint2
|
|
433
433
|
);
|
|
434
434
|
return this.processDimensionCommonAttrs(e, o), o;
|
|
435
435
|
} else if (e.subclassMarker == "AcDbRadialDimension") {
|
|
436
|
-
const t = e, o = new
|
|
436
|
+
const t = e, o = new ye(
|
|
437
437
|
t.definitionPoint,
|
|
438
438
|
t.centerPoint,
|
|
439
439
|
t.leaderLength
|
|
440
440
|
);
|
|
441
441
|
return this.processDimensionCommonAttrs(e, o), o;
|
|
442
442
|
} else if (e.subclassMarker == "AcDbDiametricDimension") {
|
|
443
|
-
const t = e, o = new
|
|
443
|
+
const t = e, o = new Ae(
|
|
444
444
|
t.definitionPoint,
|
|
445
445
|
t.centerPoint,
|
|
446
446
|
t.leaderLength
|
|
@@ -459,11 +459,11 @@ class V {
|
|
|
459
459
|
) * e.imageSize.y, t.rotation = Math.atan2(e.uPixel.y, e.uPixel.x);
|
|
460
460
|
}
|
|
461
461
|
convertImage(e) {
|
|
462
|
-
const t = new
|
|
462
|
+
const t = new be();
|
|
463
463
|
return this.processImage(e, t), t;
|
|
464
464
|
}
|
|
465
465
|
convertWipeout(e) {
|
|
466
|
-
const t = new
|
|
466
|
+
const t = new Pe();
|
|
467
467
|
return this.processImage(e, t), t;
|
|
468
468
|
}
|
|
469
469
|
convertViewport(e) {
|
|
@@ -471,29 +471,29 @@ class V {
|
|
|
471
471
|
return t.number = e.viewportId, t.centerPoint.copy(e.viewportCenter), t.height = e.height, t.width = e.width, t.viewCenter.copy(e.displayCenter), t.viewHeight = e.viewHeight, t;
|
|
472
472
|
}
|
|
473
473
|
convertRay(e) {
|
|
474
|
-
const t = new
|
|
474
|
+
const t = new Te();
|
|
475
475
|
return t.basePoint.copy(e.firstPoint), t.unitDir.copy(e.unitDirection), t;
|
|
476
476
|
}
|
|
477
477
|
convertXline(e) {
|
|
478
|
-
const t = new
|
|
478
|
+
const t = new Le();
|
|
479
479
|
return t.basePoint.copy(e.firstPoint), t.unitDir.copy(e.unitDirection), t;
|
|
480
480
|
}
|
|
481
481
|
convertAttributeCommon(e, t) {
|
|
482
482
|
const o = e.text;
|
|
483
483
|
t.textString = o.text, t.styleName = o.styleName, t.height = o.textHeight, t.position.copy(o.startPoint);
|
|
484
484
|
const n = e.alignmentPoint ?? o.endPoint, r = !n || n.x === 0 && n.y === 0 && (n.z ?? 0) === 0;
|
|
485
|
-
n && !r ? t.alignmentPoint.copy(n) : t.alignmentPoint.copy(o.startPoint), t.rotation = o.rotation, t.oblique = o.obliqueAngle ?? 0, t.thickness = o.thickness, t.horizontalMode = o.halign, t.verticalMode = o.valign, t.widthFactor = o.xScale ?? 1, t.tag = e.tag, t.fieldLength = e.fieldLength, t.isInvisible = (e.flags &
|
|
485
|
+
n && !r ? t.alignmentPoint.copy(n) : t.alignmentPoint.copy(o.startPoint), t.rotation = o.rotation, t.oblique = o.obliqueAngle ?? 0, t.thickness = o.thickness, t.horizontalMode = o.halign, t.verticalMode = o.valign, t.widthFactor = o.xScale ?? 1, t.tag = e.tag, t.fieldLength = e.fieldLength, t.isInvisible = (e.flags & P.Invisible) !== 0, t.isConst = (e.flags & P.Const) !== 0, t.isVerifiable = (e.flags & P.Verifiable) !== 0, t.isPreset = (e.flags & P.Preset) !== 0, t.lockPositionInBlock = e.lockPositionFlag, t.isReallyLocked = e.isReallyLocked, t.isMTextAttribute = (e.mtextFlag & k.MultiLine) !== 0, t.isConstMTextAttribute = (e.mtextFlag & k.ConstMultiLine) !== 0;
|
|
486
486
|
}
|
|
487
487
|
convertAttribute(e) {
|
|
488
488
|
const t = new N();
|
|
489
489
|
return this.convertAttributeCommon(e, t), t;
|
|
490
490
|
}
|
|
491
491
|
convertAttributeDefinition(e) {
|
|
492
|
-
const t = new
|
|
492
|
+
const t = new we();
|
|
493
493
|
return this.convertAttributeCommon(e, t), t.prompt = e.prompt, t;
|
|
494
494
|
}
|
|
495
495
|
convertBlockReference(e) {
|
|
496
|
-
const t = new
|
|
496
|
+
const t = new Ce(e.name);
|
|
497
497
|
return e.insertionPoint && t.position.copy(e.insertionPoint), t.scaleFactors.x = e.xScale, t.scaleFactors.y = e.yScale, t.scaleFactors.z = e.zScale, t.rotation = e.rotation, t.normal.copy(e.extrusionDirection), e.handle != null && (t.objectId = e.handle), e.attribs && e.attribs.forEach((o) => {
|
|
498
498
|
const n = this.convert(o);
|
|
499
499
|
n instanceof N && t.appendAttributes(n);
|
|
@@ -504,7 +504,7 @@ class V {
|
|
|
504
504
|
}
|
|
505
505
|
processCommonAttrs(e, t) {
|
|
506
506
|
if (t.layer = e.layer || "0", t.objectId = e.handle, e.ownerBlockRecordSoftId != null && (t.ownerId = e.ownerBlockRecordSoftId), e.lineType != null && (t.lineType = e.lineType), e.lineweight != null && (t.lineWeight = e.lineweight), e.lineTypeScale != null && (t.linetypeScale = e.lineTypeScale), e.color != null || e.colorIndex != null || e.colorName) {
|
|
507
|
-
const o = new
|
|
507
|
+
const o = new B();
|
|
508
508
|
e.color != null && o.setRGBValue(e.color), e.colorIndex != null && (e.color == null || e.colorIndex === 7) && (o.colorIndex = e.colorIndex), e.colorName && (o.colorName = e.colorName), t.color = o;
|
|
509
509
|
}
|
|
510
510
|
if (e.isVisible != null && (t.visibility = e.isVisible), e.transparency != null) {
|
|
@@ -557,15 +557,15 @@ class V {
|
|
|
557
557
|
return !!e && typeof e == "object" && typeof e.x == "number" && typeof e.y == "number";
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
const
|
|
561
|
-
class
|
|
560
|
+
const Ue = "*MODEL_SPACE";
|
|
561
|
+
class _e extends xe {
|
|
562
562
|
constructor(e = {}) {
|
|
563
563
|
super(e), e.useWorker = !0, e.parserWorkerUrl || (e.parserWorkerUrl = "/assets/libredwg-parser-worker.js");
|
|
564
564
|
}
|
|
565
565
|
async parse(e, t) {
|
|
566
566
|
const o = this.config, n = this.getParserWorkerTimeout(e, t);
|
|
567
567
|
if (o.useWorker && o.parserWorkerUrl) {
|
|
568
|
-
const r =
|
|
568
|
+
const r = Se({
|
|
569
569
|
workerUrl: o.parserWorkerUrl,
|
|
570
570
|
timeout: n,
|
|
571
571
|
maxConcurrentWorkers: 1
|
|
@@ -631,13 +631,13 @@ class je extends xe {
|
|
|
631
631
|
standardFlag: n.standardFlag,
|
|
632
632
|
totalPatternLength: n.totalPatternLength,
|
|
633
633
|
pattern: n.pattern
|
|
634
|
-
}, i = new
|
|
634
|
+
}, i = new Me(r);
|
|
635
635
|
this.processCommonTableEntryAttrs(n, i), i.name = n.name, t.tables.linetypeTable.add(i);
|
|
636
636
|
});
|
|
637
637
|
}
|
|
638
638
|
processTextStyles(e, t) {
|
|
639
639
|
e.tables.STYLE.entries.forEach((n) => {
|
|
640
|
-
const r = new
|
|
640
|
+
const r = new me(n);
|
|
641
641
|
this.processCommonTableEntryAttrs(n, r), t.tables.textStyleTable.add(r);
|
|
642
642
|
});
|
|
643
643
|
}
|
|
@@ -712,15 +712,15 @@ class je extends xe {
|
|
|
712
712
|
dimblk2: n.DIMBLK2 || "",
|
|
713
713
|
dimlwd: n.DIMLWD,
|
|
714
714
|
dimlwe: n.DIMLWE
|
|
715
|
-
}, i = new
|
|
715
|
+
}, i = new ve(r);
|
|
716
716
|
this.processCommonTableEntryAttrs(n, i), t.tables.dimStyleTable.add(i);
|
|
717
717
|
});
|
|
718
718
|
}
|
|
719
719
|
processLayers(e, t) {
|
|
720
720
|
e.tables.LAYER.entries.forEach((n) => {
|
|
721
|
-
const r = new
|
|
721
|
+
const r = new B();
|
|
722
722
|
r.colorIndex = n.colorIndex;
|
|
723
|
-
const i = new
|
|
723
|
+
const i = new Oe({
|
|
724
724
|
name: n.name,
|
|
725
725
|
standardFlags: n.standardFlag,
|
|
726
726
|
linetype: n.lineType,
|
|
@@ -735,19 +735,23 @@ class je extends xe {
|
|
|
735
735
|
processViewports(e, t) {
|
|
736
736
|
e.tables.VPORT.entries.forEach((n) => {
|
|
737
737
|
const r = new ke();
|
|
738
|
-
this.processCommonTableEntryAttrs(n, r), n.circleSides && (r.circleSides = n.circleSides), r.standardFlag = n.standardFlag, r.center.copy(n.center), r.lowerLeftCorner.copy(n.lowerLeftCorner), r.upperRightCorner.copy(n.upperRightCorner), n.snapBasePoint && r.snapBase.copy(n.snapBasePoint), n.snapRotationAngle && (r.snapAngle = n.snapRotationAngle), n.snapSpacing && r.snapIncrements.copy(n.snapSpacing), n.majorGridLines && (r.gridMajor = n.majorGridLines), n.gridSpacing && r.gridIncrements.copy(n.gridSpacing), n.backgroundObjectId && (r.backgroundObjectId = n.backgroundObjectId), r.gsView.center.copy(n.center
|
|
738
|
+
this.processCommonTableEntryAttrs(n, r), n.circleSides && (r.circleSides = n.circleSides), r.standardFlag = n.standardFlag, r.center.copy(n.center ?? V), r.lowerLeftCorner.copy(n.lowerLeftCorner ?? Ne), r.upperRightCorner.copy(n.upperRightCorner ?? Re), n.snapBasePoint && r.snapBase.copy(n.snapBasePoint), n.snapRotationAngle && (r.snapAngle = n.snapRotationAngle), n.snapSpacing && r.snapIncrements.copy(n.snapSpacing), n.majorGridLines && (r.gridMajor = n.majorGridLines), n.gridSpacing && r.gridIncrements.copy(n.gridSpacing), n.backgroundObjectId && (r.backgroundObjectId = n.backgroundObjectId), r.gsView.center.copy(n.center ?? V), r.gsView.viewDirectionFromTarget.copy(
|
|
739
|
+
n.viewDirectionFromTarget ?? Ve
|
|
740
|
+
), r.gsView.viewTarget.copy(
|
|
741
|
+
n.viewTarget ?? Fe
|
|
742
|
+
), n.lensLength && (r.gsView.lensLength = n.lensLength), n.frontClippingPlane && (r.gsView.frontClippingPlane = n.frontClippingPlane), n.backClippingPlane && (r.gsView.backClippingPlane = n.backClippingPlane), n.viewHeight && (r.gsView.viewHeight = n.viewHeight), n.viewTwistAngle && (r.gsView.viewTwistAngle = n.viewTwistAngle), n.frozenLayers && (r.gsView.frozenLayers = n.frozenLayers), n.styleSheet && (r.gsView.styleSheet = n.styleSheet), n.renderMode && (r.gsView.renderMode = n.renderMode), n.viewMode && (r.gsView.viewMode = n.viewMode), n.ucsIconSetting && (r.gsView.ucsIconSetting = n.ucsIconSetting), n.ucsOrigin && r.gsView.ucsOrigin.copy(n.ucsOrigin), n.ucsXAxis && r.gsView.ucsXAxis.copy(n.ucsXAxis), n.ucsYAxis && r.gsView.ucsYAxis.copy(n.ucsYAxis), n.orthographicType && (r.gsView.orthographicType = n.orthographicType), n.shadePlotSetting && (r.gsView.shadePlotSetting = n.shadePlotSetting), n.shadePlotObjectId && (r.gsView.shadePlotObjectId = n.shadePlotObjectId), n.visualStyleObjectId && (r.gsView.visualStyleObjectId = n.visualStyleObjectId), n.isDefaultLightingOn && (r.gsView.isDefaultLightingOn = n.isDefaultLightingOn), n.defaultLightingType && (r.gsView.defaultLightingType = n.defaultLightingType), n.brightness && (r.gsView.brightness = n.brightness), n.contrast && (r.gsView.contrast = n.contrast), n.ambientColor && (r.gsView.ambientColor = n.ambientColor), t.tables.viewportTable.add(r);
|
|
739
743
|
});
|
|
740
744
|
}
|
|
741
745
|
processBlockTables(e, t) {
|
|
742
746
|
e.tables.BLOCK_RECORD.entries.forEach((n) => {
|
|
743
747
|
let r = t.tables.blockTable.getAt(n.name);
|
|
744
|
-
r || (r = new
|
|
748
|
+
r || (r = new Be(), r.objectId = n.handle, r.name = n.name, r.ownerId = n.ownerHandle, r.origin.copy(n.basePoint), r.layoutId = n.layout, r.blockInsertUnits = n.insertionUnits, r.explodability = n.explodability, r.blockScaling = n.scalability, n.bmpPreview && (r.bmpPreview = n.bmpPreview), t.tables.blockTable.add(r)), !r.isModelSapce && n.entities && n.entities.length > 0 && this.processEntitiesInBlock(n.entities, r);
|
|
745
749
|
});
|
|
746
750
|
}
|
|
747
751
|
processBlocks(e, t) {
|
|
748
752
|
}
|
|
749
753
|
async processEntitiesInBlock(e, t) {
|
|
750
|
-
const o = new
|
|
754
|
+
const o = new F(), n = e.length, r = [];
|
|
751
755
|
for (let i = 0; i < n; i++) {
|
|
752
756
|
const a = e[i], s = o.convert(a);
|
|
753
757
|
s && r.push(s);
|
|
@@ -755,12 +759,12 @@ class je extends xe {
|
|
|
755
759
|
t.appendEntity(r);
|
|
756
760
|
}
|
|
757
761
|
async processEntities(e, t, o, n, r) {
|
|
758
|
-
const i = new
|
|
762
|
+
const i = new F();
|
|
759
763
|
let a = [];
|
|
760
764
|
e.tables.BLOCK_RECORD.entries.forEach((l) => {
|
|
761
765
|
this.isModelSpace(l.name) && (a = l.entities);
|
|
762
766
|
});
|
|
763
|
-
const s = a.length, c = new
|
|
767
|
+
const s = a.length, c = new He(
|
|
764
768
|
s,
|
|
765
769
|
100 - n.value,
|
|
766
770
|
o
|
|
@@ -769,19 +773,19 @@ class je extends xe {
|
|
|
769
773
|
const d = t.tables.blockTable.modelSpace;
|
|
770
774
|
await c.processChunk(async (l, f) => {
|
|
771
775
|
const p = [];
|
|
772
|
-
for (let
|
|
773
|
-
const
|
|
776
|
+
for (let u = l; u < f; u++) {
|
|
777
|
+
const g = a[u], y = i.convert(g);
|
|
774
778
|
y && p.push(y);
|
|
775
779
|
}
|
|
776
780
|
if (d.appendEntity(p), r) {
|
|
777
|
-
let
|
|
778
|
-
|
|
781
|
+
let u = n.value + f / s * (100 - n.value);
|
|
782
|
+
u > 100 && (u = 100), await r(u, "ENTITY", "IN-PROGRESS");
|
|
779
783
|
}
|
|
780
784
|
});
|
|
781
785
|
}
|
|
782
786
|
processHeader(e, t) {
|
|
783
787
|
const o = e.header;
|
|
784
|
-
o.CECOLOR && (o.CECOLOR.index >= 0 && o.CECOLOR.index <= 256 ? t.cecolor.colorIndex = o.CECOLOR.index : t.cecolor.setRGBValue(o.CECOLOR.rgb)), t.
|
|
788
|
+
o.CECOLOR && (o.CECOLOR.index >= 0 && o.CECOLOR.index <= 256 ? t.cecolor.colorIndex = o.CECOLOR.index : t.cecolor.setRGBValue(o.CECOLOR.rgb)), t.angbase = o.ANGBASE ?? 0, t.angdir = o.ANGDIR ?? 0, t.aunits = o.AUNITS ?? 0, o.AUPREC != null && (t.auprec = o.AUPREC), o.LUNITS != null && (t.lunits = o.LUNITS), o.LUPREC != null && (t.luprec = o.LUPREC), t.celtype = o.CELTYPE ?? We, t.celtscale = o.CELTSCALE ?? 1, t.ltscale = o.LTSCALE ?? 1, o.EXTMAX && (t.extmax = o.EXTMAX), o.EXTMIN && (t.extmin = o.EXTMIN), t.insunits = o.INSUNITS ?? 1, t.pdmode = o.PDMODE ?? 0, t.pdsize = o.PDSIZE ?? 0, t.textstyle = o.TEXTSTYLE ?? R;
|
|
785
789
|
}
|
|
786
790
|
processCommonTableEntryAttrs(e, t) {
|
|
787
791
|
t.name = e.name, t.objectId = e.handle, e.ownerHandle != null && (t.ownerId = e.ownerHandle);
|
|
@@ -792,7 +796,7 @@ class je extends xe {
|
|
|
792
796
|
processLayouts(e, t) {
|
|
793
797
|
const o = t.objects.layout;
|
|
794
798
|
e.objects.LAYOUT.forEach((r) => {
|
|
795
|
-
const i = new
|
|
799
|
+
const i = new je();
|
|
796
800
|
i.layoutName = r.layoutName, i.tabOrder = r.tabOrder;
|
|
797
801
|
const a = t.tables.blockTable.newIterator();
|
|
798
802
|
i.objectId = r.handle;
|
|
@@ -807,7 +811,7 @@ class je extends xe {
|
|
|
807
811
|
processImageDefs(e, t) {
|
|
808
812
|
const o = t.objects.imageDefinition;
|
|
809
813
|
e.objects.IMAGEDEF.forEach((r) => {
|
|
810
|
-
const i = new
|
|
814
|
+
const i = new ze();
|
|
811
815
|
i.sourceFileName = r.fileName, this.processCommonObjectAttrs(r, i), o.setAt(i.objectId, i);
|
|
812
816
|
});
|
|
813
817
|
}
|
|
@@ -821,9 +825,9 @@ class je extends xe {
|
|
|
821
825
|
return o.flatMap((n) => t[n]);
|
|
822
826
|
}
|
|
823
827
|
isModelSpace(e) {
|
|
824
|
-
return e && e.toUpperCase() ==
|
|
828
|
+
return e && e.toUpperCase() == Ue;
|
|
825
829
|
}
|
|
826
830
|
}
|
|
827
831
|
export {
|
|
828
|
-
|
|
832
|
+
_e as AcDbLibreDwgConverter
|
|
829
833
|
};
|