@mlightcad/libredwg-converter 3.5.27 → 3.5.29
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 +604 -434
- package/dist/libredwg-converter.umd.cjs +1 -1
- package/dist/libredwg-parser-worker.js +2659 -2445
- package/lib/AcDbEntitiyConverter.d.ts +8 -0
- package/lib/AcDbEntitiyConverter.d.ts.map +1 -1
- package/lib/AcDbEntitiyConverter.js +303 -1
- package/lib/AcDbEntitiyConverter.js.map +1 -1
- package/lib/AcDbLibreDwgConverter.d.ts.map +1 -1
- package/lib/AcDbLibreDwgConverter.js +17 -0
- package/lib/AcDbLibreDwgConverter.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import { AcDbFace as
|
|
2
|
-
class
|
|
1
|
+
import { AcDbFace as H, AcGeVector3d as A, AcDbArc as j, transformOcsPointToWcs as E, AcDbCircle as W, AcDbEllipse as z, AcDbLine as X, AcGePoint3d as S, AcDbSpline as M, AcDbPoint as U, AcDbTrace as G, AcDbPolyline as Y, AcGePoint2d as m, AcDbPolygonMesh as _, AcDbPolyFaceMesh as Z, AcDbPoly2dType as b, AcDb2dPolyline as K, AcDbPoly3dType as T, AcDb3dPolyline as q, AcDbHatch as J, AcGePolyline2d as Q, AcGeLine2d as $, AcGeCircArc2d as ee, AcGeVector2d as te, AcGeEllipseArc2d as ne, AcGeSpline3d as v, AcGeLoop2d as k, AcDbHatchObjectType as oe, AcDbTable as re, AcDbText as ie, AcDbMText as se, AcDbLeader as ce, AcDbMLine as ae, AcDbMLeader as le, AcDbMLeaderLineType as de, AcDbMLeaderContentType as w, AcDbAlignedDimension as fe, AcDbRotatedDimension as pe, AcDb3PointAngularDimension as ue, AcDbOrdinateDimension as ge, AcDbRadialDimension as he, AcDbDiametricDimension as De, AcDbRasterImage as ye, AcDbWipeout as Ae, AcDbViewport as be, AcDbRay as Ie, AcDbXline as Te, AcDbAttributeFlags as I, AcDbAttributeMTextFlag as O, AcDbAttribute as N, AcDbAttributeDefinition as we, AcDbBlockReference as Pe, AcCmTransparency as Le, AcDbDatabaseConverter as xe, createWorkerApi as Ce, AcDbLinetypeTableRecord as Ee, AcDbTextStyleTableRecord as Se, DEFAULT_TEXT_STYLE as R, AcDbDimStyleTableRecord as Me, AcCmColor as me, AcDbLayerTableRecord as ve, AcDbViewportTableRecord as ke, AcDbBlockTableRecord as Oe, AcDbBatchProcessing as Ne, ByLayer as Re, AcDbLayout as Ve, AcDbRasterImageDef as Fe } from "@mlightcad/data-model";
|
|
2
|
+
class V {
|
|
3
3
|
convert(e) {
|
|
4
|
-
const
|
|
5
|
-
return
|
|
4
|
+
const t = this.createEntity(e);
|
|
5
|
+
return t && this.processCommonAttrs(e, t), t;
|
|
6
6
|
}
|
|
7
7
|
createEntity(e) {
|
|
8
|
-
return e.type == "3DFACE" ? this.convertFace(e) : e.type == "ARC" ? this.convertArc(e) : e.type == "ATTDEF" ? this.convertAttributeDefinition(e) : e.type == "ATTRIB" ? this.convertAttribute(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;
|
|
8
|
+
return e.type == "3DFACE" ? this.convertFace(e) : e.type == "ARC" ? this.convertArc(e) : e.type == "ATTDEF" ? this.convertAttributeDefinition(e) : e.type == "ATTRIB" ? this.convertAttribute(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 == "MLINE" ? this.convertMLine(e) : e.type == "MTEXT" ? this.convertMText(e) : e.type == "MULTILEADER" || e.type == "MLEADER" ? this.convertMLeader(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
|
|
12
|
-
return e.corner1 &&
|
|
11
|
+
const t = new H();
|
|
12
|
+
return e.corner1 && t.setVertexAt(0, e.corner1), e.corner2 && t.setVertexAt(1, e.corner2), e.corner3 && t.setVertexAt(2, e.corner3), e.corner4 && t.setVertexAt(3, e.corner4), t.setEdgeInvisibilities(e.flag), t;
|
|
13
13
|
}
|
|
14
14
|
convertArc(e) {
|
|
15
|
-
const
|
|
16
|
-
return new
|
|
17
|
-
|
|
15
|
+
const t = e.extrusionDirection ?? A.Z_AXIS;
|
|
16
|
+
return new j(
|
|
17
|
+
E(e.center, t),
|
|
18
18
|
e.radius,
|
|
19
19
|
e.startAngle,
|
|
20
20
|
e.endAngle,
|
|
21
|
-
|
|
21
|
+
t
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
24
|
convertCirle(e) {
|
|
25
|
-
const
|
|
26
|
-
return new
|
|
27
|
-
|
|
25
|
+
const t = e.extrusionDirection ?? A.Z_AXIS;
|
|
26
|
+
return new W(
|
|
27
|
+
E(e.center, t),
|
|
28
28
|
e.radius,
|
|
29
|
-
|
|
29
|
+
t
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
convertEllipse(e) {
|
|
33
|
-
const
|
|
34
|
-
return new
|
|
33
|
+
const t = new A(e.majorAxisEndPoint), o = t.length();
|
|
34
|
+
return new z(
|
|
35
35
|
e.center,
|
|
36
|
-
e.extrusionDirection ??
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
e.extrusionDirection ?? A.Z_AXIS,
|
|
37
|
+
t,
|
|
38
|
+
o,
|
|
39
|
+
o * e.axisRatio,
|
|
40
40
|
e.startAngle,
|
|
41
41
|
e.endAngle
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
convertLine(e) {
|
|
45
|
-
const
|
|
46
|
-
return new
|
|
47
|
-
new
|
|
48
|
-
new
|
|
45
|
+
const t = e.startPoint, o = e.endPoint;
|
|
46
|
+
return new X(
|
|
47
|
+
new S(t.x, t.y, t.z),
|
|
48
|
+
new S(o.x, o.y, o.z)
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
convertSpline(e) {
|
|
52
52
|
try {
|
|
53
53
|
if (e.numberOfControlPoints > 0 && e.numberOfKnots > 0)
|
|
54
|
-
return new
|
|
54
|
+
return new M(
|
|
55
55
|
e.controlPoints,
|
|
56
56
|
e.knots,
|
|
57
57
|
e.weights,
|
|
@@ -59,7 +59,7 @@ class x {
|
|
|
59
59
|
!!(e.flag & 1)
|
|
60
60
|
);
|
|
61
61
|
if (e.numberOfFitPoints > 0)
|
|
62
|
-
return new
|
|
62
|
+
return new M(
|
|
63
63
|
e.fitPoints,
|
|
64
64
|
"Uniform",
|
|
65
65
|
e.degree,
|
|
@@ -70,582 +70,752 @@ class x {
|
|
|
70
70
|
return null;
|
|
71
71
|
}
|
|
72
72
|
convertPoint(e) {
|
|
73
|
-
const
|
|
74
|
-
return
|
|
73
|
+
const t = new U();
|
|
74
|
+
return t.position = e.position, t;
|
|
75
75
|
}
|
|
76
76
|
convertSolid(e) {
|
|
77
|
-
const
|
|
78
|
-
return
|
|
77
|
+
const t = new G();
|
|
78
|
+
return t.setPointAt(0, { ...e.corner1, z: 0 }), t.setPointAt(1, { ...e.corner2, z: 0 }), t.setPointAt(2, { ...e.corner3, z: 0 }), t.setPointAt(
|
|
79
79
|
3,
|
|
80
80
|
e.corner4 ? { ...e.corner4, z: 0 } : { ...e.corner3, z: 0 }
|
|
81
|
-
),
|
|
81
|
+
), t.thickness = e.thickness, t;
|
|
82
82
|
}
|
|
83
83
|
convertLWPolyline(e) {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
return e.vertices.forEach((
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
new
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
const t = new Y();
|
|
85
|
+
t.closed = !!(e.flag & 512);
|
|
86
|
+
const o = e.constantWidth ?? -1;
|
|
87
|
+
return e.vertices.forEach((n, r) => {
|
|
88
|
+
t.addVertexAt(
|
|
89
|
+
r,
|
|
90
|
+
new m(n.x, n.y),
|
|
91
|
+
n.bulge,
|
|
92
|
+
n.startWidth ?? o,
|
|
93
|
+
n.endWidth ?? o
|
|
94
94
|
);
|
|
95
|
-
}),
|
|
95
|
+
}), t;
|
|
96
96
|
}
|
|
97
97
|
convertPolyline2d(e) {
|
|
98
|
-
const
|
|
99
|
-
if (e.vertices.map((
|
|
100
|
-
if (!(
|
|
101
|
-
if (
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
x:
|
|
105
|
-
y:
|
|
106
|
-
z:
|
|
107
|
-
}),
|
|
98
|
+
const t = !!(e.flag & 1), o = !!(e.flag & 16), n = !!(e.flag & 64), r = !!(e.flag & 32), i = [], a = [], s = [];
|
|
99
|
+
if (e.vertices.map((c) => {
|
|
100
|
+
if (!(c.flag & 16))
|
|
101
|
+
if (n && c.flag & 128)
|
|
102
|
+
if (c.flag & 64)
|
|
103
|
+
i.push({
|
|
104
|
+
x: c.x,
|
|
105
|
+
y: c.y,
|
|
106
|
+
z: c.z
|
|
107
|
+
}), a.push(c.bulge ?? 0);
|
|
108
108
|
else {
|
|
109
109
|
const d = [];
|
|
110
|
-
|
|
110
|
+
c.polyfaceIndex0 != null && c.polyfaceIndex0 != 0 && d.push(Math.abs(c.polyfaceIndex0) - 1), c.polyfaceIndex1 != null && c.polyfaceIndex1 != 0 && d.push(Math.abs(c.polyfaceIndex1) - 1), c.polyfaceIndex2 != null && c.polyfaceIndex2 != 0 && d.push(Math.abs(c.polyfaceIndex2) - 1), c.polyfaceIndex3 != null && c.polyfaceIndex3 != 0 && d.push(Math.abs(c.polyfaceIndex3) - 1), d.length >= 3 && s.push(d);
|
|
111
111
|
}
|
|
112
112
|
else
|
|
113
|
-
|
|
114
|
-
x:
|
|
115
|
-
y:
|
|
116
|
-
z:
|
|
117
|
-
}),
|
|
118
|
-
}),
|
|
119
|
-
const
|
|
120
|
-
return new
|
|
113
|
+
i.push({
|
|
114
|
+
x: c.x,
|
|
115
|
+
y: c.y,
|
|
116
|
+
z: c.z
|
|
117
|
+
}), a.push(c.bulge ?? 0);
|
|
118
|
+
}), o) {
|
|
119
|
+
const c = e.meshMVertexCount ?? 2, d = e.meshNVertexCount ?? 2;
|
|
120
|
+
return new _(c, d, i, t, r);
|
|
121
121
|
} else {
|
|
122
|
-
if (
|
|
123
|
-
return new
|
|
122
|
+
if (n)
|
|
123
|
+
return new Z(i, s);
|
|
124
124
|
{
|
|
125
|
-
let
|
|
126
|
-
return e.flag & 2 ?
|
|
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 K(
|
|
127
|
+
c,
|
|
127
128
|
i,
|
|
128
|
-
r,
|
|
129
129
|
0,
|
|
130
|
-
|
|
130
|
+
t,
|
|
131
131
|
e.startWidth,
|
|
132
132
|
e.endWidth,
|
|
133
|
-
|
|
133
|
+
a
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
convertPolyline3d(e) {
|
|
139
|
-
const
|
|
140
|
-
e.vertices.map((
|
|
141
|
-
|
|
142
|
-
x:
|
|
143
|
-
y:
|
|
144
|
-
z:
|
|
139
|
+
const t = !!(e.flag & 1), o = [];
|
|
140
|
+
e.vertices.map((r) => {
|
|
141
|
+
r.flag & 16 || o.push({
|
|
142
|
+
x: r.x,
|
|
143
|
+
y: r.y,
|
|
144
|
+
z: r.z
|
|
145
145
|
});
|
|
146
146
|
});
|
|
147
|
-
let
|
|
148
|
-
return e.flag & 4 && (e.smoothType == 6 ?
|
|
147
|
+
let n = T.SimplePoly;
|
|
148
|
+
return e.flag & 4 && (e.smoothType == 6 ? n = T.CubicSplinePoly : e.smoothType == 5 && (n = T.QuadSplinePoly)), new q(n, o, t);
|
|
149
149
|
}
|
|
150
150
|
convertHatch(e) {
|
|
151
|
-
var
|
|
152
|
-
const
|
|
153
|
-
if ((
|
|
154
|
-
|
|
155
|
-
angle:
|
|
156
|
-
base:
|
|
157
|
-
offset:
|
|
158
|
-
dashLengths:
|
|
151
|
+
var n;
|
|
152
|
+
const t = new J();
|
|
153
|
+
if ((n = e.definitionLines) == null || n.forEach((r) => {
|
|
154
|
+
t.definitionLines.push({
|
|
155
|
+
angle: r.angle,
|
|
156
|
+
base: r.base,
|
|
157
|
+
offset: r.offset,
|
|
158
|
+
dashLengths: r.numberOfDashLengths > 0 ? r.dashLengths : []
|
|
159
159
|
});
|
|
160
|
-
}),
|
|
161
|
-
if (
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
x:
|
|
166
|
-
y:
|
|
167
|
-
bulge:
|
|
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
|
+
if (r.boundaryPathTypeFlag & 2) {
|
|
162
|
+
const a = r, s = new Q();
|
|
163
|
+
s.closed = a.isClosed, a.vertices.forEach((c, d) => {
|
|
164
|
+
s.addVertexAt(d, {
|
|
165
|
+
x: c.x,
|
|
166
|
+
y: c.y,
|
|
167
|
+
bulge: c.bulge
|
|
168
168
|
});
|
|
169
|
-
}),
|
|
169
|
+
}), t.add(s);
|
|
170
170
|
} else {
|
|
171
|
-
const
|
|
172
|
-
|
|
171
|
+
const a = r, s = [];
|
|
172
|
+
a.edges.forEach((d) => {
|
|
173
173
|
if (d != null) {
|
|
174
174
|
if (d.type == 1) {
|
|
175
|
-
const
|
|
176
|
-
|
|
175
|
+
const l = d;
|
|
176
|
+
s.push(new $(l.start, l.end));
|
|
177
177
|
} else if (d.type == 2) {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
new
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
!
|
|
178
|
+
const l = d;
|
|
179
|
+
s.push(
|
|
180
|
+
new ee(
|
|
181
|
+
l.center,
|
|
182
|
+
l.radius,
|
|
183
|
+
l.startAngle,
|
|
184
|
+
l.endAngle,
|
|
185
|
+
!l.isCCW
|
|
186
186
|
)
|
|
187
187
|
);
|
|
188
188
|
} else if (d.type == 3) {
|
|
189
|
-
const
|
|
190
|
-
new
|
|
189
|
+
const l = d;
|
|
190
|
+
new te().subVectors(l.end, l.center);
|
|
191
191
|
const p = Math.sqrt(
|
|
192
|
-
Math.pow(
|
|
193
|
-
),
|
|
194
|
-
let
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
new
|
|
198
|
-
{ ...
|
|
192
|
+
Math.pow(l.end.x, 2) + Math.pow(l.end.y, 2)
|
|
193
|
+
), u = p * l.lengthOfMinorAxis;
|
|
194
|
+
let g = l.startAngle, y = l.endAngle;
|
|
195
|
+
const h = Math.atan2(l.end.y, l.end.x);
|
|
196
|
+
l.isCCW || (g = Math.PI * 2 - g, y = Math.PI * 2 - y), s.push(
|
|
197
|
+
new ne(
|
|
198
|
+
{ ...l.center, z: 0 },
|
|
199
199
|
p,
|
|
200
|
-
f,
|
|
201
200
|
u,
|
|
202
201
|
g,
|
|
203
|
-
|
|
204
|
-
|
|
202
|
+
y,
|
|
203
|
+
!l.isCCW,
|
|
204
|
+
h
|
|
205
205
|
)
|
|
206
206
|
);
|
|
207
207
|
} else if (d.type == 4) {
|
|
208
|
-
const
|
|
209
|
-
if (
|
|
210
|
-
const
|
|
211
|
-
(
|
|
212
|
-
x:
|
|
213
|
-
y:
|
|
208
|
+
const l = d;
|
|
209
|
+
if (l.numberOfControlPoints > 0 && l.numberOfKnots > 0) {
|
|
210
|
+
const f = l.controlPoints.map(
|
|
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
|
|
219
|
-
|
|
220
|
-
new
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
p ?
|
|
218
|
+
const u = l.controlPoints.map((g) => (g.weight == null && (p = !1), g.weight || 1));
|
|
219
|
+
s.push(
|
|
220
|
+
new v(
|
|
221
|
+
f,
|
|
222
|
+
l.knots,
|
|
223
|
+
p ? u : void 0
|
|
224
224
|
)
|
|
225
225
|
);
|
|
226
|
-
} else if (
|
|
227
|
-
const
|
|
226
|
+
} else if (l.numberOfFitData > 0) {
|
|
227
|
+
const f = l.fitDatum.map((p) => ({
|
|
228
228
|
x: p.x,
|
|
229
229
|
y: p.y,
|
|
230
230
|
z: 0
|
|
231
231
|
}));
|
|
232
|
-
|
|
232
|
+
s.push(new v(f, "Uniform"));
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
});
|
|
237
|
-
const
|
|
238
|
-
|
|
237
|
+
const c = k.buildFromEdges(s);
|
|
238
|
+
c.length == 0 && s.length > 0 ? t.add(new k(s)) : c.forEach((d) => t.add(d));
|
|
239
239
|
}
|
|
240
240
|
}), e.gradientFlag) {
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
243
|
-
const
|
|
244
|
-
|
|
241
|
+
const r = e;
|
|
242
|
+
if (t.hatchObjectType = oe.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
|
+
const i = r.gradientColors.length;
|
|
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
|
}
|
|
246
246
|
}
|
|
247
|
-
return
|
|
247
|
+
return t;
|
|
248
248
|
}
|
|
249
249
|
convertTable(e) {
|
|
250
|
-
const
|
|
250
|
+
const t = new re(
|
|
251
251
|
e.name,
|
|
252
252
|
e.rowCount,
|
|
253
253
|
e.columnCount
|
|
254
254
|
);
|
|
255
|
-
return
|
|
256
|
-
(
|
|
255
|
+
return t.tableStyleId = e.tableStyleId, t.owningBlockRecordId = e.blockRecordHandle, e.directionVector && (t.horizontalDirection = new A(e.directionVector)), t.attachmentPoint = e.attachmentPoint, t.position.copy(e.startPoint), t.tableValueFlag = e.tableValue, t.tableOverrideFlag = e.overrideFlag, t.borderColorOverrideFlag = e.borderColorOverrideFlag, t.borderLineweightOverrideFlag = e.borderLineWeightOverrideFlag, t.borderVisibilityOverrideFlag = e.borderVisibilityOverrideFlag, e.columnWidthArr.forEach(
|
|
256
|
+
(o, n) => t.setColumnWidth(n, o)
|
|
257
257
|
), e.rowHeightArr.forEach(
|
|
258
|
-
(
|
|
259
|
-
), e.cells.forEach((
|
|
260
|
-
|
|
261
|
-
}),
|
|
258
|
+
(o, n) => t.setRowHeight(n, o)
|
|
259
|
+
), e.cells.forEach((o, n) => {
|
|
260
|
+
t.setCell(n, o);
|
|
261
|
+
}), t;
|
|
262
262
|
}
|
|
263
263
|
convertText(e) {
|
|
264
|
-
const
|
|
265
|
-
return
|
|
264
|
+
const t = new ie();
|
|
265
|
+
return t.textString = e.text, t.styleName = e.styleName, t.height = e.textHeight, t.position.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;
|
|
266
266
|
}
|
|
267
267
|
convertMText(e) {
|
|
268
|
-
const
|
|
269
|
-
return
|
|
268
|
+
const t = new se();
|
|
269
|
+
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;
|
|
270
270
|
}
|
|
271
271
|
convertLeader(e) {
|
|
272
|
-
const
|
|
273
|
-
return e.vertices.forEach((
|
|
274
|
-
|
|
275
|
-
}),
|
|
272
|
+
const t = new ce();
|
|
273
|
+
return e.vertices.forEach((o) => {
|
|
274
|
+
t.appendVertex(o);
|
|
275
|
+
}), t.hasArrowHead = e.isArrowheadEnabled, t.hasHookLine = e.isHooklineExists, t.isSplined = e.isSpline, t.dimensionStyle = e.styleName, t.annoType = e.leaderCreationFlag, t;
|
|
276
|
+
}
|
|
277
|
+
convertMLine(e) {
|
|
278
|
+
const t = new ae();
|
|
279
|
+
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) => ({
|
|
280
|
+
position: o.vertex,
|
|
281
|
+
direction: o.vertexDirection,
|
|
282
|
+
miterDirection: o.miterDirection,
|
|
283
|
+
elements: (o.lines ?? []).map((n) => ({
|
|
284
|
+
parameterCount: n.numberOfSegmentParams,
|
|
285
|
+
parameters: n.segmentParams ?? [],
|
|
286
|
+
fillCount: n.numberOfAreaFillParams,
|
|
287
|
+
fillParameters: n.areaFillParams ?? []
|
|
288
|
+
}))
|
|
289
|
+
})), t;
|
|
290
|
+
}
|
|
291
|
+
convertMLeader(e) {
|
|
292
|
+
var p, u, g, y;
|
|
293
|
+
const t = new le(), o = e;
|
|
294
|
+
t.leaderLineType = this.readNumber(o, [
|
|
295
|
+
"multileaderType",
|
|
296
|
+
"leaderLineType",
|
|
297
|
+
"leaderType"
|
|
298
|
+
]) ?? de.StraightLeader;
|
|
299
|
+
const n = this.readNumber(o, ["contentType"]) ?? (e.textContent ? w.MTextContent : e.blockContent ? w.BlockContent : w.NoneContent);
|
|
300
|
+
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);
|
|
301
|
+
const r = this.readString(o, [
|
|
302
|
+
"mleaderStyleId",
|
|
303
|
+
"mLeaderStyleId",
|
|
304
|
+
"mleaderStyleHandle",
|
|
305
|
+
"styleHandle",
|
|
306
|
+
"styleName"
|
|
307
|
+
]);
|
|
308
|
+
r && (t.mleaderStyleId = r);
|
|
309
|
+
const i = this.readPoint(o, ["normal", "extrusionDirection"]);
|
|
310
|
+
i && (t.normal = i);
|
|
311
|
+
const a = e.textContent, s = this.readString(a ?? {}, ["styleName", "textStyleName"]) ?? this.readString(o, ["textStyleName", "textStyle", "styleName"]);
|
|
312
|
+
s && (t.textStyleName = s), t.textHeight = this.readNumber(a ?? {}, ["textHeight", "height"]) ?? this.readNumber(o, [
|
|
313
|
+
"textHeight",
|
|
314
|
+
"mtextHeight",
|
|
315
|
+
"textContentHeight"
|
|
316
|
+
]) ?? t.textHeight, t.textWidth = this.readNumber(a ?? {}, ["textWidth", "width"]) ?? this.readNumber(o, ["textWidth", "mtextWidth", "textContentWidth"]) ?? t.textWidth;
|
|
317
|
+
const c = this.readNumber(a ?? {}, ["textRotation", "rotation"]) ?? this.readNumber(o, [
|
|
318
|
+
"textRotation",
|
|
319
|
+
"mtextRotation",
|
|
320
|
+
"textContentRotation"
|
|
321
|
+
]);
|
|
322
|
+
c != null && (t.textRotation = c);
|
|
323
|
+
const d = this.readPoint(o, [
|
|
324
|
+
"textDirection",
|
|
325
|
+
"mtextDirection",
|
|
326
|
+
"textDirectionVector"
|
|
327
|
+
]);
|
|
328
|
+
d && (t.textDirection = d);
|
|
329
|
+
const l = this.readNumber(o, [
|
|
330
|
+
"textAttachmentPoint",
|
|
331
|
+
"attachmentPoint"
|
|
332
|
+
]);
|
|
333
|
+
l != null && (t.textAttachmentPoint = l);
|
|
334
|
+
const f = this.readNumber(o, [
|
|
335
|
+
"textDrawingDirection",
|
|
336
|
+
"drawingDirection"
|
|
337
|
+
]);
|
|
338
|
+
if (f != null && (t.textDrawingDirection = f), ((p = e.textContent) == null ? void 0 : p.text) != null && e.textContent.anchorPoint)
|
|
339
|
+
t.mtextContent = {
|
|
340
|
+
text: e.textContent.text,
|
|
341
|
+
anchorPoint: e.textContent.anchorPoint
|
|
342
|
+
};
|
|
343
|
+
else {
|
|
344
|
+
const h = this.readString(o, ["text", "contents", "mtext"]), D = this.readPoint(o, [
|
|
345
|
+
"textLocation",
|
|
346
|
+
"textPosition",
|
|
347
|
+
"textAnchorPoint"
|
|
348
|
+
]);
|
|
349
|
+
h != null && D && (t.mtextContent = { text: h, anchorPoint: D });
|
|
350
|
+
}
|
|
351
|
+
if ((u = e.blockContent) != null && u.blockHandle && e.blockContent.position)
|
|
352
|
+
t.blockContent = {
|
|
353
|
+
blockHandle: e.blockContent.blockHandle,
|
|
354
|
+
position: e.blockContent.position
|
|
355
|
+
};
|
|
356
|
+
else {
|
|
357
|
+
const h = this.readString(o, [
|
|
358
|
+
"blockHandle",
|
|
359
|
+
"blockContentHandle",
|
|
360
|
+
"blockId"
|
|
361
|
+
]), D = this.readPoint(o, [
|
|
362
|
+
"blockPosition",
|
|
363
|
+
"blockContentPosition"
|
|
364
|
+
]);
|
|
365
|
+
h && D && (t.blockContent = {
|
|
366
|
+
blockHandle: h,
|
|
367
|
+
position: D
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
return (g = e.leaders) == null || g.forEach((h) => {
|
|
371
|
+
var P;
|
|
372
|
+
const D = t.addLeader({
|
|
373
|
+
landingPoint: h.landingPoint ?? e.landingPoint,
|
|
374
|
+
doglegVector: h.doglegVector ?? e.doglegVector,
|
|
375
|
+
doglegLength: h.doglegLength ?? e.doglegLength
|
|
376
|
+
});
|
|
377
|
+
(P = h.leaderLines) == null || P.forEach((L) => {
|
|
378
|
+
var x;
|
|
379
|
+
const B = t.addLeaderLine(
|
|
380
|
+
D,
|
|
381
|
+
L.vertices ?? []
|
|
382
|
+
);
|
|
383
|
+
(x = L.breaks) == null || x.forEach((C) => {
|
|
384
|
+
t.addBreak(D, B, C.start, C.end);
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
}), t.numberOfLeaders === 0 && ((y = this.readLeaderLineArray(o)) == null || y.forEach((h) => {
|
|
388
|
+
const D = t.addLeader({
|
|
389
|
+
landingPoint: e.landingPoint,
|
|
390
|
+
doglegVector: e.doglegVector,
|
|
391
|
+
doglegLength: e.doglegLength
|
|
392
|
+
});
|
|
393
|
+
t.addLeaderLine(D, h);
|
|
394
|
+
})), t;
|
|
276
395
|
}
|
|
277
396
|
convertDimension(e) {
|
|
278
397
|
if (e.subclassMarker == "AcDbAlignedDimension") {
|
|
279
|
-
const
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
398
|
+
const t = e, o = new fe(
|
|
399
|
+
t.subDefinitionPoint1,
|
|
400
|
+
t.subDefinitionPoint2,
|
|
401
|
+
t.definitionPoint
|
|
283
402
|
);
|
|
284
|
-
return
|
|
285
|
-
x:
|
|
286
|
-
y:
|
|
403
|
+
return t.insertionPoint && (o.dimBlockPosition = {
|
|
404
|
+
x: t.insertionPoint.x,
|
|
405
|
+
y: t.insertionPoint.y,
|
|
287
406
|
z: 0
|
|
288
|
-
}),
|
|
407
|
+
}), o.rotation = t.rotationAngle, this.processDimensionCommonAttrs(e, o), o;
|
|
289
408
|
} else if (e.subclassMarker == "AcDbRotatedDimension") {
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
409
|
+
const t = e, o = new pe(
|
|
410
|
+
t.subDefinitionPoint1,
|
|
411
|
+
t.subDefinitionPoint2,
|
|
412
|
+
t.definitionPoint
|
|
294
413
|
);
|
|
295
|
-
return
|
|
296
|
-
x:
|
|
297
|
-
y:
|
|
414
|
+
return t.insertionPoint && (o.dimBlockPosition = {
|
|
415
|
+
x: t.insertionPoint.x,
|
|
416
|
+
y: t.insertionPoint.y,
|
|
298
417
|
z: 0
|
|
299
|
-
}),
|
|
418
|
+
}), o.rotation = t.rotationAngle, this.processDimensionCommonAttrs(e, o), o;
|
|
300
419
|
} else if (e.subclassMarker == "AcDb3PointAngularDimension") {
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
420
|
+
const t = e, o = new ue(
|
|
421
|
+
t.centerPoint,
|
|
422
|
+
t.subDefinitionPoint1,
|
|
423
|
+
t.subDefinitionPoint2,
|
|
424
|
+
t.definitionPoint
|
|
306
425
|
);
|
|
307
|
-
return this.processDimensionCommonAttrs(e,
|
|
426
|
+
return this.processDimensionCommonAttrs(e, o), o;
|
|
308
427
|
} else if (e.subclassMarker == "AcDbOrdinateDimension") {
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
428
|
+
const t = e, o = new ge(
|
|
429
|
+
t.subDefinitionPoint1,
|
|
430
|
+
t.subDefinitionPoint2
|
|
312
431
|
);
|
|
313
|
-
return this.processDimensionCommonAttrs(e,
|
|
432
|
+
return this.processDimensionCommonAttrs(e, o), o;
|
|
314
433
|
} else if (e.subclassMarker == "AcDbRadialDimension") {
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
434
|
+
const t = e, o = new he(
|
|
435
|
+
t.definitionPoint,
|
|
436
|
+
t.centerPoint,
|
|
437
|
+
t.leaderLength
|
|
319
438
|
);
|
|
320
|
-
return this.processDimensionCommonAttrs(e,
|
|
439
|
+
return this.processDimensionCommonAttrs(e, o), o;
|
|
321
440
|
} else if (e.subclassMarker == "AcDbDiametricDimension") {
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
441
|
+
const t = e, o = new De(
|
|
442
|
+
t.definitionPoint,
|
|
443
|
+
t.centerPoint,
|
|
444
|
+
t.leaderLength
|
|
326
445
|
);
|
|
327
|
-
return this.processDimensionCommonAttrs(e,
|
|
446
|
+
return this.processDimensionCommonAttrs(e, o), o;
|
|
328
447
|
}
|
|
329
448
|
return null;
|
|
330
449
|
}
|
|
331
|
-
processImage(e,
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
}),
|
|
450
|
+
processImage(e, t) {
|
|
451
|
+
t.position.copy(e.position), t.brightness = e.brightness, t.contrast = e.contrast, t.fade = e.fade, t.imageSize.copy(e.imageSize), t.imageDefId = e.imageDefHandle, t.isClipped = e.clipping > 0, t.isShownClipped = (e.flags | 4) > 0, t.isImageShown = (e.flags | 3) > 0, t.isImageTransparent = (e.flags | 8) > 0, e.clippingBoundaryPath.forEach((o) => {
|
|
452
|
+
t.clipBoundary.push(new m(o));
|
|
453
|
+
}), t.clipBoundaryType = e.clippingBoundaryType, t.width = Math.sqrt(
|
|
335
454
|
e.uPixel.x ** 2 + e.uPixel.y ** 2 + e.uPixel.z ** 2
|
|
336
|
-
) * e.imageSize.x,
|
|
455
|
+
) * e.imageSize.x, t.height = Math.sqrt(
|
|
337
456
|
e.vPixel.x ** 2 + e.vPixel.y ** 2 + e.vPixel.z ** 2
|
|
338
|
-
) * e.imageSize.y,
|
|
457
|
+
) * e.imageSize.y, t.rotation = Math.atan2(e.uPixel.y, e.uPixel.x);
|
|
339
458
|
}
|
|
340
459
|
convertImage(e) {
|
|
341
|
-
const
|
|
342
|
-
return this.processImage(e,
|
|
460
|
+
const t = new ye();
|
|
461
|
+
return this.processImage(e, t), t;
|
|
343
462
|
}
|
|
344
463
|
convertWipeout(e) {
|
|
345
|
-
const
|
|
346
|
-
return this.processImage(e,
|
|
464
|
+
const t = new Ae();
|
|
465
|
+
return this.processImage(e, t), t;
|
|
347
466
|
}
|
|
348
467
|
convertViewport(e) {
|
|
349
|
-
const
|
|
350
|
-
return
|
|
468
|
+
const t = new be();
|
|
469
|
+
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;
|
|
351
470
|
}
|
|
352
471
|
convertRay(e) {
|
|
353
|
-
const
|
|
354
|
-
return
|
|
472
|
+
const t = new Ie();
|
|
473
|
+
return t.basePoint.copy(e.firstPoint), t.unitDir.copy(e.unitDirection), t;
|
|
355
474
|
}
|
|
356
475
|
convertXline(e) {
|
|
357
|
-
const
|
|
358
|
-
return
|
|
476
|
+
const t = new Te();
|
|
477
|
+
return t.basePoint.copy(e.firstPoint), t.unitDir.copy(e.unitDirection), t;
|
|
359
478
|
}
|
|
360
|
-
convertAttributeCommon(e,
|
|
361
|
-
const
|
|
362
|
-
|
|
479
|
+
convertAttributeCommon(e, t) {
|
|
480
|
+
const o = e.text;
|
|
481
|
+
t.textString = o.text, t.styleName = o.styleName, t.height = o.textHeight, t.position.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 & I.Invisible) !== 0, t.isConst = (e.flags & I.Const) !== 0, t.isVerifiable = (e.flags & I.Verifiable) !== 0, t.isPreset = (e.flags & I.Preset) !== 0, t.lockPositionInBlock = e.lockPositionFlag, t.isReallyLocked = e.isReallyLocked, t.isMTextAttribute = (e.mtextFlag & O.MultiLine) !== 0, t.isConstMTextAttribute = (e.mtextFlag & O.ConstMultiLine) !== 0;
|
|
363
482
|
}
|
|
364
483
|
convertAttribute(e) {
|
|
365
|
-
const
|
|
366
|
-
return this.convertAttributeCommon(e,
|
|
484
|
+
const t = new N();
|
|
485
|
+
return this.convertAttributeCommon(e, t), t;
|
|
367
486
|
}
|
|
368
487
|
convertAttributeDefinition(e) {
|
|
369
|
-
const
|
|
370
|
-
return this.convertAttributeCommon(e,
|
|
488
|
+
const t = new we();
|
|
489
|
+
return this.convertAttributeCommon(e, t), t.prompt = e.prompt, t;
|
|
371
490
|
}
|
|
372
491
|
convertBlockReference(e) {
|
|
373
|
-
const
|
|
374
|
-
return e.insertionPoint &&
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
}),
|
|
378
|
-
}
|
|
379
|
-
processDimensionCommonAttrs(e,
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
processCommonAttrs(e,
|
|
383
|
-
if (
|
|
384
|
-
const
|
|
385
|
-
|
|
492
|
+
const t = new Pe(e.name);
|
|
493
|
+
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) => {
|
|
494
|
+
const n = this.convert(o);
|
|
495
|
+
n instanceof N && t.appendAttributes(n);
|
|
496
|
+
}), t;
|
|
497
|
+
}
|
|
498
|
+
processDimensionCommonAttrs(e, t) {
|
|
499
|
+
t.dimBlockId = e.name, t.textPosition.copy(e.textPoint), t.textRotation = e.textRotation || 0, e.textLineSpacingFactor && (t.textLineSpacingFactor = e.textLineSpacingFactor), e.textLineSpacingStyle && (t.textLineSpacingStyle = e.textLineSpacingStyle), t.dimensionStyleName = e.styleName, t.dimensionText = e.text || "", t.measurement = e.measurement;
|
|
500
|
+
}
|
|
501
|
+
processCommonAttrs(e, t) {
|
|
502
|
+
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 && t.color.setRGBValue(e.color), e.colorIndex != null && (e.color == null || e.colorIndex === 7) && (t.color.colorIndex = e.colorIndex), e.colorName && (t.color.colorName = e.colorName), e.isVisible != null && (t.visibility = e.isVisible), e.transparency != null) {
|
|
503
|
+
const o = new Le();
|
|
504
|
+
o.method = e.transparencyType, (o.isByBlock || o.isByBlock) && (o.alpha = e.transparency), t.transparency = o;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
readNumber(e, t) {
|
|
508
|
+
for (const o of t) {
|
|
509
|
+
const n = e[o];
|
|
510
|
+
if (typeof n == "number" && Number.isFinite(n)) return n;
|
|
386
511
|
}
|
|
387
512
|
}
|
|
513
|
+
readString(e, t) {
|
|
514
|
+
for (const o of t) {
|
|
515
|
+
const n = e[o];
|
|
516
|
+
if (typeof n == "string") return n;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
readBoolean(e, t) {
|
|
520
|
+
for (const o of t) {
|
|
521
|
+
const n = e[o];
|
|
522
|
+
if (typeof n == "boolean") return n;
|
|
523
|
+
if (typeof n == "number") return n !== 0;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
readPoint(e, t) {
|
|
527
|
+
for (const o of t) {
|
|
528
|
+
const n = e[o];
|
|
529
|
+
if (this.isPointLike(n)) return n;
|
|
530
|
+
if (Array.isArray(n) && typeof n[0] == "number" && typeof n[1] == "number")
|
|
531
|
+
return { x: n[0], y: n[1], z: n[2] ?? 0 };
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
readLeaderLineArray(e) {
|
|
535
|
+
const t = e.leaderLines;
|
|
536
|
+
if (Array.isArray(t))
|
|
537
|
+
return t.map((n) => {
|
|
538
|
+
if (!n || typeof n != "object") return;
|
|
539
|
+
const r = n.vertices;
|
|
540
|
+
return Array.isArray(r) ? r.filter((i) => this.isPointLike(i)) : void 0;
|
|
541
|
+
}).filter((n) => !!n && n.length > 0);
|
|
542
|
+
const o = e.vertices;
|
|
543
|
+
if (Array.isArray(o)) {
|
|
544
|
+
const n = o.filter((r) => this.isPointLike(r));
|
|
545
|
+
return n.length > 0 ? [n] : void 0;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
isPointLike(e) {
|
|
549
|
+
return !!e && typeof e == "object" && typeof e.x == "number" && typeof e.y == "number";
|
|
550
|
+
}
|
|
388
551
|
}
|
|
389
|
-
const
|
|
390
|
-
class
|
|
552
|
+
const Be = "*MODEL_SPACE";
|
|
553
|
+
class je extends xe {
|
|
391
554
|
constructor(e = {}) {
|
|
392
555
|
super(e), e.useWorker = !0, e.parserWorkerUrl || (e.parserWorkerUrl = "/assets/libredwg-parser-worker.js");
|
|
393
556
|
}
|
|
394
|
-
async parse(e,
|
|
395
|
-
const
|
|
396
|
-
if (
|
|
397
|
-
const
|
|
398
|
-
workerUrl:
|
|
399
|
-
timeout:
|
|
557
|
+
async parse(e, t) {
|
|
558
|
+
const o = this.config, n = this.getParserWorkerTimeout(e, t);
|
|
559
|
+
if (o.useWorker && o.parserWorkerUrl) {
|
|
560
|
+
const r = Ce({
|
|
561
|
+
workerUrl: o.parserWorkerUrl,
|
|
562
|
+
timeout: n,
|
|
400
563
|
maxConcurrentWorkers: 1
|
|
401
|
-
}),
|
|
402
|
-
if (
|
|
403
|
-
return
|
|
564
|
+
}), i = await r.execute(e);
|
|
565
|
+
if (r.destroy(), i.success)
|
|
566
|
+
return i.data;
|
|
404
567
|
throw new Error(
|
|
405
|
-
`Failed to parse drawing due to error: '${
|
|
568
|
+
`Failed to parse drawing due to error: '${i.error}'`
|
|
406
569
|
);
|
|
407
570
|
} else
|
|
408
571
|
throw new Error("dwg converter can run in web worker only!");
|
|
409
572
|
}
|
|
410
573
|
getFonts(e) {
|
|
411
|
-
const
|
|
412
|
-
e.tables.BLOCK_RECORD.entries.forEach((
|
|
413
|
-
|
|
574
|
+
const t = /* @__PURE__ */ new Map();
|
|
575
|
+
e.tables.BLOCK_RECORD.entries.forEach((i) => {
|
|
576
|
+
t.set(i.name, i);
|
|
414
577
|
});
|
|
415
|
-
const
|
|
416
|
-
if (
|
|
417
|
-
const
|
|
418
|
-
return
|
|
578
|
+
const o = /* @__PURE__ */ new Map(), n = (i) => {
|
|
579
|
+
if (i) {
|
|
580
|
+
const a = i.lastIndexOf(".");
|
|
581
|
+
return a >= 0 ? i.substring(0, a).toLowerCase() : i.toLowerCase();
|
|
419
582
|
}
|
|
420
583
|
};
|
|
421
|
-
e.tables.STYLE.entries.forEach((
|
|
422
|
-
const
|
|
423
|
-
let
|
|
424
|
-
|
|
584
|
+
e.tables.STYLE.entries.forEach((i) => {
|
|
585
|
+
const a = [];
|
|
586
|
+
let s = n(i.font);
|
|
587
|
+
s && a.push(s), s = n(i.bigFont), s && a.push(s), o.set(i.name, a);
|
|
425
588
|
});
|
|
426
|
-
const
|
|
427
|
-
return this.getFontsInBlock(e.entities,
|
|
428
|
-
}
|
|
429
|
-
getFontsInBlock(e,
|
|
430
|
-
const
|
|
431
|
-
e.forEach((
|
|
432
|
-
if (
|
|
433
|
-
const
|
|
434
|
-
[...
|
|
435
|
-
|
|
589
|
+
const r = /* @__PURE__ */ new Set();
|
|
590
|
+
return this.getFontsInBlock(e.entities, t, o, r), Array.from(r);
|
|
591
|
+
}
|
|
592
|
+
getFontsInBlock(e, t, o, n) {
|
|
593
|
+
const r = /\\f(.*?)\|/g;
|
|
594
|
+
e.forEach((i) => {
|
|
595
|
+
if (i.type == "MTEXT") {
|
|
596
|
+
const a = i;
|
|
597
|
+
[...a.text.matchAll(r)].forEach((c) => {
|
|
598
|
+
n.add(c[1].toLowerCase());
|
|
436
599
|
});
|
|
437
|
-
const
|
|
438
|
-
|
|
439
|
-
} else if (
|
|
440
|
-
const
|
|
441
|
-
|
|
442
|
-
} else if (
|
|
443
|
-
const
|
|
444
|
-
|
|
600
|
+
const s = o.get(a.styleName);
|
|
601
|
+
s == null || s.forEach((c) => n.add(c));
|
|
602
|
+
} else if (i.type == "TEXT") {
|
|
603
|
+
const a = i, s = o.get(a.styleName);
|
|
604
|
+
s == null || s.forEach((c) => n.add(c));
|
|
605
|
+
} else if (i.type == "MULTILEADER" || i.type == "MLEADER") {
|
|
606
|
+
const a = i, s = a.textContent;
|
|
607
|
+
[...(typeof (s == null ? void 0 : s.text) == "string" ? s.text : "").matchAll(r)].forEach((f) => {
|
|
608
|
+
n.add(f[1].toLowerCase());
|
|
609
|
+
});
|
|
610
|
+
const d = typeof (s == null ? void 0 : s.styleName) == "string" ? s.styleName : typeof a.textStyleName == "string" ? a.textStyleName : typeof a.styleName == "string" ? a.styleName : void 0, l = d ? o.get(d) : void 0;
|
|
611
|
+
l == null || l.forEach((f) => n.add(f));
|
|
612
|
+
} else if (i.type == "INSERT") {
|
|
613
|
+
const a = i, s = t.get(a.name);
|
|
614
|
+
s && this.getFontsInBlock(s.entities, t, o, n);
|
|
445
615
|
}
|
|
446
616
|
});
|
|
447
617
|
}
|
|
448
|
-
processLineTypes(e,
|
|
449
|
-
e.tables.LTYPE.entries.forEach((
|
|
450
|
-
const
|
|
451
|
-
name:
|
|
452
|
-
description:
|
|
453
|
-
standardFlag:
|
|
454
|
-
totalPatternLength:
|
|
455
|
-
pattern:
|
|
456
|
-
},
|
|
457
|
-
this.processCommonTableEntryAttrs(
|
|
618
|
+
processLineTypes(e, t) {
|
|
619
|
+
e.tables.LTYPE.entries.forEach((n) => {
|
|
620
|
+
const r = {
|
|
621
|
+
name: n.name,
|
|
622
|
+
description: n.description,
|
|
623
|
+
standardFlag: n.standardFlag,
|
|
624
|
+
totalPatternLength: n.totalPatternLength,
|
|
625
|
+
pattern: n.pattern
|
|
626
|
+
}, i = new Ee(r);
|
|
627
|
+
this.processCommonTableEntryAttrs(n, i), i.name = n.name, t.tables.linetypeTable.add(i);
|
|
458
628
|
});
|
|
459
629
|
}
|
|
460
|
-
processTextStyles(e,
|
|
461
|
-
e.tables.STYLE.entries.forEach((
|
|
462
|
-
const
|
|
463
|
-
this.processCommonTableEntryAttrs(
|
|
630
|
+
processTextStyles(e, t) {
|
|
631
|
+
e.tables.STYLE.entries.forEach((n) => {
|
|
632
|
+
const r = new Se(n);
|
|
633
|
+
this.processCommonTableEntryAttrs(n, r), t.tables.textStyleTable.add(r);
|
|
464
634
|
});
|
|
465
635
|
}
|
|
466
|
-
processDimStyles(e,
|
|
467
|
-
e.tables.DIMSTYLE.entries.forEach((
|
|
468
|
-
const
|
|
469
|
-
name:
|
|
470
|
-
ownerId:
|
|
471
|
-
dimpost:
|
|
472
|
-
dimapost:
|
|
473
|
-
dimscale:
|
|
474
|
-
dimasz:
|
|
475
|
-
dimexo:
|
|
476
|
-
dimdli:
|
|
477
|
-
dimexe:
|
|
478
|
-
dimrnd:
|
|
479
|
-
dimdle:
|
|
480
|
-
dimtp:
|
|
481
|
-
dimtm:
|
|
482
|
-
dimtxt:
|
|
483
|
-
dimcen:
|
|
484
|
-
dimtsz:
|
|
485
|
-
dimaltf:
|
|
486
|
-
dimlfac:
|
|
487
|
-
dimtvp:
|
|
488
|
-
dimtfac:
|
|
489
|
-
dimgap:
|
|
490
|
-
dimaltrnd:
|
|
491
|
-
dimtol:
|
|
492
|
-
dimlim:
|
|
493
|
-
dimtih:
|
|
494
|
-
dimtoh:
|
|
495
|
-
dimse1:
|
|
496
|
-
dimse2:
|
|
497
|
-
dimtad:
|
|
498
|
-
dimzin:
|
|
499
|
-
dimazin:
|
|
500
|
-
dimalt:
|
|
501
|
-
dimaltd:
|
|
502
|
-
dimtofl:
|
|
503
|
-
dimsah:
|
|
504
|
-
dimtix:
|
|
505
|
-
dimsoxd:
|
|
506
|
-
dimclrd:
|
|
507
|
-
dimclre:
|
|
508
|
-
dimclrt:
|
|
509
|
-
dimadec:
|
|
510
|
-
dimunit:
|
|
511
|
-
dimdec:
|
|
512
|
-
dimtdec:
|
|
513
|
-
dimaltu:
|
|
514
|
-
dimalttd:
|
|
515
|
-
dimaunit:
|
|
516
|
-
dimfrac:
|
|
517
|
-
dimlunit:
|
|
518
|
-
dimdsep:
|
|
519
|
-
dimtmove:
|
|
520
|
-
dimjust:
|
|
521
|
-
dimsd1:
|
|
522
|
-
dimsd2:
|
|
523
|
-
dimtolj:
|
|
524
|
-
dimtzin:
|
|
525
|
-
dimaltz:
|
|
526
|
-
dimalttz:
|
|
527
|
-
dimfit:
|
|
528
|
-
dimupt:
|
|
529
|
-
dimatfit:
|
|
530
|
-
dimtxsty:
|
|
636
|
+
processDimStyles(e, t) {
|
|
637
|
+
e.tables.DIMSTYLE.entries.forEach((n) => {
|
|
638
|
+
const r = {
|
|
639
|
+
name: n.name,
|
|
640
|
+
ownerId: n.ownerHandle,
|
|
641
|
+
dimpost: n.DIMPOST || "",
|
|
642
|
+
dimapost: n.DIMAPOST || "",
|
|
643
|
+
dimscale: n.DIMSCALE,
|
|
644
|
+
dimasz: n.DIMASZ,
|
|
645
|
+
dimexo: n.DIMEXO,
|
|
646
|
+
dimdli: n.DIMDLI,
|
|
647
|
+
dimexe: n.DIMEXE,
|
|
648
|
+
dimrnd: n.DIMRND,
|
|
649
|
+
dimdle: n.DIMDLE,
|
|
650
|
+
dimtp: n.DIMTP,
|
|
651
|
+
dimtm: n.DIMTM,
|
|
652
|
+
dimtxt: n.DIMTXT,
|
|
653
|
+
dimcen: n.DIMCEN,
|
|
654
|
+
dimtsz: n.DIMTSZ,
|
|
655
|
+
dimaltf: n.DIMALTF,
|
|
656
|
+
dimlfac: n.DIMLFAC,
|
|
657
|
+
dimtvp: n.DIMTVP,
|
|
658
|
+
dimtfac: n.DIMTFAC,
|
|
659
|
+
dimgap: n.DIMGAP,
|
|
660
|
+
dimaltrnd: n.DIMALTRND,
|
|
661
|
+
dimtol: n.DIMTOL == null || n.DIMTOL == 0 ? 0 : 1,
|
|
662
|
+
dimlim: n.DIMLIM == null || n.DIMLIM == 0 ? 0 : 1,
|
|
663
|
+
dimtih: n.DIMTIH == null || n.DIMTIH == 0 ? 0 : 1,
|
|
664
|
+
dimtoh: n.DIMTOH == null || n.DIMTOH == 0 ? 0 : 1,
|
|
665
|
+
dimse1: n.DIMSE1 == null || n.DIMSE1 == 0 ? 0 : 1,
|
|
666
|
+
dimse2: n.DIMSE2 == null || n.DIMSE2 == 0 ? 0 : 1,
|
|
667
|
+
dimtad: n.DIMTAD,
|
|
668
|
+
dimzin: n.DIMZIN,
|
|
669
|
+
dimazin: n.DIMAZIN,
|
|
670
|
+
dimalt: n.DIMALT,
|
|
671
|
+
dimaltd: n.DIMALTD,
|
|
672
|
+
dimtofl: n.DIMTOFL,
|
|
673
|
+
dimsah: n.DIMSAH,
|
|
674
|
+
dimtix: n.DIMTIX,
|
|
675
|
+
dimsoxd: n.DIMSOXD,
|
|
676
|
+
dimclrd: n.DIMCLRD,
|
|
677
|
+
dimclre: n.DIMCLRE,
|
|
678
|
+
dimclrt: n.DIMCLRT,
|
|
679
|
+
dimadec: n.DIMADEC || 0,
|
|
680
|
+
dimunit: n.DIMUNIT || 2,
|
|
681
|
+
dimdec: n.DIMDEC,
|
|
682
|
+
dimtdec: n.DIMTDEC,
|
|
683
|
+
dimaltu: n.DIMALTU,
|
|
684
|
+
dimalttd: n.DIMALTTD,
|
|
685
|
+
dimaunit: n.DIMAUNIT,
|
|
686
|
+
dimfrac: n.DIMFRAC,
|
|
687
|
+
dimlunit: n.DIMLUNIT,
|
|
688
|
+
dimdsep: n.DIMDSEP || ".",
|
|
689
|
+
dimtmove: n.DIMTMOVE || 0,
|
|
690
|
+
dimjust: n.DIMJUST,
|
|
691
|
+
dimsd1: n.DIMSD1,
|
|
692
|
+
dimsd2: n.DIMSD2,
|
|
693
|
+
dimtolj: n.DIMTOLJ,
|
|
694
|
+
dimtzin: n.DIMTZIN,
|
|
695
|
+
dimaltz: n.DIMALTZ,
|
|
696
|
+
dimalttz: n.DIMALTTZ,
|
|
697
|
+
dimfit: n.DIMFIT || 0,
|
|
698
|
+
dimupt: n.DIMUPT,
|
|
699
|
+
dimatfit: n.DIMATFIT,
|
|
700
|
+
dimtxsty: R,
|
|
531
701
|
dimldrblk: "",
|
|
532
|
-
dimblk:
|
|
533
|
-
dimblk1:
|
|
534
|
-
dimblk2:
|
|
535
|
-
dimlwd:
|
|
536
|
-
dimlwe:
|
|
537
|
-
},
|
|
538
|
-
this.processCommonTableEntryAttrs(
|
|
702
|
+
dimblk: n.DIMBLK || "",
|
|
703
|
+
dimblk1: n.DIMBLK1 || "",
|
|
704
|
+
dimblk2: n.DIMBLK2 || "",
|
|
705
|
+
dimlwd: n.DIMLWD,
|
|
706
|
+
dimlwe: n.DIMLWE
|
|
707
|
+
}, i = new Me(r);
|
|
708
|
+
this.processCommonTableEntryAttrs(n, i), t.tables.dimStyleTable.add(i);
|
|
539
709
|
});
|
|
540
710
|
}
|
|
541
|
-
processLayers(e,
|
|
542
|
-
e.tables.LAYER.entries.forEach((
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
const
|
|
546
|
-
name:
|
|
547
|
-
standardFlags:
|
|
548
|
-
linetype:
|
|
549
|
-
lineWeight:
|
|
550
|
-
isOff:
|
|
551
|
-
color:
|
|
552
|
-
isPlottable:
|
|
711
|
+
processLayers(e, t) {
|
|
712
|
+
e.tables.LAYER.entries.forEach((n) => {
|
|
713
|
+
const r = new me();
|
|
714
|
+
r.colorIndex = n.colorIndex;
|
|
715
|
+
const i = new ve({
|
|
716
|
+
name: n.name,
|
|
717
|
+
standardFlags: n.standardFlag,
|
|
718
|
+
linetype: n.lineType,
|
|
719
|
+
lineWeight: n.lineweight,
|
|
720
|
+
isOff: n.off,
|
|
721
|
+
color: r,
|
|
722
|
+
isPlottable: n.plotFlag != 0
|
|
553
723
|
});
|
|
554
|
-
this.processCommonTableEntryAttrs(
|
|
724
|
+
this.processCommonTableEntryAttrs(n, i), t.tables.layerTable.add(i);
|
|
555
725
|
});
|
|
556
726
|
}
|
|
557
|
-
processViewports(e,
|
|
558
|
-
e.tables.VPORT.entries.forEach((
|
|
559
|
-
const
|
|
560
|
-
this.processCommonTableEntryAttrs(
|
|
727
|
+
processViewports(e, t) {
|
|
728
|
+
e.tables.VPORT.entries.forEach((n) => {
|
|
729
|
+
const r = new ke();
|
|
730
|
+
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), r.gsView.viewDirectionFromTarget.copy(n.viewDirectionFromTarget), r.gsView.viewTarget.copy(n.viewTarget), 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);
|
|
561
731
|
});
|
|
562
732
|
}
|
|
563
|
-
processBlockTables(e,
|
|
564
|
-
e.tables.BLOCK_RECORD.entries.forEach((
|
|
565
|
-
let
|
|
566
|
-
|
|
733
|
+
processBlockTables(e, t) {
|
|
734
|
+
e.tables.BLOCK_RECORD.entries.forEach((n) => {
|
|
735
|
+
let r = t.tables.blockTable.getAt(n.name);
|
|
736
|
+
r || (r = new Oe(), 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);
|
|
567
737
|
});
|
|
568
738
|
}
|
|
569
|
-
processBlocks(e,
|
|
739
|
+
processBlocks(e, t) {
|
|
570
740
|
}
|
|
571
|
-
async processEntitiesInBlock(e,
|
|
572
|
-
const
|
|
573
|
-
for (let
|
|
574
|
-
const
|
|
575
|
-
|
|
741
|
+
async processEntitiesInBlock(e, t) {
|
|
742
|
+
const o = new V(), n = e.length, r = [];
|
|
743
|
+
for (let i = 0; i < n; i++) {
|
|
744
|
+
const a = e[i], s = o.convert(a);
|
|
745
|
+
s && r.push(s);
|
|
576
746
|
}
|
|
577
|
-
|
|
747
|
+
t.appendEntity(r);
|
|
578
748
|
}
|
|
579
|
-
async processEntities(e,
|
|
580
|
-
const
|
|
581
|
-
let
|
|
582
|
-
e.tables.BLOCK_RECORD.entries.forEach((
|
|
583
|
-
this.isModelSpace(
|
|
749
|
+
async processEntities(e, t, o, n, r) {
|
|
750
|
+
const i = new V();
|
|
751
|
+
let a = [];
|
|
752
|
+
e.tables.BLOCK_RECORD.entries.forEach((l) => {
|
|
753
|
+
this.isModelSpace(l.name) && (a = l.entities);
|
|
584
754
|
});
|
|
585
|
-
const
|
|
586
|
-
|
|
587
|
-
100 -
|
|
588
|
-
|
|
755
|
+
const s = a.length, c = new Ne(
|
|
756
|
+
s,
|
|
757
|
+
100 - n.value,
|
|
758
|
+
o
|
|
589
759
|
);
|
|
590
|
-
this.config.convertByEntityType && (
|
|
591
|
-
const d =
|
|
592
|
-
await
|
|
760
|
+
this.config.convertByEntityType && (a = this.groupAndFlattenByType(a));
|
|
761
|
+
const d = t.tables.blockTable.modelSpace;
|
|
762
|
+
await c.processChunk(async (l, f) => {
|
|
593
763
|
const p = [];
|
|
594
|
-
for (let
|
|
595
|
-
const
|
|
596
|
-
|
|
764
|
+
for (let u = l; u < f; u++) {
|
|
765
|
+
const g = a[u], y = i.convert(g);
|
|
766
|
+
y && p.push(y);
|
|
597
767
|
}
|
|
598
|
-
if (d.appendEntity(p),
|
|
599
|
-
let
|
|
600
|
-
|
|
768
|
+
if (d.appendEntity(p), r) {
|
|
769
|
+
let u = n.value + f / s * (100 - n.value);
|
|
770
|
+
u > 100 && (u = 100), await r(u, "ENTITY", "IN-PROGRESS");
|
|
601
771
|
}
|
|
602
772
|
});
|
|
603
773
|
}
|
|
604
|
-
processHeader(e,
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
}
|
|
608
|
-
processCommonTableEntryAttrs(e,
|
|
609
|
-
|
|
610
|
-
}
|
|
611
|
-
processObjects(e,
|
|
612
|
-
this.processLayouts(e,
|
|
613
|
-
}
|
|
614
|
-
processLayouts(e,
|
|
615
|
-
const
|
|
616
|
-
e.objects.LAYOUT.forEach((
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
const
|
|
620
|
-
|
|
621
|
-
for (const
|
|
622
|
-
if (
|
|
623
|
-
|
|
774
|
+
processHeader(e, t) {
|
|
775
|
+
const o = e.header;
|
|
776
|
+
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, t.celtype = o.CELTYPE ?? Re, 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;
|
|
777
|
+
}
|
|
778
|
+
processCommonTableEntryAttrs(e, t) {
|
|
779
|
+
t.name = e.name, t.objectId = e.handle, e.ownerHandle != null && (t.ownerId = e.ownerHandle);
|
|
780
|
+
}
|
|
781
|
+
processObjects(e, t) {
|
|
782
|
+
this.processLayouts(e, t), this.processImageDefs(e, t);
|
|
783
|
+
}
|
|
784
|
+
processLayouts(e, t) {
|
|
785
|
+
const o = t.objects.layout;
|
|
786
|
+
e.objects.LAYOUT.forEach((r) => {
|
|
787
|
+
const i = new Ve();
|
|
788
|
+
i.layoutName = r.layoutName, i.tabOrder = r.tabOrder;
|
|
789
|
+
const a = t.tables.blockTable.newIterator();
|
|
790
|
+
i.objectId = r.handle;
|
|
791
|
+
for (const s of a)
|
|
792
|
+
if (s.layoutId === i.objectId) {
|
|
793
|
+
i.blockTableRecordId = s.objectId;
|
|
624
794
|
break;
|
|
625
795
|
}
|
|
626
|
-
|
|
796
|
+
i.blockTableRecordId || r.layoutName === "Model" && (i.blockTableRecordId = t.tables.blockTable.modelSpace.objectId), i.limits.min.copy(r.minLimit), i.limits.max.copy(r.maxLimit), i.extents.min.copy(r.minExtent), i.extents.max.copy(r.maxExtent), r.viewportId && i.viewportArray.push(r.viewportId), this.processCommonObjectAttrs(r, i), o.setAt(i.layoutName, i);
|
|
627
797
|
});
|
|
628
798
|
}
|
|
629
|
-
processImageDefs(e,
|
|
630
|
-
const
|
|
631
|
-
e.objects.IMAGEDEF.forEach((
|
|
632
|
-
const
|
|
633
|
-
|
|
799
|
+
processImageDefs(e, t) {
|
|
800
|
+
const o = t.objects.imageDefinition;
|
|
801
|
+
e.objects.IMAGEDEF.forEach((r) => {
|
|
802
|
+
const i = new Fe();
|
|
803
|
+
i.sourceFileName = r.fileName, this.processCommonObjectAttrs(r, i), o.setAt(i.objectId, i);
|
|
634
804
|
});
|
|
635
805
|
}
|
|
636
|
-
processCommonObjectAttrs(e,
|
|
637
|
-
|
|
806
|
+
processCommonObjectAttrs(e, t) {
|
|
807
|
+
t.objectId = e.handle, e.ownerHandle != null && (t.ownerId = e.ownerHandle);
|
|
638
808
|
}
|
|
639
809
|
groupAndFlattenByType(e) {
|
|
640
|
-
const
|
|
641
|
-
for (const
|
|
642
|
-
n
|
|
643
|
-
return
|
|
810
|
+
const t = {}, o = [];
|
|
811
|
+
for (const n of e)
|
|
812
|
+
t[n.type] || (t[n.type] = [], o.push(n.type)), t[n.type].push(n);
|
|
813
|
+
return o.flatMap((n) => t[n]);
|
|
644
814
|
}
|
|
645
815
|
isModelSpace(e) {
|
|
646
|
-
return e && e.toUpperCase() ==
|
|
816
|
+
return e && e.toUpperCase() == Be;
|
|
647
817
|
}
|
|
648
818
|
}
|
|
649
819
|
export {
|
|
650
|
-
|
|
820
|
+
je as AcDbLibreDwgConverter
|
|
651
821
|
};
|