• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DomCR / ACadSharp / 16398608965

20 Jul 2025 09:50AM UTC coverage: 74.718% (-0.3%) from 75.043%
16398608965

Pull #715

github

web-flow
Merge 7702a1e13 into 402a39408
Pull Request #715: Issue 712 pdfunderlay writer

5873 of 8639 branches covered (67.98%)

Branch coverage included in aggregate %.

111 of 253 new or added lines in 18 files covered. (43.87%)

40 existing lines in 3 files now uncovered.

23382 of 30515 relevant lines covered (76.62%)

80843.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.36
/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs
1
using ACadSharp.Entities;
2
using ACadSharp.Objects;
3
using CSMath;
4
using System;
5
using System.IO;
6
using System.Linq;
7
using System.Text;
8
using static System.Net.Mime.MediaTypeNames;
9

10
namespace ACadSharp.IO.DXF
11
{
12
        internal abstract partial class DxfSectionWriterBase
13
        {
14
                protected void writeEntity<T>(T entity)
15
                        where T : Entity
16
                {
8,416✔
17
                        //TODO: Implement complex entities in a separated branch
18
                        switch (entity)
8,416✔
19
                        {
20
                                case TableEntity:
21
                                case Solid3D:
22
                                case UnknownEntity:
23
                                        this.notify($"Entity type not implemented : {entity.GetType().FullName}", NotificationType.NotImplemented);
36✔
24
                                        return;
36✔
25
                        }
26

27
                        this._writer.Write(DxfCode.Start, entity.ObjectName);
8,380✔
28

29
                        this.writeCommonObjectData(entity);
8,380✔
30

31
                        this.writeCommonEntityData(entity);
8,380✔
32

33
                        switch (entity)
8,380!
34
                        {
35
                                case Arc arc:
36
                                        this.writeArc(arc);
84✔
37
                                        break;
84✔
38
                                case Circle circle:
39
                                        this.writeCircle(circle);
223✔
40
                                        break;
223✔
41
                                case Dimension dimension:
42
                                        this.writeDimension(dimension);
286✔
43
                                        break;
286✔
44
                                case Ellipse ellipse:
45
                                        this.writeEllipse(ellipse);
26✔
46
                                        break;
26✔
47
                                case Face3D face3D:
48
                                        this.writeFace3D(face3D);
26✔
49
                                        break;
26✔
50
                                case Hatch hatch:
51
                                        this.writeHatch(hatch);
208✔
52
                                        break;
208✔
53
                                case Insert insert:
54
                                        this.writeInsert(insert);
322✔
55
                                        break;
322✔
56
                                case Leader leader:
57
                                        this.writeLeader(leader);
26✔
58
                                        break;
26✔
59
                                case Line line:
60
                                        this.writeLine(line);
2,415✔
61
                                        break;
2,415✔
62
                                case LwPolyline lwPolyline:
63
                                        this.writeLwPolyline(lwPolyline);
552✔
64
                                        break;
552✔
65
                                case Mesh mesh:
66
                                        this.writeMesh(mesh);
52✔
67
                                        break;
52✔
68
                                case MLine mline:
69
                                        this.writeMLine(mline);
78✔
70
                                        break;
78✔
71
                                case MText mtext:
72
                                        this.writeMText(mtext);
856✔
73
                                        break;
856✔
74
                                case MultiLeader multiLeader:
75
                                        this.writeMultiLeader(multiLeader);
210✔
76
                                        break;
210✔
77
                                case PdfUnderlay pdfUnderlay:
NEW
78
                                        this.writePdfUnderlay<PdfUnderlay, PdfUnderlayDefinition>(pdfUnderlay);
×
NEW
79
                                        break;
×
80
                                case Point point:
81
                                        this.writePoint(point);
1,046✔
82
                                        break;
1,046✔
83
                                case Polyline polyline:
84
                                        this.writePolyline(polyline);
64✔
85
                                        break;
64✔
86
                                case RasterImage rasterImage:
87
                                        this.writeCadImage(rasterImage);
14✔
88
                                        break;
14✔
89
                                case Ray ray:
90
                                        this.writeRay(ray);
26✔
91
                                        break;
26✔
92
                                case Shape shape:
93
                                        this.writeShape(shape);
26✔
94
                                        break;
26✔
95
                                case Solid solid:
96
                                        this.writeSolid(solid);
360✔
97
                                        break;
360✔
98
                                case Spline spline:
99
                                        this.writeSpline(spline);
52✔
100
                                        break;
52✔
101
                                case TextEntity text:
102
                                        this.writeTextEntity(text);
936✔
103
                                        break;
936✔
104
                                case Tolerance tolerance:
105
                                        this.writeTolerance(tolerance);
78✔
106
                                        break;
78✔
107
                                case Vertex vertex:
108
                                        this.writeVertex(vertex);
260✔
109
                                        break;
260✔
110
                                case Viewport viewport:
111
                                        this.writeViewport(viewport);
114✔
112
                                        break;
114✔
113
                                case Wipeout wipeout:
114
                                        this.writeCadImage(wipeout);
14✔
115
                                        break;
14✔
116
                                case XLine xline:
117
                                        this.writeXLine(xline);
26✔
118
                                        break;
26✔
119
                                default:
120
                                        throw new NotImplementedException($"Entity not implemented {entity.GetType().FullName}");
×
121
                        }
122

123
                        this.writeExtendedData(entity.ExtendedData);
8,380✔
124
                }
8,416✔
125

126
                private void writeArc(Arc arc)
127
                {
84✔
128
                        DxfClassMap map = DxfClassMap.Create<Arc>();
84✔
129

130
                        this.writeCircle(arc);
84✔
131

132
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Arc);
84✔
133

134
                        this._writer.Write(50, arc.StartAngle, map);
84✔
135
                        this._writer.Write(51, arc.EndAngle, map);
84✔
136
                }
84✔
137

138
                private void writeCircle(Circle circle)
139
                {
307✔
140
                        DxfClassMap map = DxfClassMap.Create<Circle>();
307✔
141

142
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Circle);
307✔
143

144
                        this._writer.Write(10, circle.Center, map);
307✔
145

146
                        this._writer.Write(39, circle.Thickness, map);
307✔
147
                        this._writer.Write(40, circle.Radius, map);
307✔
148

149
                        this._writer.Write(210, circle.Normal, map);
307✔
150
                }
307✔
151

152
                private void writeDimension(Dimension dim)
153
                {
286✔
154
                        DxfClassMap map = DxfClassMap.Create<Dimension>();
286✔
155

156
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Dimension);
286✔
157

158
                        this._writer.WriteName(2, dim.Block, map);
286✔
159

160
                        this._writer.Write(10, dim.DefinitionPoint, map);
286✔
161
                        this._writer.Write(11, dim.TextMiddlePoint, map);
286✔
162

163
                        this._writer.Write(53, dim.TextRotation, map);
286✔
164
                        this._writer.Write(70, (short)dim.Flags, map);
286✔
165
                        this._writer.Write(71, (short)dim.AttachmentPoint, map);
286✔
166
                        this._writer.Write(72, (short)dim.LineSpacingStyle, map);
286✔
167
                        this._writer.Write(41, dim.LineSpacingFactor, map);
286✔
168

169
                        if (string.IsNullOrEmpty(dim.Text))
286✔
170
                        {
286✔
171
                                this._writer.Write(1, dim.Text, map);
286✔
172
                        }
286✔
173

174
                        this._writer.Write(210, dim.Normal, map);
286✔
175

176
                        this._writer.WriteName(3, dim.Style, map);
286✔
177

178
                        switch (dim)
286!
179
                        {
180
                                case DimensionAligned aligned:
181
                                        this.writeDimensionAligned(aligned);
130✔
182
                                        break;
130✔
183
                                case DimensionRadius radius:
184
                                        this.writeDimensionRadius(radius);
26✔
185
                                        break;
26✔
186
                                case DimensionDiameter diameter:
187
                                        this.writeDimensionDiameter(diameter);
26✔
188
                                        break;
26✔
189
                                case DimensionAngular2Line angular2Line:
190
                                        this.writeDimensionAngular2Line(angular2Line);
26✔
191
                                        break;
26✔
192
                                case DimensionAngular3Pt angular3Pt:
193
                                        this.writeDimensionAngular3Pt(angular3Pt);
26✔
194
                                        break;
26✔
195
                                case DimensionOrdinate ordinate:
196
                                        this.writeDimensionOrdinate(ordinate);
52✔
197
                                        break;
52✔
198
                                default:
199
                                        throw new NotImplementedException($"Dimension type not implemented {dim.GetType().FullName}");
×
200
                        }
201
                }
286✔
202

203
                private void writeDimensionAligned(DimensionAligned aligned)
204
                {
130✔
205
                        DxfClassMap map = DxfClassMap.Create<DimensionAligned>();
130✔
206

207
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.AlignedDimension);
130✔
208

209
                        this._writer.Write(13, aligned.FirstPoint, map);
130✔
210
                        this._writer.Write(14, aligned.SecondPoint, map);
130✔
211

212
                        if (aligned is DimensionLinear linear)
130✔
213
                        {
54✔
214
                                this.writeDimensionLinear(linear);
54✔
215
                        }
54✔
216
                }
130✔
217

218
                private void writeDimensionLinear(DimensionLinear linear)
219
                {
54✔
220
                        DxfClassMap map = DxfClassMap.Create<DimensionLinear>();
54✔
221

222
                        this._writer.Write(50, linear.Rotation, map);
54✔
223

224
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.LinearDimension);
54✔
225
                }
54✔
226

227
                private void writeDimensionRadius(DimensionRadius radius)
228
                {
26✔
229
                        DxfClassMap map = DxfClassMap.Create<DimensionRadius>();
26✔
230

231
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.RadialDimension);
26✔
232

233
                        this._writer.Write(15, radius.AngleVertex, map);
26✔
234

235
                        this._writer.Write(40, radius.LeaderLength, map);
26✔
236
                }
26✔
237

238
                private void writeDimensionDiameter(DimensionDiameter diameter)
239
                {
26✔
240
                        DxfClassMap map = DxfClassMap.Create<DimensionDiameter>();
26✔
241

242
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.DiametricDimension);
26✔
243

244
                        this._writer.Write(15, diameter.AngleVertex, map);
26✔
245

246
                        this._writer.Write(40, diameter.LeaderLength, map);
26✔
247
                }
26✔
248

249
                private void writeDimensionAngular2Line(DimensionAngular2Line angular2Line)
250
                {
26✔
251
                        DxfClassMap map = DxfClassMap.Create<DimensionAngular2Line>();
26✔
252

253
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Angular2LineDimension);
26✔
254

255
                        this._writer.Write(13, angular2Line.FirstPoint, map);
26✔
256
                        this._writer.Write(14, angular2Line.SecondPoint, map);
26✔
257
                        this._writer.Write(15, angular2Line.AngleVertex, map);
26✔
258
                        this._writer.Write(16, angular2Line.DimensionArc, map);
26✔
259
                }
26✔
260

261
                private void writeDimensionAngular3Pt(DimensionAngular3Pt angular3Pt)
262
                {
26✔
263
                        DxfClassMap map = DxfClassMap.Create<DimensionAngular3Pt>();
26✔
264

265
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Angular3PointDimension);
26✔
266

267
                        this._writer.Write(13, angular3Pt.FirstPoint, map);
26✔
268
                        this._writer.Write(14, angular3Pt.SecondPoint, map);
26✔
269
                        this._writer.Write(15, angular3Pt.AngleVertex, map);
26✔
270
                }
26✔
271

272
                private void writeDimensionOrdinate(DimensionOrdinate ordinate)
273
                {
52✔
274
                        DxfClassMap map = DxfClassMap.Create<DimensionOrdinate>();
52✔
275

276
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.OrdinateDimension);
52✔
277

278
                        this._writer.Write(13, ordinate.FeatureLocation, map);
52✔
279
                        this._writer.Write(14, ordinate.LeaderEndpoint, map);
52✔
280
                }
52✔
281

282
                private void writeHatch(Hatch hatch)
283
                {
208✔
284
                        DxfClassMap map = DxfClassMap.Create<Hatch>();
208✔
285

286
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Hatch);
208✔
287

288
                        this._writer.Write(10, 0, map);
208✔
289
                        this._writer.Write(20, 0, map);
208✔
290
                        this._writer.Write(30, hatch.Elevation, map);
208✔
291

292
                        this._writer.Write(210, hatch.Normal, map);
208✔
293

294
                        this._writer.Write(2, hatch.Pattern.Name, map);
208✔
295

296
                        this._writer.Write(70, hatch.IsSolid ? (short)1 : (short)0, map);
208✔
297
                        this._writer.Write(71, hatch.IsAssociative ? (short)1 : (short)0, map);
208✔
298

299
                        this._writer.Write(91, hatch.Paths.Count, map);
208✔
300
                        foreach (var path in hatch.Paths)
1,040✔
301
                        {
208✔
302
                                this.writeBoundaryPath(path);
208✔
303
                        }
208✔
304

305
                        this.writeHatchPattern(hatch, hatch.Pattern);
208✔
306

307
                        if (hatch.PixelSize != 0)
208✔
308
                        {
42✔
309
                                this._writer.Write(47, hatch.PixelSize, map);
42✔
310
                        }
42✔
311

312
                        this._writer.Write(98, hatch.SeedPoints.Count);
208✔
313
                        foreach (XY spoint in hatch.SeedPoints)
848✔
314
                        {
112✔
315
                                this._writer.Write(10, spoint);
112✔
316
                        }
112✔
317

318
                        //TODO: Implement HatchGradientPattern
319
                }
208✔
320

321
                private void writeBoundaryPath(Hatch.BoundaryPath path)
322
                {
208✔
323
                        this._writer.Write(92, (int)path.Flags);
208✔
324

325
                        if (!path.Flags.HasFlag(BoundaryPathFlags.Polyline))
208✔
326
                        {
130✔
327
                                this._writer.Write(93, path.Edges.Count);
130✔
328
                        }
130✔
329

330
                        foreach (Hatch.BoundaryPath.Edge edge in path.Edges)
1,820✔
331
                        {
598✔
332
                                this.writeHatchBoundaryPathEdge(edge);
598✔
333
                        }
598✔
334

335
                        this._writer.Write(97, path.Entities.Count);
208✔
336
                        foreach (Entity entity in path.Entities)
988✔
337
                        {
182✔
338
                                this._writer.WriteHandle(330, entity);
182✔
339
                        }
182✔
340
                }
208✔
341

342
                private void writeHatchBoundaryPathEdge(Hatch.BoundaryPath.Edge edge)
343
                {
598✔
344
                        if (edge is not Hatch.BoundaryPath.Polyline)
598✔
345
                        {
520✔
346
                                this._writer.Write(72, edge.Type);
520✔
347
                        }
520✔
348

349
                        switch (edge)
598!
350
                        {
351
                                case Hatch.BoundaryPath.Arc arc:
352
                                        this._writer.Write(10, arc.Center);
×
353
                                        this._writer.Write(40, arc.Radius);
×
354
                                        this._writer.Write(50, arc.StartAngle);
×
355
                                        this._writer.Write(51, arc.EndAngle);
×
356
                                        this._writer.Write(73, arc.CounterClockWise ? (short)1 : (short)0);
×
357
                                        break;
×
358
                                case Hatch.BoundaryPath.Ellipse ellipse:
359
                                        this._writer.Write(10, ellipse.Center);
×
360
                                        this._writer.Write(11, ellipse.MajorAxisEndPoint);
×
361
                                        this._writer.Write(40, ellipse.MinorToMajorRatio);
×
362
                                        this._writer.Write(50, ellipse.StartAngle);
×
363
                                        this._writer.Write(51, ellipse.EndAngle);
×
364
                                        this._writer.Write(73, ellipse.IsCounterclockwise ? (short)1 : (short)0);
×
365
                                        break;
×
366
                                case Hatch.BoundaryPath.Line line:
367
                                        this._writer.Write(10, line.Start);
520✔
368
                                        this._writer.Write(11, line.End);
520✔
369
                                        break;
520✔
370
                                case Hatch.BoundaryPath.Polyline poly:
371
                                        this._writer.Write(72, poly.HasBulge ? (short)1 : (short)0);
78!
372
                                        this._writer.Write(73, poly.IsClosed ? (short)1 : (short)0);
78✔
373
                                        this._writer.Write(93, poly.Vertices.Count);
78✔
374
                                        for (int i = 0; i < poly.Vertices.Count; i++)
780✔
375
                                        {
312✔
376
                                                this._writer.Write(10, (XY)poly.Vertices[i]);
312✔
377
                                                if (poly.HasBulge)
312!
378
                                                {
×
379
                                                        this._writer.Write(42, poly.Bulges.ElementAtOrDefault(i));
×
380
                                                }
×
381
                                        }
312✔
382
                                        break;
78✔
383
                                case Hatch.BoundaryPath.Spline spline:
384
                                        this._writer.Write(73, spline.Rational ? (short)1 : (short)0);
×
385
                                        this._writer.Write(74, spline.Periodic ? (short)1 : (short)0);
×
386

387
                                        this._writer.Write(94, (int)spline.Degree);
×
388
                                        this._writer.Write(95, spline.Knots.Count);
×
389
                                        this._writer.Write(96, spline.ControlPoints.Count);
×
390

391
                                        foreach (double knot in spline.Knots)
×
392
                                        {
×
393
                                                this._writer.Write(40, knot);
×
394
                                        }
×
395

396
                                        foreach (var point in spline.ControlPoints)
×
397
                                        {
×
398
                                                this._writer.Write(10, point.X);
×
399
                                                this._writer.Write(20, point.Y);
×
400
                                                if (spline.Rational)
×
401
                                                {
×
402
                                                        this._writer.Write(42, point.Z);
×
403
                                                }
×
404
                                        }
×
405
                                        break;
×
406
                                default:
407
                                        throw new ArgumentException($"Unknown Hatch.BoundaryPath.Edge type {edge.GetType().FullName}");
×
408
                        }
409
                }
598✔
410

411
                private void writeHatchPattern(Hatch hatch, HatchPattern pattern)
412
                {
208✔
413
                        this._writer.Write(75, (short)hatch.Style);
208✔
414
                        this._writer.Write(76, (short)hatch.PatternType);
208✔
415

416
                        if (!hatch.IsSolid)
208✔
417
                        {
156✔
418
                                this._writer.Write(52, MathHelper.RadToDeg(hatch.PatternAngle));
156✔
419
                                this._writer.Write(41, hatch.PatternScale);
156✔
420
                                this._writer.Write(77, (short)(hatch.IsDouble ? 1 : 0));
156!
421
                                this._writer.Write(78, (short)pattern.Lines.Count);
156✔
422
                                foreach (HatchPattern.Line line in pattern.Lines)
23,816✔
423
                                {
11,674✔
424
                                        this._writer.Write(53, MathHelper.RadToDeg(line.Angle));
11,674✔
425
                                        this._writer.Write(43, line.BasePoint.X);
11,674✔
426
                                        this._writer.Write(44, line.BasePoint.Y);
11,674✔
427
                                        this._writer.Write(45, line.Offset.X);
11,674✔
428
                                        this._writer.Write(46, line.Offset.Y);
11,674✔
429
                                        this._writer.Write(79, (short)line.DashLengths.Count);
11,674✔
430
                                        foreach (double dashLength in line.DashLengths)
81,614✔
431
                                        {
23,296✔
432
                                                this._writer.Write(49, dashLength);
23,296✔
433
                                        }
23,296✔
434
                                }
11,674✔
435
                        }
156✔
436
                }
208✔
437

438
                private void writeEllipse(Ellipse ellipse)
439
                {
26✔
440
                        DxfClassMap map = DxfClassMap.Create<Ellipse>();
26✔
441

442
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Ellipse);
26✔
443

444
                        this._writer.Write(10, ellipse.Center, map);
26✔
445

446
                        this._writer.Write(11, ellipse.EndPoint, map);
26✔
447

448
                        this._writer.Write(210, ellipse.Normal, map);
26✔
449

450
                        this._writer.Write(39, ellipse.Thickness, map);
26✔
451
                        this._writer.Write(40, ellipse.RadiusRatio, map);
26✔
452
                        this._writer.Write(41, ellipse.StartParameter, map);
26✔
453
                        this._writer.Write(42, ellipse.EndParameter, map);
26✔
454
                }
26✔
455

456
                private void writeFace3D(Face3D face)
457
                {
26✔
458
                        DxfClassMap map = DxfClassMap.Create<Face3D>();
26✔
459

460
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Face3d);
26✔
461

462
                        this._writer.Write(10, face.FirstCorner, map);
26✔
463
                        this._writer.Write(11, face.SecondCorner, map);
26✔
464
                        this._writer.Write(12, face.ThirdCorner, map);
26✔
465
                        this._writer.Write(13, face.FourthCorner, map);
26✔
466

467
                        this._writer.Write(70, (short)face.Flags, map);
26✔
468
                }
26✔
469

470
                private void writeInsert(Insert insert)
471
                {
322✔
472
                        DxfClassMap map = DxfClassMap.Create<Insert>();
322✔
473

474
                        this._writer.Write(DxfCode.Subclass, insert.SubclassMarker);
322✔
475

476
                        this._writer.WriteName(2, insert.Block, map);
322✔
477

478
                        this._writer.Write(10, insert.InsertPoint, map);
322✔
479

480
                        this._writer.Write(41, insert.XScale, map);
322✔
481
                        this._writer.Write(42, insert.YScale, map);
322✔
482
                        this._writer.Write(43, insert.ZScale, map);
322✔
483

484
                        this._writer.Write(50, insert.Rotation, map);
322✔
485

486

487
                        this._writer.Write(70, (short)insert.ColumnCount);
322✔
488
                        this._writer.Write(71, (short)insert.RowCount);
322✔
489

490
                        this._writer.Write(44, insert.ColumnSpacing);
322✔
491
                        this._writer.Write(45, insert.RowSpacing);
322✔
492

493
                        this._writer.Write(210, insert.Normal, map);
322✔
494

495
                        if (insert.HasAttributes)
322✔
496
                        {
52✔
497
                                this._writer.Write(66, 1);
52✔
498

499
                                //WARNING: Write extended data before attributes
500

501
                                foreach (var att in insert.Attributes)
364✔
502
                                {
104✔
503
                                        this.writeEntity(att);
104✔
504
                                }
104✔
505

506
                                this.writeSeqend(insert.Attributes.Seqend);
52✔
507
                        }
52✔
508
                }
322✔
509

510
                private void writeLeader(Leader leader)
511
                {
26✔
512
                        DxfClassMap map = DxfClassMap.Create<Leader>();
26✔
513

514
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Leader);
26✔
515

516
                        this._writer.WriteName(3, leader.Style, map);
26✔
517

518
                        this._writer.Write(71, leader.ArrowHeadEnabled ? (short)1 : (short)0, map);
26✔
519
                        this._writer.Write(72, (short)leader.PathType, map);
26✔
520
                        this._writer.Write(73, (short)leader.CreationType, map);
26✔
521
                        this._writer.Write(74, leader.HookLineDirection == HookLineDirection.Same ? (short)1 : (short)0, map);
26!
522
                        this._writer.Write(75, leader.HasHookline ? (short)1 : (short)0, map);
26!
523

524
                        this._writer.Write(40, leader.TextHeight, map);
26✔
525
                        this._writer.Write(41, leader.TextWidth, map);
26✔
526

527
                        this._writer.Write(76, leader.Vertices.Count, map);
26✔
528
                        foreach (var vertex in leader.Vertices)
258✔
529
                        {
90✔
530
                                this._writer.Write(10, vertex, map);
90✔
531
                        }
90✔
532

533
                        //this._writer.Write(77, leader,map);
534
                        //this._writer.Write(340, leader.Annotation,map);
535

536
                        this._writer.Write(210, leader.Normal, map);
26✔
537

538
                        this._writer.Write(211, leader.HorizontalDirection, map);
26✔
539
                        this._writer.Write(212, leader.BlockOffset, map);
26✔
540
                        this._writer.Write(213, leader.AnnotationOffset, map);
26✔
541
                }
26✔
542

543
                private void writeLine(Line line)
544
                {
2,415✔
545
                        DxfClassMap map = DxfClassMap.Create<Line>();
2,415✔
546

547
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Line);
2,415✔
548

549
                        this._writer.Write(10, line.StartPoint, map);
2,415✔
550

551
                        this._writer.Write(11, line.EndPoint, map);
2,415✔
552

553
                        this._writer.Write(39, line.Thickness, map);
2,415✔
554

555
                        this._writer.Write(210, line.Normal, map);
2,415✔
556
                }
2,415✔
557

558
                private void writeLwPolyline(LwPolyline polyline)
559
                {
552✔
560
                        DxfClassMap map = DxfClassMap.Create<LwPolyline>();
552✔
561

562
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.LwPolyline);
552✔
563

564
                        this._writer.Write(90, polyline.Vertices.Count);
552✔
565
                        this._writer.Write(70, (short)polyline.Flags);
552✔
566

567
                        this._writer.Write(38, polyline.Elevation);
552✔
568
                        this._writer.Write(39, polyline.Thickness);
552✔
569

570
                        foreach (LwPolyline.Vertex v in polyline.Vertices)
6,544✔
571
                        {
2,444✔
572
                                this._writer.Write(10, v.Location);
2,444✔
573
                                this._writer.Write(40, v.StartWidth);
2,444✔
574
                                this._writer.Write(41, v.EndWidth);
2,444✔
575
                                this._writer.Write(42, v.Bulge);
2,444✔
576
                        }
2,444✔
577

578
                        this._writer.Write(210, polyline.Normal, map);
552✔
579
                }
552✔
580

581
                private void writeMesh(Mesh mesh)
582
                {
52✔
583
                        DxfClassMap map = DxfClassMap.Create<Mesh>();
52✔
584

585
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Mesh);
52✔
586

587
                        this._writer.Write(71, (short)mesh.Version, map);
52✔
588
                        this._writer.Write(72, (short)(mesh.BlendCrease ? 1 : 0), map);
52!
589

590
                        this._writer.Write(91, mesh.SubdivisionLevel, map);
52✔
591

592
                        this._writer.Write(92, mesh.Vertices.Count, map);
52✔
593
                        foreach (XYZ vertex in mesh.Vertices)
6,708✔
594
                        {
3,276✔
595
                                this._writer.Write(10, vertex, map);
3,276✔
596
                        }
3,276✔
597

598
                        int nFaces = mesh.Faces.Count;
52✔
599
                        nFaces += mesh.Faces.Sum(f => f.Length);
3,588✔
600

601
                        this._writer.Write(93, nFaces);
52✔
602
                        foreach (int[] face in mesh.Faces)
7,228✔
603
                        {
3,536✔
604
                                this._writer.Write(90, face.Length);
3,536✔
605
                                foreach (int index in face)
37,648✔
606
                                {
13,520✔
607
                                        this._writer.Write(90, index);
13,520✔
608
                                }
13,520✔
609
                        }
3,536✔
610

611
                        this._writer.Write(94, mesh.Edges.Count, map);
52✔
612
                        foreach (Mesh.Edge edge in mesh.Edges)
13,676✔
613
                        {
6,760✔
614
                                this._writer.Write(90, edge.Start);
6,760✔
615
                                this._writer.Write(90, edge.End);
6,760✔
616
                        }
6,760✔
617

618
                        this._writer.Write(95, mesh.Edges.Count, map);
52✔
619
                        foreach (Mesh.Edge edge in mesh.Edges)
13,676✔
620
                        {
6,760✔
621
                                this._writer.Write(140, edge.Crease);
6,760✔
622
                        }
6,760✔
623

624
                        this._writer.Write(90, 0);
52✔
625
                }
52✔
626

627
                private void writeMLine(MLine mLine)
628
                {
78✔
629
                        DxfClassMap map = DxfClassMap.Create<MLine>();
78✔
630

631
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.MLine);
78✔
632

633
                        //Style has two references
634
                        this._writer.WriteName(2, mLine.Style, map);
78✔
635
                        this._writer.WriteHandle(340, mLine.Style, map);
78✔
636

637
                        this._writer.Write(40, mLine.ScaleFactor);
78✔
638

639
                        this._writer.Write(70, (short)mLine.Justification);
78✔
640
                        this._writer.Write(71, (short)mLine.Flags);
78✔
641
                        this._writer.Write(72, (short)mLine.Vertices.Count);
78✔
642

643
                        if (mLine.Style != null)
78✔
644
                        {
78✔
645
                                this._writer.Write(73, (short)mLine.Style.Elements.Count);
78✔
646
                        }
78✔
647

648
                        this._writer.Write(10, mLine.StartPoint, map);
78✔
649

650
                        this._writer.Write(210, mLine.Normal);
78✔
651

652
                        foreach (var v in mLine.Vertices)
858✔
653
                        {
312✔
654
                                this._writer.Write(11, v.Position, map);
312✔
655
                                this._writer.Write(12, v.Direction, map);
312✔
656
                                this._writer.Write(13, v.Miter, map);
312✔
657

658
                                foreach (var s in v.Segments)
2,184✔
659
                                {
624✔
660
                                        this._writer.Write(74, (short)s.Parameters.Count);
624✔
661
                                        foreach (double parameter in s.Parameters)
4,472✔
662
                                        {
1,300✔
663
                                                this._writer.Write(41, parameter);
1,300✔
664
                                        }
1,300✔
665
                                        this._writer.Write(75, (short)s.AreaFillParameters.Count);
624✔
666
                                        foreach (double areaFillParameter in s.AreaFillParameters)
1,872!
667
                                        {
×
668
                                                this._writer.Write(42, areaFillParameter);
×
669
                                        }
×
670
                                }
624✔
671
                        }
312✔
672
                }
78✔
673

674
                private void writeMText(MText mtext, bool writeSubclass = true)
675
                {
864✔
676
                        DxfClassMap map = DxfClassMap.Create<MText>();
864✔
677

678
                        if (writeSubclass)
864✔
679
                        {
856✔
680
                                this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.MText);
856✔
681
                        }
856✔
682

683
                        this._writer.Write(10, mtext.InsertPoint, map);
864✔
684

685
                        this._writer.Write(40, mtext.Height, map);
864✔
686
                        this._writer.Write(41, mtext.RectangleWidth, map);
864✔
687
                        this._writer.Write(44, mtext.LineSpacing, map);
864✔
688

689
                        if (this.Version >= ACadVersion.AC1021)
864✔
690
                        {
564✔
691
                                this._writer.Write(46, mtext.RectangleHeight, map);
564✔
692
                        }
564✔
693

694
                        this._writer.Write(71, (short)mtext.AttachmentPoint, map);
864✔
695
                        this._writer.Write(72, (short)mtext.DrawingDirection, map);
864✔
696

697
                        this.writeLongTextValue(1, 3, mtext.Value);
864✔
698

699
                        this._writer.WriteName(7, mtext.Style);
864✔
700

701
                        this._writer.Write(73, (short)mtext.LineSpacingStyle, map);
864✔
702

703
                        this._writer.Write(11, mtext.AlignmentPoint, map);
864✔
704

705
                        this._writer.Write(210, mtext.Normal, map);
864✔
706
                }
864✔
707

708
                private void writeMultiLeader(MultiLeader multiLeader)
709
                {
210✔
710
                        MultiLeaderAnnotContext contextData = multiLeader.ContextData;
210✔
711

712
                        this._writer.Write(100, "AcDbMLeader");
210✔
713

714
                        //        version
715
                        //        if (Version > ACadVersion.
716
                        this._writer.Write(270, 2);
210✔
717

718
                        writeMultiLeaderAnnotContext(contextData);
210✔
719

720
                        //        MultiLeader properties
721
                        this._writer.WriteHandle(340, multiLeader.Style);
210✔
722
                        this._writer.Write(90, multiLeader.PropertyOverrideFlags);
210✔
723
                        this._writer.Write(170, (short)multiLeader.PathType);
210✔
724

725
                        this._writer.WriteCmColor(91, multiLeader.LineColor);
210✔
726

727
                        this._writer.WriteHandle(341, multiLeader.LineType);
210✔
728
                        this._writer.Write(171, (short)multiLeader.LeaderLineWeight);
210✔
729
                        this._writer.Write(290, multiLeader.EnableLanding);
210✔
730
                        this._writer.Write(291, multiLeader.EnableDogleg);
210✔
731
                        this._writer.Write(41, multiLeader.LandingDistance);
210✔
732
                        this._writer.Write(42, multiLeader.ArrowheadSize);
210✔
733
                        this._writer.Write(172, (short)multiLeader.ContentType);
210✔
734
                        this._writer.WriteHandle(343, multiLeader.TextStyle);
210✔
735
                        this._writer.Write(173, (short)multiLeader.TextLeftAttachment);
210✔
736
                        this._writer.Write(95, (short)multiLeader.TextRightAttachment);
210✔
737
                        this._writer.Write(174, (short)multiLeader.TextAngle);
210✔
738
                        this._writer.Write(175, (short)multiLeader.TextAlignment);
210✔
739

740
                        this._writer.WriteCmColor(92, multiLeader.TextColor);
210✔
741

742
                        this._writer.Write(292, multiLeader.TextFrame);
210✔
743

744
                        this._writer.WriteCmColor(93, multiLeader.BlockContentColor);
210✔
745

746
                        this._writer.Write(10, multiLeader.BlockContentScale);
210✔
747

748
                        this._writer.Write(43, multiLeader.BlockContentRotation);
210✔
749
                        this._writer.Write(176, (short)multiLeader.BlockContentConnection);
210✔
750
                        this._writer.Write(293, multiLeader.EnableAnnotationScale);
210✔
751
                        this._writer.Write(294, multiLeader.TextDirectionNegative);
210✔
752
                        this._writer.Write(178, multiLeader.TextAligninIPE);
210✔
753
                        this._writer.Write(179, multiLeader.TextAttachmentPoint);
210✔
754
                        this._writer.Write(45, multiLeader.ScaleFactor);
210✔
755
                        this._writer.Write(271, multiLeader.TextAttachmentDirection);
210✔
756
                        this._writer.Write(272, multiLeader.TextBottomAttachment);
210✔
757
                        this._writer.Write(273, multiLeader.TextTopAttachment);
210✔
758
                        this._writer.Write(295, 0);
210✔
759
                }
210✔
760

761
                private void writeMultiLeaderAnnotContext(MultiLeaderAnnotContext contextData)
762
                {
210✔
763
                        this._writer.Write(300, "CONTEXT_DATA{");
210✔
764
                        this._writer.Write(40, contextData.ScaleFactor);
210✔
765
                        this._writer.Write(10, contextData.ContentBasePoint);
210✔
766
                        this._writer.Write(41, contextData.TextHeight);
210✔
767
                        this._writer.Write(140, contextData.ArrowheadSize);
210✔
768
                        this._writer.Write(145, contextData.LandingGap);
210✔
769
                        this._writer.Write(174, (short)contextData.TextLeftAttachment);
210✔
770
                        this._writer.Write(175, (short)contextData.TextRightAttachment);
210✔
771
                        this._writer.Write(176, (short)contextData.TextAlignment);
210✔
772
                        this._writer.Write(177, (short)contextData.BlockContentConnection);
210✔
773
                        this._writer.Write(290, contextData.HasTextContents);
210✔
774
                        this._writer.Write(304, contextData.TextLabel);
210✔
775

776
                        this._writer.Write(11, contextData.TextNormal);
210✔
777

778
                        this._writer.WriteHandle(340, contextData.TextStyle);
210✔
779

780
                        this._writer.Write(12, contextData.TextLocation);
210✔
781

782
                        this._writer.Write(13, contextData.Direction);
210✔
783

784
                        this._writer.Write(42, contextData.TextRotation);
210✔
785
                        this._writer.Write(43, contextData.BoundaryWidth);
210✔
786
                        this._writer.Write(44, contextData.BoundaryHeight);
210✔
787
                        this._writer.Write(45, contextData.LineSpacingFactor);
210✔
788
                        this._writer.Write(170, (short)contextData.LineSpacing);
210✔
789

790
                        this._writer.WriteCmColor(90, contextData.TextColor);
210✔
791

792
                        this._writer.Write(171, (short)contextData.TextAttachmentPoint);
210✔
793
                        this._writer.Write(172, (short)contextData.FlowDirection);
210✔
794

795
                        this._writer.WriteCmColor(91, contextData.BackgroundFillColor);
210✔
796

797
                        this._writer.Write(141, contextData.BackgroundScaleFactor);
210✔
798
                        this._writer.Write(92, contextData.BackgroundTransparency);
210✔
799
                        this._writer.Write(291, contextData.BackgroundFillEnabled);
210✔
800
                        this._writer.Write(292, contextData.BackgroundMaskFillOn);
210✔
801
                        this._writer.Write(173, contextData.ColumnType);
210✔
802
                        this._writer.Write(293, contextData.TextHeightAutomatic);
210✔
803
                        this._writer.Write(142, contextData.ColumnWidth);
210✔
804
                        this._writer.Write(143, contextData.ColumnGutter);
210✔
805
                        this._writer.Write(294, contextData.ColumnFlowReversed);
210✔
806
                        this._writer.Write(295, contextData.WordBreak);
210✔
807

808
                        this._writer.Write(296, contextData.HasContentsBlock);
210✔
809

810
                        this._writer.Write(110, contextData.BasePoint);
210✔
811

812
                        this._writer.Write(111, contextData.BaseDirection);
210✔
813

814
                        this._writer.Write(112, contextData.BaseVertical);
210✔
815

816
                        this._writer.Write(297, contextData.NormalReversed);
210✔
817

818
                        foreach (MultiLeaderAnnotContext.LeaderRoot leaderRoot in contextData.LeaderRoots)
1,050✔
819
                        {
210✔
820
                                writeLeaderRoot(leaderRoot);
210✔
821
                        }
210✔
822

823
                        this._writer.Write(272, (short)contextData.TextBottomAttachment);
210✔
824
                        this._writer.Write(273, (short)contextData.TextTopAttachment);
210✔
825
                        this._writer.Write(301, "}");       //        CONTEXT_DATA
210✔
826
                }
210✔
827

828
                private void writeLeaderRoot(MultiLeaderAnnotContext.LeaderRoot leaderRoot)
829
                {
210✔
830
                        this._writer.Write(302, "LEADER{");
210✔
831

832
                        // TODO: true is placeholder
833
                        this._writer.Write(290, true ? (short)1 : (short)0); // Has Set Last Leader Line Point
210✔
834
                        this._writer.Write(291, true ? (short)1 : (short)0); // Has Set Dogleg Vector
210✔
835

836
                        this._writer.Write(10, leaderRoot.ConnectionPoint);
210✔
837

838
                        this._writer.Write(11, leaderRoot.Direction);
210✔
839

840
                        this._writer.Write(90, leaderRoot.LeaderIndex);
210✔
841
                        this._writer.Write(40, leaderRoot.LandingDistance);
210✔
842

843
                        foreach (MultiLeaderAnnotContext.LeaderLine leaderLine in leaderRoot.Lines)
1,050✔
844
                        {
210✔
845
                                writeLeaderLine(leaderLine);
210✔
846
                        }
210✔
847

848
                        this._writer.Write(271, 0);
210✔
849
                        this._writer.Write(303, "}");   //        LEADER
210✔
850
                }
210✔
851

852
                private void writeLeaderLine(MultiLeaderAnnotContext.LeaderLine leaderLine)
853
                {
210✔
854
                        this._writer.Write(304, "LEADER_LINE{");
210✔
855

856
                        foreach (XYZ point in leaderLine.Points)
1,050✔
857
                        {
210✔
858
                                this._writer.Write(10, point);
210✔
859
                        }
210✔
860
                        this._writer.Write(91, leaderLine.Index);
210✔
861

862
                        this._writer.Write(305, "}");   //        LEADER_Line
210✔
863
                }
210✔
864

865
                private void writePdfUnderlay<T,R>(T underlay)
866
                        where T : UnderlayEntity<R>
867
                        where R : UnderlayDefinition
NEW
868
                {
×
NEW
869
                        DxfClassMap map = DxfClassMap.Create<T>();
×
870

NEW
871
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Underlay);
×
872

NEW
873
                        this._writer.WriteHandle(340, underlay.Definition, map);
×
874

NEW
875
                        this._writer.Write(10, underlay.InsertPoint, map);
×
876

NEW
877
                        this._writer.Write(280, underlay.Flags, map);
×
NEW
878
                        this._writer.Write(281, underlay.Contrast, map);
×
NEW
879
                        this._writer.Write(282, underlay.Fade, map);
×
880

NEW
881
                        foreach (XY bv in underlay.ClipBoundaryVertices)
×
NEW
882
                        {
×
NEW
883
                                this._writer.Write(11, bv, map);
×
NEW
884
                        }
×
885

NEW
886
                }
×
887

888
                private void writePoint(Point point)
889
                {
1,046✔
890
                        DxfClassMap map = DxfClassMap.Create<Point>();
1,046✔
891

892
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Point);
1,046✔
893

894
                        this._writer.Write(10, point.Location, map);
1,046✔
895

896
                        this._writer.Write(39, point.Thickness, map);
1,046✔
897

898
                        this._writer.Write(210, point.Normal, map);
1,046✔
899

900
                        this._writer.Write(50, point.Rotation, map);
1,046✔
901
                }
1,046✔
902

903
                private void writePolyline(Polyline polyline)
904
                {
64✔
905
                        DxfClassMap map;
906

907
                        switch (polyline)
64!
908
                        {
909
                                case Polyline2D:
910
                                        map = DxfClassMap.Create<Polyline2D>();
6✔
911
                                        break;
6✔
912
                                case Polyline3D:
913
                                        map = DxfClassMap.Create<Polyline3D>();
32✔
914
                                        break;
32✔
915
                                case PolyfaceMesh:
916
                                        map = DxfClassMap.Create<PolyfaceMesh>();
26✔
917
                                        break;
26✔
918
                                default:
919
                                        throw new NotImplementedException($"Polyline not implemented {polyline.GetType().FullName}");
×
920
                        }
921

922
                        this._writer.Write(DxfCode.Subclass, polyline.SubclassMarker);
64✔
923

924
                        this._writer.Write(DxfCode.XCoordinate, 0);
64✔
925
                        this._writer.Write(DxfCode.YCoordinate, 0);
64✔
926
                        this._writer.Write(DxfCode.ZCoordinate, polyline.Elevation);
64✔
927

928
                        this._writer.Write(70, (short)polyline.Flags, map);
64✔
929
                        this._writer.Write(75, (short)polyline.SmoothSurface, map);
64✔
930

931
                        this._writer.Write(210, polyline.Normal, map);
64✔
932

933
                        if (polyline.Vertices.Any())
64✔
934
                        {
52✔
935
                                foreach (Vertex v in polyline.Vertices)
676✔
936
                                {
260✔
937
                                        this.writeEntity(v);
260✔
938
                                }
260✔
939

940
                                this.writeSeqend(polyline.Vertices.Seqend);
52✔
941
                        }
52✔
942
                }
64✔
943

944
                private void writeSeqend(Seqend seqend)
945
                {
104✔
946
                        this._writer.Write(0, seqend.ObjectName);
104✔
947
                        this._writer.Write(5, seqend.Handle);
104✔
948
                        this._writer.Write(330, seqend.Owner.Handle);
104✔
949
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Entity);
104✔
950
                        this._writer.Write(8, seqend.Layer.Name);
104✔
951
                }
104✔
952

953
                private void writeRay(Ray ray)
954
                {
26✔
955
                        DxfClassMap map = DxfClassMap.Create<Ray>();
26✔
956

957
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Ray);
26✔
958

959
                        this._writer.Write(10, ray.StartPoint, map);
26✔
960

961
                        this._writer.Write(11, ray.Direction, map);
26✔
962
                }
26✔
963

964
                private void writeShape(Shape shape)
965
                {
26✔
966
                        DxfClassMap map = DxfClassMap.Create<Shape>();
26✔
967

968
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Shape);
26✔
969

970
                        this._writer.Write(39, shape.Thickness, map);
26✔
971

972
                        this._writer.Write(10, shape.InsertionPoint, map);
26✔
973

974
                        this._writer.Write(40, shape.Size, map);
26✔
975

976
                        this._writer.WriteName(2, shape.ShapeStyle, map);
26✔
977

978
                        this._writer.Write(50, shape.Rotation, map);
26✔
979

980
                        this._writer.Write(41, shape.RelativeXScale, map);
26✔
981
                        this._writer.Write(51, shape.ObliqueAngle, map);
26✔
982

983
                        this._writer.Write(210, shape.Normal, map);
26✔
984
                }
26✔
985

986
                private void writeSolid(Solid solid)
987
                {
360✔
988
                        DxfClassMap map = DxfClassMap.Create<Solid>();
360✔
989

990
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Solid);
360✔
991

992
                        this._writer.Write(10, solid.FirstCorner, map);
360✔
993
                        this._writer.Write(11, solid.SecondCorner, map);
360✔
994
                        this._writer.Write(12, solid.ThirdCorner, map);
360✔
995
                        this._writer.Write(13, solid.FourthCorner, map);
360✔
996

997
                        this._writer.Write(39, solid.Thickness, map);
360✔
998

999
                        this._writer.Write(210, solid.Normal, map);
360✔
1000
                }
360✔
1001

1002
                private void writeSpline(Spline spline)
1003
                {
52✔
1004
                        DxfClassMap map = DxfClassMap.Create<Spline>();
52✔
1005

1006
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Spline);
52✔
1007

1008
                        if (spline.Flags.HasFlag(SplineFlags.Planar))
52✔
1009
                        {
24✔
1010
                                this._writer.Write(210, spline.Normal, map);
24✔
1011
                        }
24✔
1012

1013
                        this._writer.Write(70, (short)spline.Flags, map);
52✔
1014
                        this._writer.Write(71, (short)spline.Degree, map);
52✔
1015
                        this._writer.Write(72, (short)spline.Knots.Count, map);
52✔
1016
                        this._writer.Write(73, (short)spline.ControlPoints.Count, map);
52✔
1017

1018
                        if (spline.FitPoints.Any())
52✔
1019
                        {
4✔
1020
                                this._writer.Write(74, (short)spline.FitPoints.Count, map);
4✔
1021
                        }
4✔
1022

1023
                        this._writer.Write(42, spline.KnotTolerance, map);
52✔
1024
                        this._writer.Write(43, spline.ControlPointTolerance, map);
52✔
1025
                        this._writer.Write(44, spline.FitTolerance, map);
52✔
1026

1027
                        this._writer.Write(12, spline.StartTangent, map);
52✔
1028
                        this._writer.Write(13, spline.EndTangent, map);
52✔
1029

1030
                        foreach (double knot in spline.Knots)
924✔
1031
                        {
384✔
1032
                                this._writer.Write(40, knot, map);
384✔
1033
                        }
384✔
1034
                        foreach (double weight in spline.Weights)
156!
1035
                        {
×
1036
                                this._writer.Write(41, weight, map);
×
1037
                        }
×
1038
                        foreach (var cp in spline.ControlPoints)
540✔
1039
                        {
192✔
1040
                                this._writer.Write(10, cp, map);
192✔
1041
                        }
192✔
1042
                        foreach (var fp in spline.FitPoints)
172✔
1043
                        {
8✔
1044
                                this._writer.Write(11, fp, map);
8✔
1045
                        }
8✔
1046
                }
52✔
1047

1048
                private void writeTextEntity(TextEntity text)
1049
                {
936✔
1050
                        DxfClassMap map = DxfClassMap.Create<TextEntity>();
936✔
1051

1052
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Text);
936✔
1053

1054
                        this._writer.Write(1, text.Value, map);
936✔
1055

1056
                        this._writer.Write(10, text.InsertPoint, map);
936✔
1057

1058
                        this._writer.Write(40, text.Height, map);
936✔
1059

1060
                        if (text.WidthFactor != 1.0)
936!
1061
                        {
×
1062
                                this._writer.Write(41, text.WidthFactor, map);
×
1063
                        }
×
1064

1065
                        if (text.Rotation != 0.0)
936!
1066
                        {
×
1067
                                this._writer.Write(50, text.Rotation, map);
×
1068
                        }
×
1069

1070
                        if (text.ObliqueAngle != 0.0)
936!
1071
                        {
×
1072
                                this._writer.Write(51, text.ObliqueAngle, map);
×
1073
                        }
×
1074

1075
                        this._writer.Write(7, text.Style.Name);
936✔
1076

1077
                        this._writer.Write(11, text.AlignmentPoint, map);
936✔
1078

1079
                        this._writer.Write(210, text.Normal, map);
936✔
1080

1081
                        if (text.Mirror != 0)
936!
1082
                        {
×
1083
                                this._writer.Write(71, text.Mirror, map);
×
1084
                        }
×
1085
                        if (text.HorizontalAlignment != 0)
936!
1086
                        {
×
1087
                                this._writer.Write(72, text.HorizontalAlignment, map);
×
1088
                        }
×
1089

1090
                        if (text.GetType() == typeof(TextEntity))
936✔
1091
                        {
702✔
1092
                                this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Text);
702✔
1093

1094
                                if (text.VerticalAlignment != 0)
702!
1095
                                {
×
1096
                                        this._writer.Write(73, text.VerticalAlignment, map);
×
1097
                                }
×
1098
                        }
702✔
1099

1100
                        if (text is AttributeBase)
936✔
1101
                        {
234✔
1102
                                switch (text)
234!
1103
                                {
1104
                                        case AttributeEntity att:
1105
                                                this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Attribute);
104✔
1106
                                                this.writeAttributeBase(att);
104✔
1107
                                                break;
104✔
1108
                                        case AttributeDefinition attdef:
1109
                                                this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.AttributeDefinition);
130✔
1110
                                                this._writer.Write(3, attdef.Prompt, DxfClassMap.Create<AttributeDefinition>());
130✔
1111
                                                this.writeAttributeBase(attdef);
130✔
1112
                                                break;
130✔
1113
                                        default:
1114
                                                throw new ArgumentException($"Unknown AttributeBase type {text.GetType().FullName}");
×
1115
                                }
1116
                        }
234✔
1117
                }
936✔
1118

1119
                private void writeTolerance(Tolerance tolerance)
1120
                {
78✔
1121
                        DxfClassMap map = DxfClassMap.Create<Tolerance>();
78✔
1122

1123
                        this._writer.Write(DxfCode.Subclass, tolerance.SubclassMarker);
78✔
1124

1125
                        this._writer.WriteName(3, tolerance.Style, map);
78✔
1126

1127
                        this._writer.Write(10, tolerance.InsertionPoint, map);
78✔
1128
                        this._writer.Write(11, tolerance.Direction, map);
78✔
1129
                        this._writer.Write(210, tolerance.Normal, map);
78✔
1130
                        this._writer.Write(1, tolerance.Text, map);
78✔
1131
                }
78✔
1132

1133
                private void writeAttributeBase(AttributeBase att)
1134
                {
234✔
1135
                        this._writer.Write(2, att.Tag);
234✔
1136

1137
                        this._writer.Write(70, (short)att.Flags);
234✔
1138
                        this._writer.Write(73, (short)0);
234✔
1139

1140
                        if (att.VerticalAlignment != 0)
234✔
1141
                        {
82✔
1142
                                this._writer.Write(74, (short)att.VerticalAlignment);
82✔
1143
                        }
82✔
1144

1145
                        if (this.Version > ACadVersion.AC1027 && att.MText != null)
234✔
1146
                        {
8✔
1147
                                this._writer.Write(71, (short)att.AttributeType);
8✔
1148
                                this._writer.Write(72, (short)0);
8✔
1149
                                this._writer.Write(11, att.AlignmentPoint);
8✔
1150

1151
                                this.writeMText(att.MText, false);
8✔
1152
                        }
8✔
1153
                }
234✔
1154

1155
                private void writeVertex(Vertex v)
1156
                {
260✔
1157
                        DxfClassMap map = DxfClassMap.Create<Vertex>();
260✔
1158

1159
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Vertex);
260✔
1160
                        this._writer.Write(DxfCode.Subclass, v.SubclassMarker);
260✔
1161

1162
                        this._writer.Write(10, v.Location, map);
260✔
1163

1164
                        this._writer.Write(40, v.StartWidth, map);
260✔
1165
                        this._writer.Write(41, v.EndWidth, map);
260✔
1166
                        this._writer.Write(42, v.Bulge, map);
260✔
1167

1168
                        this._writer.Write(70, v.Flags, map);
260✔
1169

1170
                        this._writer.Write(50, v.CurveTangent, map);
260✔
1171
                }
260✔
1172

1173
                private void writeViewport(Viewport vp)
1174
                {
114✔
1175
                        DxfClassMap map = DxfClassMap.Create<Viewport>();
114✔
1176

1177
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Viewport);
114✔
1178

1179
                        this._writer.Write(10, vp.Center, map);
114✔
1180

1181
                        this._writer.Write(40, vp.Width, map);
114✔
1182
                        this._writer.Write(41, vp.Height, map);
114✔
1183

1184
                        this._writer.Write(69, vp.Id, map);
114✔
1185

1186
                        this._writer.Write(12, vp.ViewCenter, map);
114✔
1187

1188
                        this._writer.Write(13, vp.SnapBase, map);
114✔
1189

1190
                        this._writer.Write(14, vp.SnapSpacing, map);
114✔
1191

1192
                        this._writer.Write(15, vp.GridSpacing, map);
114✔
1193

1194
                        this._writer.Write(16, vp.ViewDirection, map);
114✔
1195

1196
                        this._writer.Write(17, vp.ViewTarget, map);
114✔
1197

1198
                        this._writer.Write(42, vp.LensLength, map);
114✔
1199

1200
                        this._writer.Write(43, vp.FrontClipPlane, map);
114✔
1201
                        this._writer.Write(44, vp.BackClipPlane, map);
114✔
1202
                        this._writer.Write(45, vp.ViewHeight, map);
114✔
1203

1204
                        this._writer.Write(50, vp.SnapAngle, map);
114✔
1205
                        this._writer.Write(51, vp.TwistAngle, map);
114✔
1206

1207
                        this._writer.Write(72, vp.CircleZoomPercent, map);
114✔
1208

1209
                        foreach (var layer in vp.FrozenLayers)
342!
1210
                        {
×
1211
                                this._writer.Write(331, layer.Handle, map);
×
1212
                        }
×
1213

1214
                        this._writer.Write(90, (int)vp.Status, map);
114✔
1215

1216
                        if (vp.Boundary != null)
114!
1217
                        {
×
1218
                                this._writer.Write(340, vp.Boundary.Handle, map);
×
1219
                        }
×
1220

1221
                        this._writer.Write(110, vp.UcsOrigin, map);
114✔
1222

1223
                        this._writer.Write(111, vp.UcsXAxis, map);
114✔
1224

1225
                        this._writer.Write(112, vp.UcsYAxis, map);
114✔
1226
                }
114✔
1227

1228
                private void writeCadImage<T>(T image)
1229
                        where T : CadWipeoutBase
1230
                {
28✔
1231
                        DxfClassMap map = DxfClassMap.Create<T>();
28✔
1232

1233
                        this._writer.Write(DxfCode.Subclass, image.SubclassMarker);
28✔
1234

1235
                        this._writer.Write(90, image.ClassVersion, map);
28✔
1236

1237
                        this._writer.Write(10, image.InsertPoint, map);
28✔
1238
                        this._writer.Write(11, image.UVector, map);
28✔
1239
                        this._writer.Write(12, image.VVector, map);
28✔
1240
                        this._writer.Write(13, image.Size, map);
28✔
1241

1242
                        this._writer.WriteHandle(340, image.Definition, map);
28✔
1243

1244
                        this._writer.Write(70, (short)image.Flags, map);
28✔
1245

1246
                        this._writer.Write(280, image.ClippingState, map);
28✔
1247
                        this._writer.Write(281, image.Brightness, map);
28✔
1248
                        this._writer.Write(282, image.Contrast, map);
28✔
1249
                        this._writer.Write(283, image.Fade, map);
28✔
1250

1251
                        //this._writer.WriteHandle(360, image.DefinitionReactor, map);
1252

1253
                        this._writer.Write(71, (short)image.ClipType, map);
28✔
1254

1255
                        if (image.ClipType == ClipType.Polygonal)
28✔
1256
                        {
14✔
1257
                                this._writer.Write(91, image.ClipBoundaryVertices.Count + 1, map);
14✔
1258
                                foreach (XY bv in image.ClipBoundaryVertices)
154✔
1259
                                {
56✔
1260
                                        this._writer.Write(14, bv, map);
56✔
1261
                                }
56✔
1262

1263
                                this._writer.Write(14, image.ClipBoundaryVertices.First(), map);
14✔
1264
                        }
14✔
1265
                        else
1266
                        {
14✔
1267
                                this._writer.Write(91, image.ClipBoundaryVertices.Count, map);
14✔
1268
                                foreach (XY bv in image.ClipBoundaryVertices)
98✔
1269
                                {
28✔
1270
                                        this._writer.Write(14, bv, map);
28✔
1271
                                }
28✔
1272
                        }
14✔
1273
                }
28✔
1274

1275
                private void writeXLine(XLine xline)
1276
                {
26✔
1277
                        DxfClassMap map = DxfClassMap.Create<XLine>();
26✔
1278

1279
                        this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.XLine);
26✔
1280

1281
                        this._writer.Write(10, xline.FirstPoint, map);
26✔
1282
                        this._writer.Write(11, xline.Direction, map);
26✔
1283
                }
26✔
1284
        }
1285
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc