@mlightcad/libredwg-converter 3.5.24 → 3.5.26
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/LICENSE +21 -21
- package/README.md +52 -52
- package/dist/libredwg-converter.js +221 -212
- package/dist/libredwg-converter.umd.cjs +1 -1
- package/dist/libredwg-parser-worker.js +3122 -3068
- package/lib/AcDbEntitiyConverter.d.ts.map +1 -1
- package/lib/AcDbEntitiyConverter.js +32 -5
- package/lib/AcDbEntitiyConverter.js.map +1 -1
- package/lib/AcDbLibreDwgConverter.d.ts.map +1 -1
- package/lib/AcDbLibreDwgConverter.js +6 -2
- package/lib/AcDbLibreDwgConverter.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AcDbFace as
|
|
2
|
-
class
|
|
1
|
+
import { AcDbFace as O, AcGeVector3d as D, AcDbArc as m, transformOcsPointToWcs as w, AcDbCircle as k, AcDbEllipse as R, AcDbLine as F, AcGePoint3d as T, AcDbSpline as b, AcDbPoint as V, AcDbTrace as N, AcDbPolyline as B, AcGePoint2d as P, AcDbPolygonMesh as z, AcDbPolyFaceMesh as j, AcDbPoly2dType as A, AcDb2dPolyline as W, AcDbPoly3dType as y, AcDb3dPolyline as H, AcDbHatch as X, AcGePolyline2d as G, AcGeLine2d as U, AcGeCircArc2d as Y, AcGeVector2d as _, AcGeEllipseArc2d as Z, AcGeSpline3d as E, AcGeLoop2d as M, AcDbHatchObjectType as K, AcDbTable as q, AcDbText as J, AcDbMText as Q, AcDbLeader as $, AcDbAlignedDimension as ee, AcDbRotatedDimension as ne, AcDb3PointAngularDimension as oe, AcDbOrdinateDimension as te, AcDbRadialDimension as se, AcDbDiametricDimension as re, AcDbRasterImage as ie, AcDbWipeout as ce, AcDbViewport as ae, AcDbRay as le, AcDbXline as de, AcDbAttributeFlags as I, AcDbAttributeMTextFlag as C, AcDbAttribute as pe, AcDbAttributeDefinition as fe, AcDbBlockReference as ue, AcCmTransparency as ge, AcDbDatabaseConverter as he, createWorkerApi as De, AcDbLinetypeTableRecord as Ae, AcDbTextStyleTableRecord as Ie, DEFAULT_TEXT_STYLE as L, AcDbDimStyleTableRecord as ye, AcCmColor as we, AcDbLayerTableRecord as Te, AcDbViewportTableRecord as be, AcDbBlockTableRecord as Pe, AcDbBatchProcessing as Ee, ByLayer as Me, AcDbLayout as Ce, AcDbRasterImageDef as Le } from "@mlightcad/data-model";
|
|
2
|
+
class S {
|
|
3
3
|
convert(e) {
|
|
4
4
|
const n = this.createEntity(e);
|
|
5
5
|
return n && this.processCommonAttrs(e, n), n;
|
|
@@ -8,48 +8,50 @@ class C {
|
|
|
8
8
|
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;
|
|
9
9
|
}
|
|
10
10
|
convertFace(e) {
|
|
11
|
-
const n = new
|
|
11
|
+
const n = new O();
|
|
12
12
|
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;
|
|
13
13
|
}
|
|
14
14
|
convertArc(e) {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
const n = e.extrusionDirection ?? D.Z_AXIS;
|
|
16
|
+
return new m(
|
|
17
|
+
w(e.center, n),
|
|
17
18
|
e.radius,
|
|
18
19
|
e.startAngle,
|
|
19
20
|
e.endAngle,
|
|
20
|
-
|
|
21
|
+
n
|
|
21
22
|
);
|
|
22
23
|
}
|
|
23
24
|
convertCirle(e) {
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const n = e.extrusionDirection ?? D.Z_AXIS;
|
|
26
|
+
return new k(
|
|
27
|
+
w(e.center, n),
|
|
26
28
|
e.radius,
|
|
27
|
-
|
|
29
|
+
n
|
|
28
30
|
);
|
|
29
31
|
}
|
|
30
32
|
convertEllipse(e) {
|
|
31
|
-
const n = new D(e.majorAxisEndPoint),
|
|
32
|
-
return new
|
|
33
|
+
const n = new D(e.majorAxisEndPoint), s = n.length();
|
|
34
|
+
return new R(
|
|
33
35
|
e.center,
|
|
34
36
|
e.extrusionDirection ?? D.Z_AXIS,
|
|
35
37
|
n,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
s,
|
|
39
|
+
s * e.axisRatio,
|
|
38
40
|
e.startAngle,
|
|
39
41
|
e.endAngle
|
|
40
42
|
);
|
|
41
43
|
}
|
|
42
44
|
convertLine(e) {
|
|
43
|
-
const n = e.startPoint,
|
|
44
|
-
return new
|
|
45
|
-
new
|
|
46
|
-
new
|
|
45
|
+
const n = e.startPoint, s = e.endPoint;
|
|
46
|
+
return new F(
|
|
47
|
+
new T(n.x, n.y, n.z),
|
|
48
|
+
new T(s.x, s.y, s.z)
|
|
47
49
|
);
|
|
48
50
|
}
|
|
49
51
|
convertSpline(e) {
|
|
50
52
|
try {
|
|
51
53
|
if (e.numberOfControlPoints > 0 && e.numberOfKnots > 0)
|
|
52
|
-
return new
|
|
54
|
+
return new b(
|
|
53
55
|
e.controlPoints,
|
|
54
56
|
e.knots,
|
|
55
57
|
e.weights,
|
|
@@ -57,7 +59,7 @@ class C {
|
|
|
57
59
|
!!(e.flag & 1)
|
|
58
60
|
);
|
|
59
61
|
if (e.numberOfFitPoints > 0)
|
|
60
|
-
return new
|
|
62
|
+
return new b(
|
|
61
63
|
e.fitPoints,
|
|
62
64
|
"Uniform",
|
|
63
65
|
e.degree,
|
|
@@ -68,32 +70,32 @@ class C {
|
|
|
68
70
|
return null;
|
|
69
71
|
}
|
|
70
72
|
convertPoint(e) {
|
|
71
|
-
const n = new
|
|
73
|
+
const n = new V();
|
|
72
74
|
return n.position = e.position, n;
|
|
73
75
|
}
|
|
74
76
|
convertSolid(e) {
|
|
75
|
-
const n = new
|
|
77
|
+
const n = new N();
|
|
76
78
|
return n.setPointAt(0, { ...e.corner1, z: 0 }), n.setPointAt(1, { ...e.corner2, z: 0 }), n.setPointAt(2, { ...e.corner3, z: 0 }), n.setPointAt(
|
|
77
79
|
3,
|
|
78
80
|
e.corner4 ? { ...e.corner4, z: 0 } : { ...e.corner3, z: 0 }
|
|
79
81
|
), n.thickness = e.thickness, n;
|
|
80
82
|
}
|
|
81
83
|
convertLWPolyline(e) {
|
|
82
|
-
const n = new
|
|
84
|
+
const n = new B();
|
|
83
85
|
n.closed = !!(e.flag & 512);
|
|
84
|
-
const
|
|
85
|
-
return e.vertices.forEach((o,
|
|
86
|
+
const s = e.constantWidth ?? -1;
|
|
87
|
+
return e.vertices.forEach((o, t) => {
|
|
86
88
|
n.addVertexAt(
|
|
87
|
-
|
|
88
|
-
new
|
|
89
|
+
t,
|
|
90
|
+
new P(o.x, o.y),
|
|
89
91
|
o.bulge,
|
|
90
|
-
o.startWidth ??
|
|
91
|
-
o.endWidth ??
|
|
92
|
+
o.startWidth ?? s,
|
|
93
|
+
o.endWidth ?? s
|
|
92
94
|
);
|
|
93
95
|
}), n;
|
|
94
96
|
}
|
|
95
97
|
convertPolyline2d(e) {
|
|
96
|
-
const n = !!(e.flag & 1),
|
|
98
|
+
const n = !!(e.flag & 1), s = !!(e.flag & 16), o = !!(e.flag & 64), t = !!(e.flag & 32), r = [], l = [], c = [];
|
|
97
99
|
if (e.vertices.map((i) => {
|
|
98
100
|
if (!(i.flag & 16))
|
|
99
101
|
if (o && i.flag & 128)
|
|
@@ -102,7 +104,7 @@ class C {
|
|
|
102
104
|
x: i.x,
|
|
103
105
|
y: i.y,
|
|
104
106
|
z: i.z
|
|
105
|
-
}),
|
|
107
|
+
}), l.push(i.bulge ?? 0);
|
|
106
108
|
else {
|
|
107
109
|
const d = [];
|
|
108
110
|
i.polyfaceIndex0 != null && i.polyfaceIndex0 != 0 && d.push(Math.abs(i.polyfaceIndex0) - 1), i.polyfaceIndex1 != null && i.polyfaceIndex1 != 0 && d.push(Math.abs(i.polyfaceIndex1) - 1), i.polyfaceIndex2 != null && i.polyfaceIndex2 != 0 && d.push(Math.abs(i.polyfaceIndex2) - 1), i.polyfaceIndex3 != null && i.polyfaceIndex3 != 0 && d.push(Math.abs(i.polyfaceIndex3) - 1), d.length >= 3 && c.push(d);
|
|
@@ -112,53 +114,53 @@ class C {
|
|
|
112
114
|
x: i.x,
|
|
113
115
|
y: i.y,
|
|
114
116
|
z: i.z
|
|
115
|
-
}),
|
|
116
|
-
}),
|
|
117
|
+
}), l.push(i.bulge ?? 0);
|
|
118
|
+
}), s) {
|
|
117
119
|
const i = e.meshMVertexCount ?? 2, d = e.meshNVertexCount ?? 2;
|
|
118
|
-
return new
|
|
120
|
+
return new z(i, d, r, n, t);
|
|
119
121
|
} else {
|
|
120
122
|
if (o)
|
|
121
|
-
return new
|
|
123
|
+
return new j(r, c);
|
|
122
124
|
{
|
|
123
125
|
let i = A.SimplePoly;
|
|
124
|
-
return e.flag & 2 ? i = A.FitCurvePoly : e.flag & 4 && (e.smoothType == 6 ? i = A.CubicSplinePoly : e.smoothType == 5 && (i = A.QuadSplinePoly)), new
|
|
126
|
+
return e.flag & 2 ? i = A.FitCurvePoly : e.flag & 4 && (e.smoothType == 6 ? i = A.CubicSplinePoly : e.smoothType == 5 && (i = A.QuadSplinePoly)), new W(
|
|
125
127
|
i,
|
|
126
128
|
r,
|
|
127
129
|
0,
|
|
128
130
|
n,
|
|
129
131
|
e.startWidth,
|
|
130
132
|
e.endWidth,
|
|
131
|
-
|
|
133
|
+
l
|
|
132
134
|
);
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
138
|
convertPolyline3d(e) {
|
|
137
|
-
const n = !!(e.flag & 1),
|
|
138
|
-
e.vertices.map((
|
|
139
|
-
|
|
140
|
-
x:
|
|
141
|
-
y:
|
|
142
|
-
z:
|
|
139
|
+
const n = !!(e.flag & 1), s = [];
|
|
140
|
+
e.vertices.map((t) => {
|
|
141
|
+
t.flag & 16 || s.push({
|
|
142
|
+
x: t.x,
|
|
143
|
+
y: t.y,
|
|
144
|
+
z: t.z
|
|
143
145
|
});
|
|
144
146
|
});
|
|
145
147
|
let o = y.SimplePoly;
|
|
146
|
-
return e.flag & 4 && (e.smoothType == 6 ? o = y.CubicSplinePoly : e.smoothType == 5 && (o = y.QuadSplinePoly)), new
|
|
148
|
+
return e.flag & 4 && (e.smoothType == 6 ? o = y.CubicSplinePoly : e.smoothType == 5 && (o = y.QuadSplinePoly)), new H(o, s, n);
|
|
147
149
|
}
|
|
148
150
|
convertHatch(e) {
|
|
149
151
|
var o;
|
|
150
|
-
const n = new
|
|
151
|
-
|
|
152
|
+
const n = new X();
|
|
153
|
+
if ((o = e.definitionLines) == null || o.forEach((t) => {
|
|
152
154
|
n.definitionLines.push({
|
|
153
|
-
angle:
|
|
154
|
-
base:
|
|
155
|
-
offset:
|
|
156
|
-
dashLengths:
|
|
155
|
+
angle: t.angle,
|
|
156
|
+
base: t.base,
|
|
157
|
+
offset: t.offset,
|
|
158
|
+
dashLengths: t.numberOfDashLengths > 0 ? t.dashLengths : []
|
|
157
159
|
});
|
|
158
|
-
}), 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((
|
|
159
|
-
if (
|
|
160
|
-
const
|
|
161
|
-
c.closed =
|
|
160
|
+
}), 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((t) => {
|
|
161
|
+
if (t.boundaryPathTypeFlag & 2) {
|
|
162
|
+
const l = t, c = new G();
|
|
163
|
+
c.closed = l.isClosed, l.vertices.forEach((i, d) => {
|
|
162
164
|
c.addVertexAt(d, {
|
|
163
165
|
x: i.x,
|
|
164
166
|
y: i.y,
|
|
@@ -166,162 +168,169 @@ class C {
|
|
|
166
168
|
});
|
|
167
169
|
}), n.add(c);
|
|
168
170
|
} else {
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
+
const l = t, c = [];
|
|
172
|
+
l.edges.forEach((d) => {
|
|
171
173
|
if (d != null) {
|
|
172
174
|
if (d.type == 1) {
|
|
173
|
-
const
|
|
174
|
-
c.push(new U(
|
|
175
|
+
const a = d;
|
|
176
|
+
c.push(new U(a.start, a.end));
|
|
175
177
|
} else if (d.type == 2) {
|
|
176
|
-
const
|
|
178
|
+
const a = d;
|
|
177
179
|
c.push(
|
|
178
|
-
new
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
!
|
|
180
|
+
new Y(
|
|
181
|
+
a.center,
|
|
182
|
+
a.radius,
|
|
183
|
+
a.startAngle,
|
|
184
|
+
a.endAngle,
|
|
185
|
+
!a.isCCW
|
|
184
186
|
)
|
|
185
187
|
);
|
|
186
188
|
} else if (d.type == 3) {
|
|
187
|
-
const
|
|
188
|
-
new
|
|
189
|
+
const a = d;
|
|
190
|
+
new _().subVectors(a.end, a.center);
|
|
189
191
|
const p = Math.sqrt(
|
|
190
|
-
Math.pow(
|
|
191
|
-
),
|
|
192
|
-
let
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
new
|
|
196
|
-
{ ...
|
|
192
|
+
Math.pow(a.end.x, 2) + Math.pow(a.end.y, 2)
|
|
193
|
+
), f = p * a.lengthOfMinorAxis;
|
|
194
|
+
let u = a.startAngle, h = a.endAngle;
|
|
195
|
+
const v = Math.atan2(a.end.y, a.end.x);
|
|
196
|
+
a.isCCW || (u = Math.PI * 2 - u, h = Math.PI * 2 - h), c.push(
|
|
197
|
+
new Z(
|
|
198
|
+
{ ...a.center, z: 0 },
|
|
197
199
|
p,
|
|
198
|
-
u,
|
|
199
200
|
f,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
u,
|
|
202
|
+
h,
|
|
203
|
+
!a.isCCW,
|
|
204
|
+
v
|
|
203
205
|
)
|
|
204
206
|
);
|
|
205
207
|
} else if (d.type == 4) {
|
|
206
|
-
const
|
|
207
|
-
if (
|
|
208
|
-
const
|
|
209
|
-
(
|
|
210
|
-
x:
|
|
211
|
-
y:
|
|
208
|
+
const a = d;
|
|
209
|
+
if (a.numberOfControlPoints > 0 && a.numberOfKnots > 0) {
|
|
210
|
+
const g = a.controlPoints.map(
|
|
211
|
+
(u) => ({
|
|
212
|
+
x: u.x,
|
|
213
|
+
y: u.y,
|
|
212
214
|
z: 0
|
|
213
215
|
})
|
|
214
216
|
);
|
|
215
217
|
let p = !0;
|
|
216
|
-
const
|
|
218
|
+
const f = a.controlPoints.map((u) => (u.weight == null && (p = !1), u.weight || 1));
|
|
217
219
|
c.push(
|
|
218
|
-
new
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
p ?
|
|
220
|
+
new E(
|
|
221
|
+
g,
|
|
222
|
+
a.knots,
|
|
223
|
+
p ? f : void 0
|
|
222
224
|
)
|
|
223
225
|
);
|
|
224
|
-
} else if (
|
|
225
|
-
const
|
|
226
|
+
} else if (a.numberOfFitData > 0) {
|
|
227
|
+
const g = a.fitDatum.map((p) => ({
|
|
226
228
|
x: p.x,
|
|
227
229
|
y: p.y,
|
|
228
230
|
z: 0
|
|
229
231
|
}));
|
|
230
|
-
c.push(new
|
|
232
|
+
c.push(new E(g, "Uniform"));
|
|
231
233
|
}
|
|
232
234
|
}
|
|
233
235
|
}
|
|
234
236
|
});
|
|
235
|
-
const i =
|
|
236
|
-
i.length == 0 && c.length > 0 ? n.add(new
|
|
237
|
+
const i = M.buildFromEdges(c);
|
|
238
|
+
i.length == 0 && c.length > 0 ? n.add(new M(c)) : i.forEach((d) => n.add(d));
|
|
237
239
|
}
|
|
238
|
-
}),
|
|
240
|
+
}), e.gradientFlag) {
|
|
241
|
+
const t = e;
|
|
242
|
+
if (n.hatchObjectType = K.GradientObject, n.gradientName = t.gradientName, n.gradientAngle = t.gradientRotation ?? 0, n.gradientShift = t.gradientDefinition ?? 0, n.gradientOneColorMode = t.gradientColorFlag == 1, n.shadeTintValue = t.colorTint ?? 0, t.gradientColors) {
|
|
243
|
+
const r = t.gradientColors.length;
|
|
244
|
+
r > 1 ? (n.gradientStartColor = t.gradientColors[0].rgb, n.gradientEndColor = t.gradientColors[1].rgb) : r > 0 && (n.gradientStartColor = t.gradientColors[0].rgb);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return n;
|
|
239
248
|
}
|
|
240
249
|
convertTable(e) {
|
|
241
|
-
const n = new
|
|
250
|
+
const n = new q(
|
|
242
251
|
e.name,
|
|
243
252
|
e.rowCount,
|
|
244
253
|
e.columnCount
|
|
245
254
|
);
|
|
246
255
|
return n.tableStyleId = e.tableStyleId, n.owningBlockRecordId = e.blockRecordHandle, e.directionVector && (n.horizontalDirection = new D(e.directionVector)), n.attachmentPoint = e.attachmentPoint, n.position.copy(e.startPoint), n.tableValueFlag = e.tableValue, n.tableOverrideFlag = e.overrideFlag, n.borderColorOverrideFlag = e.borderColorOverrideFlag, n.borderLineweightOverrideFlag = e.borderLineWeightOverrideFlag, n.borderVisibilityOverrideFlag = e.borderVisibilityOverrideFlag, e.columnWidthArr.forEach(
|
|
247
|
-
(
|
|
256
|
+
(s, o) => n.setColumnWidth(o, s)
|
|
248
257
|
), e.rowHeightArr.forEach(
|
|
249
|
-
(
|
|
250
|
-
), e.cells.forEach((
|
|
251
|
-
n.setCell(o,
|
|
258
|
+
(s, o) => n.setRowHeight(o, s)
|
|
259
|
+
), e.cells.forEach((s, o) => {
|
|
260
|
+
n.setCell(o, s);
|
|
252
261
|
}), n;
|
|
253
262
|
}
|
|
254
263
|
convertText(e) {
|
|
255
|
-
const n = new
|
|
264
|
+
const n = new J();
|
|
256
265
|
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;
|
|
257
266
|
}
|
|
258
267
|
convertMText(e) {
|
|
259
|
-
const n = new
|
|
268
|
+
const n = new Q();
|
|
260
269
|
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;
|
|
261
270
|
}
|
|
262
271
|
convertLeader(e) {
|
|
263
|
-
const n = new
|
|
264
|
-
return e.vertices.forEach((
|
|
265
|
-
n.appendVertex(
|
|
272
|
+
const n = new $();
|
|
273
|
+
return e.vertices.forEach((s) => {
|
|
274
|
+
n.appendVertex(s);
|
|
266
275
|
}), n.hasArrowHead = e.isArrowheadEnabled, n.hasHookLine = e.isHooklineExists, n.isSplined = e.isSpline, n.dimensionStyle = e.styleName, n.annoType = e.leaderCreationFlag, n;
|
|
267
276
|
}
|
|
268
277
|
convertDimension(e) {
|
|
269
278
|
if (e.subclassMarker == "AcDbAlignedDimension") {
|
|
270
|
-
const n = e,
|
|
279
|
+
const n = e, s = new ee(
|
|
271
280
|
n.subDefinitionPoint1,
|
|
272
281
|
n.subDefinitionPoint2,
|
|
273
282
|
n.definitionPoint
|
|
274
283
|
);
|
|
275
|
-
return n.insertionPoint && (
|
|
284
|
+
return n.insertionPoint && (s.dimBlockPosition = {
|
|
276
285
|
x: n.insertionPoint.x,
|
|
277
286
|
y: n.insertionPoint.y,
|
|
278
287
|
z: 0
|
|
279
|
-
}),
|
|
288
|
+
}), s.rotation = n.rotationAngle, this.processDimensionCommonAttrs(e, s), s;
|
|
280
289
|
} else if (e.subclassMarker == "AcDbRotatedDimension") {
|
|
281
|
-
const n = e,
|
|
290
|
+
const n = e, s = new ne(
|
|
282
291
|
n.subDefinitionPoint1,
|
|
283
292
|
n.subDefinitionPoint2,
|
|
284
293
|
n.definitionPoint
|
|
285
294
|
);
|
|
286
|
-
return n.insertionPoint && (
|
|
295
|
+
return n.insertionPoint && (s.dimBlockPosition = {
|
|
287
296
|
x: n.insertionPoint.x,
|
|
288
297
|
y: n.insertionPoint.y,
|
|
289
298
|
z: 0
|
|
290
|
-
}),
|
|
299
|
+
}), s.rotation = n.rotationAngle, this.processDimensionCommonAttrs(e, s), s;
|
|
291
300
|
} else if (e.subclassMarker == "AcDb3PointAngularDimension") {
|
|
292
|
-
const n = e,
|
|
301
|
+
const n = e, s = new oe(
|
|
293
302
|
n.centerPoint,
|
|
294
303
|
n.subDefinitionPoint1,
|
|
295
304
|
n.subDefinitionPoint2,
|
|
296
305
|
n.definitionPoint
|
|
297
306
|
);
|
|
298
|
-
return this.processDimensionCommonAttrs(e,
|
|
307
|
+
return this.processDimensionCommonAttrs(e, s), s;
|
|
299
308
|
} else if (e.subclassMarker == "AcDbOrdinateDimension") {
|
|
300
|
-
const n = e,
|
|
309
|
+
const n = e, s = new te(
|
|
301
310
|
n.subDefinitionPoint1,
|
|
302
311
|
n.subDefinitionPoint2
|
|
303
312
|
);
|
|
304
|
-
return this.processDimensionCommonAttrs(e,
|
|
313
|
+
return this.processDimensionCommonAttrs(e, s), s;
|
|
305
314
|
} else if (e.subclassMarker == "AcDbRadialDimension") {
|
|
306
|
-
const n = e,
|
|
315
|
+
const n = e, s = new se(
|
|
307
316
|
n.definitionPoint,
|
|
308
317
|
n.centerPoint,
|
|
309
318
|
n.leaderLength
|
|
310
319
|
);
|
|
311
|
-
return this.processDimensionCommonAttrs(e,
|
|
320
|
+
return this.processDimensionCommonAttrs(e, s), s;
|
|
312
321
|
} else if (e.subclassMarker == "AcDbDiametricDimension") {
|
|
313
|
-
const n = e,
|
|
322
|
+
const n = e, s = new re(
|
|
314
323
|
n.definitionPoint,
|
|
315
324
|
n.centerPoint,
|
|
316
325
|
n.leaderLength
|
|
317
326
|
);
|
|
318
|
-
return this.processDimensionCommonAttrs(e,
|
|
327
|
+
return this.processDimensionCommonAttrs(e, s), s;
|
|
319
328
|
}
|
|
320
329
|
return null;
|
|
321
330
|
}
|
|
322
331
|
processImage(e, n) {
|
|
323
|
-
n.position.copy(e.position), n.brightness = e.brightness, n.contrast = e.contrast, n.fade = e.fade, n.imageSize.copy(e.imageSize), 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((
|
|
324
|
-
n.clipBoundary.push(new
|
|
332
|
+
n.position.copy(e.position), n.brightness = e.brightness, n.contrast = e.contrast, n.fade = e.fade, n.imageSize.copy(e.imageSize), 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) => {
|
|
333
|
+
n.clipBoundary.push(new P(s));
|
|
325
334
|
}), n.clipBoundaryType = e.clippingBoundaryType, n.width = Math.sqrt(
|
|
326
335
|
e.uPixel.x ** 2 + e.uPixel.y ** 2 + e.uPixel.z ** 2
|
|
327
336
|
) * e.imageSize.x, n.height = Math.sqrt(
|
|
@@ -329,41 +338,41 @@ class C {
|
|
|
329
338
|
) * e.imageSize.y, n.rotation = Math.atan2(e.uPixel.y, e.uPixel.x);
|
|
330
339
|
}
|
|
331
340
|
convertImage(e) {
|
|
332
|
-
const n = new
|
|
341
|
+
const n = new ie();
|
|
333
342
|
return this.processImage(e, n), n;
|
|
334
343
|
}
|
|
335
344
|
convertWipeout(e) {
|
|
336
|
-
const n = new
|
|
345
|
+
const n = new ce();
|
|
337
346
|
return this.processImage(e, n), n;
|
|
338
347
|
}
|
|
339
348
|
convertViewport(e) {
|
|
340
|
-
const n = new
|
|
349
|
+
const n = new ae();
|
|
341
350
|
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;
|
|
342
351
|
}
|
|
343
352
|
convertRay(e) {
|
|
344
|
-
const n = new
|
|
353
|
+
const n = new le();
|
|
345
354
|
return n.basePoint.copy(e.firstPoint), n.unitDir.copy(e.unitDirection), n;
|
|
346
355
|
}
|
|
347
356
|
convertXline(e) {
|
|
348
|
-
const n = new
|
|
357
|
+
const n = new de();
|
|
349
358
|
return n.basePoint.copy(e.firstPoint), n.unitDir.copy(e.unitDirection), n;
|
|
350
359
|
}
|
|
351
360
|
convertAttributeCommon(e, n) {
|
|
352
|
-
const
|
|
353
|
-
n.textString =
|
|
361
|
+
const s = e.text;
|
|
362
|
+
n.textString = s.text, n.styleName = s.styleName, n.height = s.textHeight, n.position.copy(s.startPoint), n.rotation = s.rotation, n.oblique = s.obliqueAngle ?? 0, n.thickness = s.thickness, n.horizontalMode = s.halign, n.verticalMode = s.valign, n.widthFactor = s.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 & C.MultiLine) !== 0, n.isConstMTextAttribute = (e.mtextFlag & C.ConstMultiLine) !== 0;
|
|
354
363
|
}
|
|
355
364
|
convertAttribute(e) {
|
|
356
|
-
const n = new
|
|
365
|
+
const n = new pe();
|
|
357
366
|
return this.convertAttributeCommon(e, n), n;
|
|
358
367
|
}
|
|
359
368
|
convertAttributeDefinition(e) {
|
|
360
|
-
const n = new
|
|
369
|
+
const n = new fe();
|
|
361
370
|
return this.convertAttributeCommon(e, n), n.prompt = e.prompt, n;
|
|
362
371
|
}
|
|
363
372
|
convertBlockReference(e) {
|
|
364
|
-
const n = new
|
|
365
|
-
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 && e.attribs.forEach((
|
|
366
|
-
const o = this.convertAttribute(
|
|
373
|
+
const n = new ue(e.name);
|
|
374
|
+
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 && e.attribs.forEach((s) => {
|
|
375
|
+
const o = this.convertAttribute(s);
|
|
367
376
|
n.appendAttributes(o);
|
|
368
377
|
}), n;
|
|
369
378
|
}
|
|
@@ -371,26 +380,26 @@ class C {
|
|
|
371
380
|
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;
|
|
372
381
|
}
|
|
373
382
|
processCommonAttrs(e, n) {
|
|
374
|
-
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 && (e.color == null || e.colorIndex === 7) && (n.color.colorIndex = e.colorIndex), e.colorName && (n.color.colorName = e.colorName), e.isVisible != null && (n.visibility = e.isVisible), e.transparency != null) {
|
|
375
|
-
const
|
|
376
|
-
|
|
383
|
+
if (n.layer = e.layer || "0", n.objectId = e.handle, e.ownerBlockRecordSoftId != null && (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 && (e.color == null || e.colorIndex === 7) && (n.color.colorIndex = e.colorIndex), e.colorName && (n.color.colorName = e.colorName), e.isVisible != null && (n.visibility = e.isVisible), e.transparency != null) {
|
|
384
|
+
const s = new ge();
|
|
385
|
+
s.method = e.transparencyType, (s.isByBlock || s.isByBlock) && (s.alpha = e.transparency), n.transparency = s;
|
|
377
386
|
}
|
|
378
387
|
}
|
|
379
388
|
}
|
|
380
|
-
const
|
|
381
|
-
class
|
|
389
|
+
const Se = "*MODEL_SPACE";
|
|
390
|
+
class ve extends he {
|
|
382
391
|
constructor(e = {}) {
|
|
383
392
|
super(e), e.useWorker = !0, e.parserWorkerUrl || (e.parserWorkerUrl = "/assets/libredwg-parser-worker.js");
|
|
384
393
|
}
|
|
385
394
|
async parse(e, n) {
|
|
386
|
-
const
|
|
387
|
-
if (
|
|
388
|
-
const
|
|
389
|
-
workerUrl:
|
|
395
|
+
const s = this.config, o = this.getParserWorkerTimeout(e, n);
|
|
396
|
+
if (s.useWorker && s.parserWorkerUrl) {
|
|
397
|
+
const t = De({
|
|
398
|
+
workerUrl: s.parserWorkerUrl,
|
|
390
399
|
timeout: o,
|
|
391
400
|
maxConcurrentWorkers: 1
|
|
392
|
-
}), r = await
|
|
393
|
-
if (
|
|
401
|
+
}), r = await t.execute(e);
|
|
402
|
+
if (t.destroy(), r.success)
|
|
394
403
|
return r.data;
|
|
395
404
|
throw new Error(
|
|
396
405
|
`Failed to parse drawing due to error: '${r.error}'`
|
|
@@ -403,60 +412,60 @@ class Se extends fe {
|
|
|
403
412
|
e.tables.BLOCK_RECORD.entries.forEach((r) => {
|
|
404
413
|
n.set(r.name, r);
|
|
405
414
|
});
|
|
406
|
-
const
|
|
415
|
+
const s = /* @__PURE__ */ new Map(), o = (r) => {
|
|
407
416
|
if (r) {
|
|
408
|
-
const
|
|
409
|
-
return
|
|
417
|
+
const l = r.lastIndexOf(".");
|
|
418
|
+
return l >= 0 ? r.substring(0, l).toLowerCase() : r.toLowerCase();
|
|
410
419
|
}
|
|
411
420
|
};
|
|
412
421
|
e.tables.STYLE.entries.forEach((r) => {
|
|
413
|
-
const
|
|
422
|
+
const l = [];
|
|
414
423
|
let c = o(r.font);
|
|
415
|
-
c &&
|
|
424
|
+
c && l.push(c), c = o(r.bigFont), c && l.push(c), s.set(r.name, l);
|
|
416
425
|
});
|
|
417
|
-
const
|
|
418
|
-
return this.getFontsInBlock(e.entities, n,
|
|
426
|
+
const t = /* @__PURE__ */ new Set();
|
|
427
|
+
return this.getFontsInBlock(e.entities, n, s, t), Array.from(t);
|
|
419
428
|
}
|
|
420
|
-
getFontsInBlock(e, n,
|
|
421
|
-
const
|
|
429
|
+
getFontsInBlock(e, n, s, o) {
|
|
430
|
+
const t = /\\f(.*?)\|/g;
|
|
422
431
|
e.forEach((r) => {
|
|
423
432
|
if (r.type == "MTEXT") {
|
|
424
|
-
const
|
|
425
|
-
[...
|
|
433
|
+
const l = r;
|
|
434
|
+
[...l.text.matchAll(t)].forEach((i) => {
|
|
426
435
|
o.add(i[1].toLowerCase());
|
|
427
436
|
});
|
|
428
|
-
const c =
|
|
437
|
+
const c = s.get(l.styleName);
|
|
429
438
|
c == null || c.forEach((i) => o.add(i));
|
|
430
439
|
} else if (r.type == "TEXT") {
|
|
431
|
-
const
|
|
440
|
+
const l = r, c = s.get(l.styleName);
|
|
432
441
|
c == null || c.forEach((i) => o.add(i));
|
|
433
442
|
} else if (r.type == "INSERT") {
|
|
434
|
-
const
|
|
435
|
-
c && this.getFontsInBlock(c.entities, n,
|
|
443
|
+
const l = r, c = n.get(l.name);
|
|
444
|
+
c && this.getFontsInBlock(c.entities, n, s, o);
|
|
436
445
|
}
|
|
437
446
|
});
|
|
438
447
|
}
|
|
439
448
|
processLineTypes(e, n) {
|
|
440
449
|
e.tables.LTYPE.entries.forEach((o) => {
|
|
441
|
-
const
|
|
450
|
+
const t = {
|
|
442
451
|
name: o.name,
|
|
443
452
|
description: o.description,
|
|
444
453
|
standardFlag: o.standardFlag,
|
|
445
454
|
totalPatternLength: o.totalPatternLength,
|
|
446
455
|
pattern: o.pattern
|
|
447
|
-
}, r = new
|
|
456
|
+
}, r = new Ae(t);
|
|
448
457
|
this.processCommonTableEntryAttrs(o, r), r.name = o.name, n.tables.linetypeTable.add(r);
|
|
449
458
|
});
|
|
450
459
|
}
|
|
451
460
|
processTextStyles(e, n) {
|
|
452
461
|
e.tables.STYLE.entries.forEach((o) => {
|
|
453
|
-
const
|
|
454
|
-
this.processCommonTableEntryAttrs(o,
|
|
462
|
+
const t = new Ie(o);
|
|
463
|
+
this.processCommonTableEntryAttrs(o, t), n.tables.textStyleTable.add(t);
|
|
455
464
|
});
|
|
456
465
|
}
|
|
457
466
|
processDimStyles(e, n) {
|
|
458
467
|
e.tables.DIMSTYLE.entries.forEach((o) => {
|
|
459
|
-
const
|
|
468
|
+
const t = {
|
|
460
469
|
name: o.name,
|
|
461
470
|
ownerId: o.ownerHandle,
|
|
462
471
|
dimpost: o.DIMPOST || "",
|
|
@@ -525,21 +534,21 @@ class Se extends fe {
|
|
|
525
534
|
dimblk2: o.DIMBLK2 || "",
|
|
526
535
|
dimlwd: o.DIMLWD,
|
|
527
536
|
dimlwe: o.DIMLWE
|
|
528
|
-
}, r = new
|
|
537
|
+
}, r = new ye(t);
|
|
529
538
|
this.processCommonTableEntryAttrs(o, r), n.tables.dimStyleTable.add(r);
|
|
530
539
|
});
|
|
531
540
|
}
|
|
532
541
|
processLayers(e, n) {
|
|
533
542
|
e.tables.LAYER.entries.forEach((o) => {
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
const r = new
|
|
543
|
+
const t = new we();
|
|
544
|
+
t.colorIndex = o.colorIndex;
|
|
545
|
+
const r = new Te({
|
|
537
546
|
name: o.name,
|
|
538
547
|
standardFlags: o.standardFlag,
|
|
539
548
|
linetype: o.lineType,
|
|
540
549
|
lineWeight: o.lineweight,
|
|
541
550
|
isOff: o.off,
|
|
542
|
-
color:
|
|
551
|
+
color: t,
|
|
543
552
|
isPlottable: o.plotFlag != 0
|
|
544
553
|
});
|
|
545
554
|
this.processCommonTableEntryAttrs(o, r), n.tables.layerTable.add(r);
|
|
@@ -547,96 +556,96 @@ class Se extends fe {
|
|
|
547
556
|
}
|
|
548
557
|
processViewports(e, n) {
|
|
549
558
|
e.tables.VPORT.entries.forEach((o) => {
|
|
550
|
-
const
|
|
551
|
-
this.processCommonTableEntryAttrs(o,
|
|
559
|
+
const t = new be();
|
|
560
|
+
this.processCommonTableEntryAttrs(o, t), o.circleSides && (t.circleSides = o.circleSides), t.standardFlag = o.standardFlag, t.center.copy(o.center), t.lowerLeftCorner.copy(o.lowerLeftCorner), t.upperRightCorner.copy(o.upperRightCorner), o.snapBasePoint && t.snapBase.copy(o.snapBasePoint), o.snapRotationAngle && (t.snapAngle = o.snapRotationAngle), o.snapSpacing && t.snapIncrements.copy(o.snapSpacing), o.majorGridLines && (t.gridMajor = o.majorGridLines), o.gridSpacing && t.gridIncrements.copy(o.gridSpacing), o.backgroundObjectId && (t.backgroundObjectId = o.backgroundObjectId), t.gsView.center.copy(o.center), t.gsView.viewDirectionFromTarget.copy(o.viewDirectionFromTarget), t.gsView.viewTarget.copy(o.viewTarget), o.lensLength && (t.gsView.lensLength = o.lensLength), o.frontClippingPlane && (t.gsView.frontClippingPlane = o.frontClippingPlane), o.backClippingPlane && (t.gsView.backClippingPlane = o.backClippingPlane), o.viewHeight && (t.gsView.viewHeight = o.viewHeight), o.viewTwistAngle && (t.gsView.viewTwistAngle = o.viewTwistAngle), o.frozenLayers && (t.gsView.frozenLayers = o.frozenLayers), o.styleSheet && (t.gsView.styleSheet = o.styleSheet), o.renderMode && (t.gsView.renderMode = o.renderMode), o.viewMode && (t.gsView.viewMode = o.viewMode), o.ucsIconSetting && (t.gsView.ucsIconSetting = o.ucsIconSetting), o.ucsOrigin && t.gsView.ucsOrigin.copy(o.ucsOrigin), o.ucsXAxis && t.gsView.ucsXAxis.copy(o.ucsXAxis), o.ucsYAxis && t.gsView.ucsYAxis.copy(o.ucsYAxis), o.orthographicType && (t.gsView.orthographicType = o.orthographicType), o.shadePlotSetting && (t.gsView.shadePlotSetting = o.shadePlotSetting), o.shadePlotObjectId && (t.gsView.shadePlotObjectId = o.shadePlotObjectId), o.visualStyleObjectId && (t.gsView.visualStyleObjectId = o.visualStyleObjectId), o.isDefaultLightingOn && (t.gsView.isDefaultLightingOn = o.isDefaultLightingOn), o.defaultLightingType && (t.gsView.defaultLightingType = o.defaultLightingType), o.brightness && (t.gsView.brightness = o.brightness), o.contrast && (t.gsView.contrast = o.contrast), o.ambientColor && (t.gsView.ambientColor = o.ambientColor), n.tables.viewportTable.add(t);
|
|
552
561
|
});
|
|
553
562
|
}
|
|
554
563
|
processBlockTables(e, n) {
|
|
555
564
|
e.tables.BLOCK_RECORD.entries.forEach((o) => {
|
|
556
|
-
let
|
|
557
|
-
|
|
565
|
+
let t = n.tables.blockTable.getAt(o.name);
|
|
566
|
+
t || (t = new Pe(), t.objectId = o.handle, t.name = o.name, t.ownerId = o.ownerHandle, t.origin.copy(o.basePoint), t.layoutId = o.layout, t.blockInsertUnits = o.insertionUnits, t.explodability = o.explodability, t.blockScaling = o.scalability, o.bmpPreview && (t.bmpPreview = o.bmpPreview), n.tables.blockTable.add(t)), !t.isModelSapce && o.entities && o.entities.length > 0 && this.processEntitiesInBlock(o.entities, t);
|
|
558
567
|
});
|
|
559
568
|
}
|
|
560
569
|
processBlocks(e, n) {
|
|
561
570
|
}
|
|
562
571
|
async processEntitiesInBlock(e, n) {
|
|
563
|
-
const
|
|
572
|
+
const s = new S(), o = e.length, t = [];
|
|
564
573
|
for (let r = 0; r < o; r++) {
|
|
565
|
-
const
|
|
566
|
-
c &&
|
|
574
|
+
const l = e[r], c = s.convert(l);
|
|
575
|
+
c && t.push(c);
|
|
567
576
|
}
|
|
568
|
-
n.appendEntity(
|
|
577
|
+
n.appendEntity(t);
|
|
569
578
|
}
|
|
570
|
-
async processEntities(e, n,
|
|
571
|
-
const r = new
|
|
572
|
-
let
|
|
573
|
-
e.tables.BLOCK_RECORD.entries.forEach((
|
|
574
|
-
this.isModelSpace(
|
|
579
|
+
async processEntities(e, n, s, o, t) {
|
|
580
|
+
const r = new S();
|
|
581
|
+
let l = [];
|
|
582
|
+
e.tables.BLOCK_RECORD.entries.forEach((a) => {
|
|
583
|
+
this.isModelSpace(a.name) && (l = a.entities);
|
|
575
584
|
});
|
|
576
|
-
const c =
|
|
585
|
+
const c = l.length, i = new Ee(
|
|
577
586
|
c,
|
|
578
587
|
100 - o.value,
|
|
579
|
-
|
|
588
|
+
s
|
|
580
589
|
);
|
|
581
|
-
this.config.convertByEntityType && (
|
|
590
|
+
this.config.convertByEntityType && (l = this.groupAndFlattenByType(l));
|
|
582
591
|
const d = n.tables.blockTable.modelSpace;
|
|
583
|
-
await i.processChunk(async (
|
|
592
|
+
await i.processChunk(async (a, g) => {
|
|
584
593
|
const p = [];
|
|
585
|
-
for (let
|
|
586
|
-
const
|
|
587
|
-
|
|
594
|
+
for (let f = a; f < g; f++) {
|
|
595
|
+
const u = l[f], h = r.convert(u);
|
|
596
|
+
h && p.push(h);
|
|
588
597
|
}
|
|
589
|
-
if (d.appendEntity(p),
|
|
590
|
-
let
|
|
591
|
-
|
|
598
|
+
if (d.appendEntity(p), t) {
|
|
599
|
+
let f = o.value + g / c * (100 - o.value);
|
|
600
|
+
f > 100 && (f = 100), await t(f, "ENTITY", "IN-PROGRESS");
|
|
592
601
|
}
|
|
593
602
|
});
|
|
594
603
|
}
|
|
595
604
|
processHeader(e, n) {
|
|
596
|
-
const
|
|
597
|
-
|
|
605
|
+
const s = e.header;
|
|
606
|
+
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.celtype = s.CELTYPE ?? Me, 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, n.textstyle = s.TEXTSTYLE ?? L;
|
|
598
607
|
}
|
|
599
608
|
processCommonTableEntryAttrs(e, n) {
|
|
600
|
-
n.name = e.name, n.objectId = e.handle, n.ownerId = e.ownerHandle;
|
|
609
|
+
n.name = e.name, n.objectId = e.handle, e.ownerHandle != null && (n.ownerId = e.ownerHandle);
|
|
601
610
|
}
|
|
602
611
|
processObjects(e, n) {
|
|
603
612
|
this.processLayouts(e, n), this.processImageDefs(e, n);
|
|
604
613
|
}
|
|
605
614
|
processLayouts(e, n) {
|
|
606
|
-
const
|
|
607
|
-
e.objects.LAYOUT.forEach((
|
|
608
|
-
const r = new
|
|
609
|
-
r.layoutName =
|
|
610
|
-
const
|
|
611
|
-
r.objectId =
|
|
612
|
-
for (const c of
|
|
615
|
+
const s = n.objects.layout;
|
|
616
|
+
e.objects.LAYOUT.forEach((t) => {
|
|
617
|
+
const r = new Ce();
|
|
618
|
+
r.layoutName = t.layoutName, r.tabOrder = t.tabOrder;
|
|
619
|
+
const l = n.tables.blockTable.newIterator();
|
|
620
|
+
r.objectId = t.handle;
|
|
621
|
+
for (const c of l)
|
|
613
622
|
if (c.layoutId === r.objectId) {
|
|
614
623
|
r.blockTableRecordId = c.objectId;
|
|
615
624
|
break;
|
|
616
625
|
}
|
|
617
|
-
r.blockTableRecordId ||
|
|
626
|
+
r.blockTableRecordId || t.layoutName === "Model" && (r.blockTableRecordId = n.tables.blockTable.modelSpace.objectId), r.limits.min.copy(t.minLimit), r.limits.max.copy(t.maxLimit), r.extents.min.copy(t.minExtent), r.extents.max.copy(t.maxExtent), t.viewportId && r.viewportArray.push(t.viewportId), this.processCommonObjectAttrs(t, r), s.setAt(r.layoutName, r);
|
|
618
627
|
});
|
|
619
628
|
}
|
|
620
629
|
processImageDefs(e, n) {
|
|
621
|
-
const
|
|
622
|
-
e.objects.IMAGEDEF.forEach((
|
|
623
|
-
const r = new
|
|
624
|
-
r.sourceFileName =
|
|
630
|
+
const s = n.objects.imageDefinition;
|
|
631
|
+
e.objects.IMAGEDEF.forEach((t) => {
|
|
632
|
+
const r = new Le();
|
|
633
|
+
r.sourceFileName = t.fileName, this.processCommonObjectAttrs(t, r), s.setAt(r.objectId, r);
|
|
625
634
|
});
|
|
626
635
|
}
|
|
627
636
|
processCommonObjectAttrs(e, n) {
|
|
628
|
-
n.objectId = e.handle, n.ownerId = e.ownerHandle;
|
|
637
|
+
n.objectId = e.handle, e.ownerHandle != null && (n.ownerId = e.ownerHandle);
|
|
629
638
|
}
|
|
630
639
|
groupAndFlattenByType(e) {
|
|
631
|
-
const n = {},
|
|
640
|
+
const n = {}, s = [];
|
|
632
641
|
for (const o of e)
|
|
633
|
-
n[o.type] || (n[o.type] = [],
|
|
634
|
-
return
|
|
642
|
+
n[o.type] || (n[o.type] = [], s.push(o.type)), n[o.type].push(o);
|
|
643
|
+
return s.flatMap((o) => n[o]);
|
|
635
644
|
}
|
|
636
645
|
isModelSpace(e) {
|
|
637
|
-
return e && e.toUpperCase() ==
|
|
646
|
+
return e && e.toUpperCase() == Se;
|
|
638
647
|
}
|
|
639
648
|
}
|
|
640
649
|
export {
|
|
641
|
-
|
|
650
|
+
ve as AcDbLibreDwgConverter
|
|
642
651
|
};
|