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

DomCR / ACadSharp / 25273872940

03 May 2026 08:06AM UTC coverage: 76.734% (-0.2%) from 76.965%
25273872940

Pull #1059

github

web-flow
Merge ead68d9bb into 76d062bc8
Pull Request #1059: issue-1058 dxf copy to clipboard fix

8548 of 12079 branches covered (70.77%)

Branch coverage included in aggregate %.

363 of 573 new or added lines in 4 files covered. (63.35%)

16 existing lines in 2 files now uncovered.

30697 of 39065 relevant lines covered (78.58%)

152616.31 hits per line

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

61.55
/src/ACadSharp/IO/DXF/DxfStreamWriter/DxfObjectsSectionWriter.cs
1
using ACadSharp.Entities;
2
using ACadSharp.Objects;
3
using ACadSharp.Objects.Evaluations;
4
using CSMath;
5
using System;
6
using System.Linq;
7

8
namespace ACadSharp.IO.DXF;
9

10
internal class DxfObjectsSectionWriter : DxfSectionWriterBase
11
{
12
        public override string SectionName { get { return DxfFileToken.ObjectsSection; } }
1,341✔
13

14
        public DxfObjectsSectionWriter(IDxfStreamWriter writer, CadDocument document, CadObjectHolder holder, DxfWriterConfiguration configuration)
15
                : base(writer, document, holder, configuration)
447✔
16
        {
447✔
17
        }
447✔
18

19
        protected void writeBookColor(BookColor color)
20
        {
25✔
21
                this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.DbColor);
25✔
22

23
                this._writer.Write(62, color.Color.GetApproxIndex());
25✔
24
                this._writer.WriteTrueColor(420, color.Color);
25✔
25
                this._writer.Write(430, $"{color.Name}${color.BookName}");
25✔
26
        }
25✔
27

28
        protected void writeDictionary(CadDictionary dict)
29
        {
3,012✔
30
                this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Dictionary);
3,012✔
31

32
                this._writer.Write(280, dict.HardOwnerFlag);
3,012✔
33
                this._writer.Write(281, (int)dict.ClonningFlags);
3,012✔
34

35
                foreach (NonGraphicalObject item in dict)
16,857✔
36
                {
4,134✔
37
                        if (item is XRecord && !this.Configuration.WriteXRecords)
4,134!
UNCOV
38
                        {
×
NEW
39
                                continue;
×
40
                        }
41

42
                        //Not compatible dictionaries
43
                        if (item.Name == CadDictionary.AcadTableStyle
4,134!
44
                                        || item.Name == CadDictionary.AcadMaterial)
4,134✔
45
                        {
447✔
46
                                return;
447✔
47
                        }
48

49
                        this._writer.Write(3, item.Name);
3,687✔
50
                        this._writer.Write(350, item.Handle);
3,687✔
51

52
                        this.Holder.Objects.Enqueue(item);
3,687✔
53
                }
3,687✔
54

55
                if (dict is CadDictionaryWithDefault withDefault)
2,565!
UNCOV
56
                {
×
NEW
57
                        this._writer.Write(100, DxfSubclassMarker.DictionaryWithDefault);
×
NEW
58
                        this._writer.WriteHandle(340, withDefault.DefaultEntry);
×
NEW
59
                }
×
60
        }
3,012✔
61

62
        protected void writeDictionaryVariable(DictionaryVariable dictvar)
NEW
63
        {
×
NEW
64
                DxfClassMap map = DxfClassMap.Create<DictionaryVariable>();
×
65

NEW
66
                this._writer.Write(100, DxfSubclassMarker.DictionaryVariables);
×
67

NEW
68
                this._writer.Write(1, dictvar.Value, map);
×
NEW
69
                this._writer.Write(280, dictvar.ObjectSchemaNumber, map);
×
NEW
70
        }
×
71

72
        protected void writeGeoData(GeoData geodata)
73
        {
6✔
74
                DxfClassMap map = DxfClassMap.Create<GeoData>();
6✔
75

76
                this._writer.Write(100, DxfSubclassMarker.GeoData, map);
6✔
77

78
                switch (this.Version)
6✔
79
                {
80
                        case ACadVersion.Unknown:
81
                        case ACadVersion.MC0_0:
82
                        case ACadVersion.AC1_2:
83
                        case ACadVersion.AC1_4:
84
                        case ACadVersion.AC1_50:
85
                        case ACadVersion.AC2_10:
86
                        case ACadVersion.AC1002:
87
                        case ACadVersion.AC1003:
88
                        case ACadVersion.AC1004:
89
                        case ACadVersion.AC1006:
90
                        case ACadVersion.AC1009:
91
                        case ACadVersion.AC1012:
92
                        case ACadVersion.AC1014:
93
                        case ACadVersion.AC1015:
94
                        case ACadVersion.AC1018:
95
                        case ACadVersion.AC1021:
96
                                this._writer.Write(90, 1, map);
3✔
97
                                break;
3✔
98
                        case ACadVersion.AC1024:
99
                                this._writer.Write(90, 2, map);
1✔
100
                                break;
1✔
101
                        case ACadVersion.AC1027:
102
                        case ACadVersion.AC1032:
103
                                this._writer.Write(90, 3, map);
2✔
104
                                break;
2✔
105
                }
106

107
                if (geodata.HostBlock != null)
6✔
108
                {
6✔
109
                        this._writer.Write(330, geodata.HostBlock.Handle, map);
6✔
110
                }
6✔
111

112
                this._writer.Write(70, (short)geodata.CoordinatesType, map);
6✔
113

114
                if (this.Version <= ACadVersion.AC1021)
6✔
115
                {
3✔
116
                        this._writer.Write(40, geodata.ReferencePoint.Y, map);
3✔
117
                        this._writer.Write(41, geodata.ReferencePoint.X, map);
3✔
118
                        this._writer.Write(42, geodata.ReferencePoint.Z, map);
3✔
119
                        this._writer.Write(91, (int)geodata.HorizontalUnits, map);
3✔
120

121
                        this._writer.Write(10, geodata.DesignPoint, map);
3✔
122
                        this._writer.Write(11, XYZ.Zero, map);
3✔
123

124
                        this._writer.Write(210, geodata.UpDirection, map);
3✔
125

126
                        this._writer.Write(52, MathHelper.RadToDeg(System.Math.PI / 2.0 - geodata.NorthDirection.GetAngle()), map);
3✔
127

128
                        this._writer.Write(43, 1.0, map);
3✔
129
                        this._writer.Write(44, 1.0, map);
3✔
130
                        this._writer.Write(45, 1.0, map);
3✔
131

132
                        this._writer.Write(301, geodata.CoordinateSystemDefinition, map);
3✔
133
                        this._writer.Write(302, geodata.GeoRssTag, map);
3✔
134

135
                        this._writer.Write(46, geodata.UserSpecifiedScaleFactor, map);
3✔
136

137
                        this._writer.Write(303, string.Empty, map);
3✔
138
                        this._writer.Write(304, string.Empty, map);
3✔
139

140
                        this._writer.Write(305, geodata.ObservationFromTag, map);
3✔
141
                        this._writer.Write(306, geodata.ObservationToTag, map);
3✔
142
                        this._writer.Write(307, geodata.ObservationCoverageTag, map);
3✔
143

144
                        this._writer.Write(93, geodata.Points.Count, map);
3✔
145
                        foreach (var pt in geodata.Points)
9!
UNCOV
146
                        {
×
NEW
147
                                this._writer.Write(12, pt.Source, map);
×
NEW
148
                                this._writer.Write(13, pt.Destination, map);
×
UNCOV
149
                        }
×
150
                        this._writer.Write(96, geodata.Faces.Count, map);
3✔
151
                        foreach (var face in geodata.Faces)
9!
UNCOV
152
                        {
×
NEW
153
                                this._writer.Write(97, face.Index1, map);
×
NEW
154
                                this._writer.Write(98, face.Index2, map);
×
NEW
155
                                this._writer.Write(99, face.Index3, map);
×
UNCOV
156
                        }
×
157
                        this._writer.Write(3, "CIVIL3D_DATA_BEGIN", map);
3✔
158

159
                        this._writer.Write(292, false, map);
3✔
160
                        this._writer.Write(14, geodata.ReferencePoint.Convert<XY>(), map);
3✔
161
                        this._writer.Write(15, geodata.ReferencePoint.Convert<XY>(), map);
3✔
162
                        this._writer.Write(93, 0, map);
3✔
163
                        this._writer.Write(94, 0, map);
3✔
164
                        this._writer.Write(293, false, map);
3✔
165

166
                        this._writer.Write(16, XY.Zero, map);
3✔
167
                        this._writer.Write(17, XY.Zero, map);
3✔
168

169
                        this._writer.Write(54, MathHelper.RadToDeg(System.Math.PI / 2.0 - geodata.NorthDirection.GetAngle()), map);
3✔
170
                        this._writer.Write(140, System.Math.PI / 2.0 - geodata.NorthDirection.GetAngle(), map);
3✔
171

172
                        this._writer.Write(95, (int)geodata.ScaleEstimationMethod, map);
3✔
173
                        this._writer.Write(141, geodata.UserSpecifiedScaleFactor, map);
3✔
174
                        this._writer.Write(294, geodata.EnableSeaLevelCorrection, map);
3✔
175
                        this._writer.Write(142, geodata.SeaLevelElevation, map);
3✔
176
                        this._writer.Write(143, geodata.CoordinateProjectionRadius, map);
3✔
177

178
                        this._writer.Write(4, "CIVIL3D_DATA_END", map);
3✔
179
                }
3✔
180
                else
181
                {
3✔
182
                        this._writer.Write(10, geodata.DesignPoint, map);
3✔
183
                        this._writer.Write(11, geodata.ReferencePoint, map);
3✔
184
                        this._writer.Write(40, geodata.VerticalUnitScale, map);
3✔
185
                        this._writer.Write(91, (int)geodata.HorizontalUnits, map);
3✔
186
                        this._writer.Write(41, geodata.VerticalUnitScale, map);
3✔
187
                        this._writer.Write(92, (int)geodata.VerticalUnits, map);
3✔
188

189
                        this._writer.Write(210, geodata.UpDirection, map);
3✔
190

191
                        this._writer.Write(12, geodata.NorthDirection, map);
3✔
192

193
                        this._writer.Write(95, geodata.ScaleEstimationMethod, map);
3✔
194
                        this._writer.Write(141, geodata.UserSpecifiedScaleFactor, map);
3✔
195
                        this._writer.Write(294, geodata.EnableSeaLevelCorrection, map);
3✔
196
                        this._writer.Write(142, geodata.SeaLevelElevation, map);
3✔
197
                        this._writer.Write(143, geodata.CoordinateProjectionRadius, map);
3✔
198

199
                        this.writeLongTextValue(301, 303, geodata.CoordinateSystemDefinition);
3✔
200

201
                        this._writer.Write(302, geodata.GeoRssTag, map);
3✔
202
                        this._writer.Write(305, geodata.ObservationFromTag, map);
3✔
203
                        this._writer.Write(306, geodata.ObservationToTag, map);
3✔
204
                        this._writer.Write(307, geodata.ObservationCoverageTag, map);
3✔
205

206
                        this._writer.Write(93, geodata.Points.Count, map);
3✔
207
                        foreach (var pt in geodata.Points)
9!
UNCOV
208
                        {
×
NEW
209
                                this._writer.Write(13, pt.Source, map);
×
NEW
210
                                this._writer.Write(14, pt.Destination, map);
×
NEW
211
                        }
×
212

213
                        this._writer.Write(96, geodata.Faces.Count, map);
3✔
214

215
                        foreach (var face in geodata.Faces)
9!
NEW
216
                        {
×
NEW
217
                                this._writer.Write(97, face.Index1, map);
×
NEW
218
                                this._writer.Write(98, face.Index2, map);
×
NEW
219
                                this._writer.Write(99, face.Index3, map);
×
UNCOV
220
                        }
×
221
                }
3✔
222
        }
6✔
223

224
        protected void writeGroup(Group group)
225
        {
32✔
226
                this._writer.Write(100, DxfSubclassMarker.Group);
32✔
227

228
                this._writer.Write(300, group.Description);
32✔
229
                this._writer.Write(70, group.IsUnnamed ? (short)1 : (short)0);
32✔
230
                this._writer.Write(71, group.Selectable ? (short)1 : (short)0);
32!
231

232
                foreach (Entity entity in group.Entities)
432✔
233
                {
168✔
234
                        this._writer.WriteHandle(340, entity);
168✔
235
                }
168✔
236
        }
32✔
237

238
        protected void writeImageDefinition(ImageDefinition definition)
239
        {
13✔
240
                DxfClassMap map = DxfClassMap.Create<ImageDefinition>();
13✔
241

242
                this._writer.Write(100, DxfSubclassMarker.RasterImageDef);
13✔
243

244
                this._writer.Write(90, definition.ClassVersion, map);
13✔
245
                this._writer.Write(1, definition.FileName, map);
13✔
246

247
                this._writer.Write(10, definition.Size, map);
13✔
248

249
                this._writer.Write(280, definition.IsLoaded ? 1 : 0, map);
13!
250

251
                this._writer.Write(281, (byte)definition.Units, map);
13✔
252
        }
13✔
253

254
        protected void writeLayout(Layout layout)
255
        {
927✔
256
                DxfClassMap map = DxfClassMap.Create<Layout>();
927✔
257

258
                this.writePlotSettings(layout);
927✔
259

260
                this._writer.Write(100, DxfSubclassMarker.Layout);
927✔
261

262
                this._writer.Write(1, layout.Name, map);
927✔
263

264
                //this._writer.Write(70, (short) 1,map);
265
                this._writer.Write(71, layout.TabOrder, map);
927✔
266

267
                this._writer.Write(10, layout.MinLimits, map);
927✔
268
                this._writer.Write(11, layout.MaxLimits, map);
927✔
269
                this._writer.Write(12, layout.InsertionBasePoint, map);
927✔
270
                this._writer.Write(13, layout.Origin, map);
927✔
271
                this._writer.Write(14, layout.MinExtents, map);
927✔
272
                this._writer.Write(15, layout.MaxExtents, map);
927✔
273
                this._writer.Write(16, layout.XAxis, map);
927✔
274
                this._writer.Write(17, layout.YAxis, map);
927✔
275

276
                this._writer.Write(146, layout.Elevation, map);
927✔
277

278
                this._writer.Write(76, (short)0, map);
927✔
279

280
                this._writer.WriteHandle(330, layout.AssociatedBlock, map);
927✔
281
        }
927✔
282

283
        protected void writeMLineStyle(MLineStyle style)
NEW
284
        {
×
NEW
285
                DxfClassMap map = DxfClassMap.Create<MLineStyle>();
×
286

NEW
287
                this._writer.Write(100, DxfSubclassMarker.MLineStyle);
×
288

NEW
289
                this._writer.Write(2, style.Name, map);
×
290

NEW
291
                this._writer.Write(70, (short)style.Flags, map);
×
292

NEW
293
                this._writer.Write(3, style.Description, map);
×
294

NEW
295
                this._writer.Write(62, style.FillColor.GetApproxIndex(), map);
×
296

NEW
297
                this._writer.Write(51, style.StartAngle, map);
×
NEW
298
                this._writer.Write(52, style.EndAngle, map);
×
NEW
299
                this._writer.Write(71, (short)style.Elements.Count(), map);
×
NEW
300
                foreach (MLineStyle.Element element in style.Elements)
×
UNCOV
301
                {
×
NEW
302
                        this._writer.Write(49, element.Offset, map);
×
NEW
303
                        this._writer.Write(62, element.Color.Index, map);
×
NEW
304
                        this._writer.Write(6, element.LineType.Name, map);
×
UNCOV
305
                }
×
NEW
306
        }
×
307

308
        protected void writeMultiLeaderStyle(MultiLeaderStyle style)
NEW
309
        {
×
NEW
310
                DxfClassMap map = DxfClassMap.Create<MultiLeaderStyle>();
×
311

NEW
312
                this._writer.Write(100, DxfSubclassMarker.MLeaderStyle);
×
313

NEW
314
                this._writer.Write(179, 2);
×
315
                //        this._writer.Write(2, style.Name, map);
NEW
316
                this._writer.Write(170, (short)style.ContentType, map);
×
NEW
317
                this._writer.Write(171, (short)style.MultiLeaderDrawOrder, map);
×
NEW
318
                this._writer.Write(172, (short)style.LeaderDrawOrder, map);
×
NEW
319
                this._writer.Write(90, style.MaxLeaderSegmentsPoints, map);
×
NEW
320
                this._writer.Write(40, style.FirstSegmentAngleConstraint, map);
×
NEW
321
                this._writer.Write(41, style.SecondSegmentAngleConstraint, map);
×
NEW
322
                this._writer.Write(173, (short)style.PathType, map);
×
NEW
323
                this._writer.WriteCmColor(91, style.LineColor, map);
×
NEW
324
                this._writer.WriteHandle(340, style.LeaderLineType);
×
NEW
325
                this._writer.Write(92, (short)style.LeaderLineWeight, map);
×
NEW
326
                this._writer.Write(290, style.EnableLanding, map);
×
NEW
327
                this._writer.Write(42, style.LandingGap, map);
×
NEW
328
                this._writer.Write(291, style.EnableDogleg, map);
×
NEW
329
                this._writer.Write(43, style.LandingDistance, map);
×
NEW
330
                this._writer.Write(3, style.Description, map);
×
NEW
331
                this._writer.WriteHandle(341, style.Arrowhead);
×
NEW
332
                this._writer.Write(44, style.ArrowheadSize, map);
×
NEW
333
                this._writer.Write(300, style.DefaultTextContents, map);
×
NEW
334
                this._writer.WriteHandle(342, style.TextStyle);
×
NEW
335
                this._writer.Write(174, (short)style.TextLeftAttachment, map);
×
NEW
336
                this._writer.Write(178, (short)style.TextRightAttachment, map);
×
NEW
337
                this._writer.Write(175, style.TextAngle, map);
×
NEW
338
                this._writer.Write(176, (short)style.TextAlignment, map);
×
NEW
339
                this._writer.WriteCmColor(93, style.TextColor, map);
×
NEW
340
                this._writer.Write(45, style.TextHeight, map);
×
NEW
341
                this._writer.Write(292, style.TextFrame, map);
×
NEW
342
                this._writer.Write(297, style.TextAlignAlwaysLeft, map);
×
NEW
343
                this._writer.Write(46, style.AlignSpace, map);
×
NEW
344
                this._writer.WriteHandle(343, style.BlockContent);
×
NEW
345
                this._writer.WriteCmColor(94, style.BlockContentColor, map);
×
346

347
                //        Write 3 doubles since group codes do not conform vector group codes
NEW
348
                this._writer.Write(47, style.BlockContentScale.X, map);
×
NEW
349
                this._writer.Write(49, style.BlockContentScale.Y, map);
×
NEW
350
                this._writer.Write(140, style.BlockContentScale.Z, map);
×
351

NEW
352
                this._writer.Write(293, style.EnableBlockContentScale, map);
×
NEW
353
                this._writer.Write(141, style.BlockContentRotation, map);
×
NEW
354
                this._writer.Write(294, style.EnableBlockContentRotation, map);
×
NEW
355
                this._writer.Write(177, (short)style.BlockContentConnection, map);
×
NEW
356
                this._writer.Write(142, style.ScaleFactor, map);
×
NEW
357
                this._writer.Write(295, style.OverwritePropertyValue, map);
×
NEW
358
                this._writer.Write(296, style.IsAnnotative, map);
×
NEW
359
                this._writer.Write(143, style.BreakGapSize, map);
×
NEW
360
                this._writer.Write(271, (short)style.TextAttachmentDirection, map);
×
NEW
361
                this._writer.Write(272, (short)style.TextBottomAttachment, map);
×
NEW
362
                this._writer.Write(273, (short)style.TextTopAttachment, map);
×
NEW
363
                this._writer.Write(298, false); //        undocumented
×
NEW
364
        }
×
365

366
        protected void writeObject<T>(T co)
367
                where T : CadObject
368
        {
4,920✔
369
                if (!this.isObjectSupported(co))
4,920✔
370
                {
109✔
371
                        return;
109✔
372
                }
373

374
                if (co is XRecord && !this.Configuration.WriteXRecords)
4,811!
NEW
375
                {
×
NEW
376
                        return;
×
377
                }
378

379
                this._writer.Write(DxfCode.Start, co.ObjectName);
4,811✔
380

381
                this.writeCommonObjectData(co);
4,811✔
382

383
                switch (co)
4,811!
384
                {
385
                        case AcdbPlaceHolder acdbPlaceHolder:
NEW
386
                                this.writeAcdbPlaceHolder(acdbPlaceHolder);
×
NEW
387
                                return;
×
388
                        case BookColor bookColor:
389
                                this.writeBookColor(bookColor);
25✔
390
                                return;
25✔
391
                        case CadDictionary cadDictionary:
392
                                this.writeDictionary(cadDictionary);
3,012✔
393
                                return;
3,012✔
394
                        case DictionaryVariable dictvar:
NEW
395
                                this.writeDictionaryVariable(dictvar);
×
NEW
396
                                break;
×
397
                        case DimensionAssociation dimAssociation:
NEW
398
                                this.writeDimensionAssociation(dimAssociation);
×
NEW
399
                                break;
×
400
                        case GeoData geodata:
401
                                this.writeGeoData(geodata);
6✔
402
                                break;
6✔
403
                        case Group group:
404
                                this.writeGroup(group);
32✔
405
                                break;
32✔
406
                        case ImageDefinition imageDefinition:
407
                                this.writeImageDefinition(imageDefinition);
13✔
408
                                return;
13✔
409
                        case ImageDefinitionReactor reactor:
410
                                this.writeImageDefinitionReactor(reactor);
26✔
411
                                return;
26✔
412
                        case Layout layout:
413
                                this.writeLayout(layout);
927✔
414
                                break;
927✔
415
                        case Field field:
NEW
416
                                this.writeField(field);
×
NEW
417
                                break;
×
418
                        case FieldList fieldList:
NEW
419
                                this.writeFieldList(fieldList);
×
NEW
420
                                break;
×
421
                        case MLineStyle mlStyle:
NEW
422
                                this.writeMLineStyle(mlStyle);
×
NEW
423
                                break;
×
424
                        case MultiLeaderStyle multiLeaderlStyle:
NEW
425
                                this.writeMultiLeaderStyle(multiLeaderlStyle);
×
NEW
426
                                break;
×
427
                        case PlotSettings plotSettings:
NEW
428
                                this.writePlotSettings(plotSettings);
×
NEW
429
                                break;
×
430
                        case PdfUnderlayDefinition pdfUnderlayDefinition:
NEW
431
                                this.writePdfUnderlayDefinition(pdfUnderlayDefinition);
×
NEW
432
                                break;
×
433
                        case RasterVariables rasterVariables:
434
                                this.writeRasterVariables(rasterVariables);
13✔
435
                                break;
13✔
436
                        case Scale scale:
NEW
437
                                this.writeScale(scale);
×
NEW
438
                                break;
×
439
                        case SpatialFilter spatialFilter:
440
                                this.writeSpatialFilter(spatialFilter);
26✔
441
                                break;
26✔
442
                        case SortEntitiesTable sortensTable:
443
                                this.writeSortentsTable(sortensTable);
53✔
444
                                break;
53✔
445
                        case XRecord record:
446
                                this.writeXRecord(record);
678✔
447
                                break;
678✔
448
                        default:
NEW
449
                                throw new NotImplementedException($"Object not implemented : {co.GetType().FullName}");
×
450
                }
451

452
                this.writeExtendedData(co.ExtendedData);
1,735✔
453
        }
4,920✔
454

455
        protected void writePdfUnderlayDefinition(PdfUnderlayDefinition definition)
NEW
456
        {
×
NEW
457
                DxfClassMap map = DxfClassMap.Create<PlotSettings>();
×
458

NEW
459
                this._writer.Write(100, DxfSubclassMarker.UnderlayDefinition);
×
460

NEW
461
                this._writer.Write(1, definition.File, map);
×
NEW
462
                this._writer.Write(2, definition.Page, map);
×
NEW
463
        }
×
464

465
        protected void writePlotSettings(PlotSettings plot)
466
        {
927✔
467
                DxfClassMap map = DxfClassMap.Create<PlotSettings>();
927✔
468

469
                this._writer.Write(100, DxfSubclassMarker.PlotSettings);
927✔
470

471
                this._writer.Write(1, plot.PageName, map);
927✔
472
                this._writer.Write(2, plot.SystemPrinterName, map);
927✔
473

474
                this._writer.Write(4, plot.PaperSize, map);
927✔
475

476
                this._writer.Write(6, plot.PlotViewName, map);
927✔
477
                this._writer.Write(7, plot.StyleSheet, map);
927✔
478

479
                this._writer.Write(40, plot.UnprintableMargin.Left, map);
927✔
480
                this._writer.Write(41, plot.UnprintableMargin.Bottom, map);
927✔
481
                this._writer.Write(42, plot.UnprintableMargin.Right, map);
927✔
482
                this._writer.Write(43, plot.UnprintableMargin.Top, map);
927✔
483
                this._writer.Write(44, plot.PaperWidth, map);
927✔
484
                this._writer.Write(45, plot.PaperHeight, map);
927✔
485
                this._writer.Write(46, plot.PlotOriginX, map);
927✔
486
                this._writer.Write(47, plot.PlotOriginY, map);
927✔
487
                this._writer.Write(48, plot.WindowLowerLeftX, map);
927✔
488
                this._writer.Write(49, plot.WindowLowerLeftY, map);
927✔
489

490
                this._writer.Write(140, plot.WindowUpperLeftX, map);
927✔
491
                this._writer.Write(141, plot.WindowUpperLeftY, map);
927✔
492
                this._writer.Write(142, plot.NumeratorScale, map);
927✔
493
                this._writer.Write(143, plot.DenominatorScale, map);
927✔
494

495
                this._writer.Write(70, (short)plot.Flags, map);
927✔
496

497
                this._writer.Write(72, (short)plot.PaperUnits, map);
927✔
498
                this._writer.Write(73, (short)plot.PaperRotation, map);
927✔
499
                this._writer.Write(74, (short)plot.PlotType, map);
927✔
500
                this._writer.Write(75, plot.ScaledFit, map);
927✔
501
                this._writer.Write(76, (short)plot.ShadePlotMode, map);
927✔
502
                this._writer.Write(77, (short)plot.ShadePlotResolutionMode, map);
927✔
503
                this._writer.Write(78, plot.ShadePlotDPI, map);
927✔
504
                this._writer.Write(147, plot.PrintScale, map);
927✔
505

506
                this._writer.Write(148, plot.PaperImageOrigin.X, map);
927✔
507
                this._writer.Write(149, plot.PaperImageOrigin.Y, map);
927✔
508
        }
927✔
509

510
        protected void writeRasterVariables(RasterVariables variables)
511
        {
13✔
512
                DxfClassMap map = DxfClassMap.Create<RasterVariables>();
13✔
513

514
                this._writer.Write(100, DxfSubclassMarker.RasterVariables);
13✔
515

516
                this._writer.Write(90, variables.ClassVersion, map);
13✔
517
                this._writer.Write(70, variables.IsDisplayFrameShown ? 1 : 0, map);
13!
518
                this._writer.Write(71, (short)variables.DisplayQuality, map);
13✔
519
                this._writer.Write(72, (short)variables.DisplayQuality, map);
13✔
520
        }
13✔
521

522
        protected void writeScale(Scale scale)
NEW
523
        {
×
NEW
524
                this._writer.Write(100, DxfSubclassMarker.Scale);
×
525

NEW
526
                this._writer.Write(70, 0);
×
NEW
527
                this._writer.Write(300, scale.Name);
×
NEW
528
                this._writer.Write(140, scale.PaperUnits);
×
NEW
529
                this._writer.Write(141, scale.DrawingUnits);
×
NEW
530
                this._writer.Write(290, scale.IsUnitScale ? (short)1 : (short)0);
×
NEW
531
        }
×
532

533
        protected override void writeSection()
534
        {
447✔
535
                while (this.Holder.Objects.Any())
5,367✔
536
                {
4,920✔
537
                        CadObject item = this.Holder.Objects.Dequeue();
4,920✔
538

539
                        this.writeObject(item);
4,920✔
540
                }
4,920✔
541
        }
447✔
542

543
        protected void writeXRecord(XRecord record)
544
        {
678✔
545
                this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.XRecord);
678✔
546

547
                this._writer.Write(280, record.CloningFlags);
678✔
548

549
                foreach (var e in record.Entries)
17,382✔
550
                {
7,674✔
551
                        switch (e.GroupCode)
7,674✔
552
                        {
553
                                case GroupCodeValueType.None:
NEW
554
                                        break;
×
555
                                case GroupCodeValueType.Point3D:
556
                                        if (e.Value is IVector v)
256!
557
                                        {
256✔
558
                                                this._writer.Write(e.Code, v);
256✔
559
                                        }
256✔
560
                                        else
NEW
561
                                        {
×
NEW
562
                                                this._writer.Write(e.Code, e.Value);
×
NEW
563
                                        }
×
564
                                        break;
256✔
565
                                case GroupCodeValueType.Handle:
566
                                case GroupCodeValueType.ObjectId:
567
                                case GroupCodeValueType.ExtendedDataHandle:
568
                                        var obj = e.Value as IHandledCadObject;
604✔
569
                                        this._writer.Write(e.Code, obj.Handle);
604✔
570
                                        break;
604✔
571
                                default:
572
                                        this._writer.Write(e.Code, e.Value);
6,814✔
573
                                        break;
6,814✔
574
                        }
575
                }
7,674✔
576
        }
678✔
577

578
        private bool isObjectSupported(CadObject co)
579
        {
4,920✔
580
                switch (co)
4,920!
581
                {
582
                        case UnknownNonGraphicalObject:
NEW
583
                                return false;
×
584
                        case AecWallStyle:
585
                        case AecCleanupGroup:
586
                        case AecBinRecord:
587
                        case DimensionAssociation:
588
                        case EvaluationGraph:
589
                        case Material:
590
                        case MultiLeaderObjectContextData:
591
                        case VisualStyle:
592
                        case TableStyle:
593
                        case ProxyObject:
594
                        case BlockRepresentationData:
595
                        case MTextAttributeObjectContextData:
596
                        case BlockReferenceObjectContextData:
597
                                this.notify($"Object not implemented : {co.GetType().FullName}", NotificationType.NotImplemented);
109✔
598
                                return false;
109✔
599
                        default:
600
                                return true;
4,811✔
601
                }
602
        }
4,920✔
603

604
        private void writeAcdbPlaceHolder(AcdbPlaceHolder acdbPlaceHolder)
NEW
605
        {
×
NEW
606
        }
×
607

608
        private void writeDimensionAssociation(DimensionAssociation dimAssociation)
NEW
609
        {
×
NEW
610
                DxfClassMap map = DxfClassMap.Create<DimensionAssociation>();
×
611

NEW
612
                this._writer.Write(100, DxfSubclassMarker.DimensionAssociation);
×
613

NEW
614
                this._writer.WriteHandle(330, dimAssociation.Dimension, map);
×
NEW
615
                this._writer.Write(90, (int)dimAssociation.AssociativityFlags, map);
×
NEW
616
                this._writer.Write(70, dimAssociation.IsTransSpace, map);
×
NEW
617
                this._writer.Write(71, (short)dimAssociation.RotatedDimensionType, map);
×
618

NEW
619
                if (dimAssociation.AssociativityFlags.HasFlag(AssociativityFlags.FirstPointReference))
×
NEW
620
                {
×
NEW
621
                        this.writeOsnapPointRef(dimAssociation.FirstPointRef);
×
NEW
622
                }
×
623

NEW
624
                if (dimAssociation.AssociativityFlags.HasFlag(AssociativityFlags.SecondPointReference))
×
NEW
625
                {
×
NEW
626
                        this.writeOsnapPointRef(dimAssociation.SecondPointRef);
×
UNCOV
627
                }
×
628

NEW
629
                if (dimAssociation.AssociativityFlags.HasFlag(AssociativityFlags.ThirdPointReference))
×
630
                {
×
NEW
631
                        this.writeOsnapPointRef(dimAssociation.ThirdPointRef);
×
NEW
632
                }
×
633

NEW
634
                if (dimAssociation.AssociativityFlags.HasFlag(AssociativityFlags.FourthPointReference))
×
NEW
635
                {
×
NEW
636
                        this.writeOsnapPointRef(dimAssociation.FourthPointRef);
×
NEW
637
                }
×
NEW
638
        }
×
639

640
        private void writeField(Field field)
NEW
641
        {
×
NEW
642
                this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.Field);
×
643

NEW
644
                this._writer.Write(1, field.EvaluatorId);
×
645

NEW
646
                writeLongTextValue(2, 3, field.FieldCode);
×
647

NEW
648
                this._writer.Write(90, field.Children.Count);
×
NEW
649
                foreach (var item in field.Children)
×
NEW
650
                {
×
NEW
651
                        this._writer.WriteHandle(360, item);
×
NEW
652
                }
×
653

NEW
654
                this._writer.Write(97, field.CadObjects.Count);
×
NEW
655
                foreach (var item in field.CadObjects)
×
NEW
656
                {
×
NEW
657
                        this._writer.WriteHandle(331, item);
×
NEW
658
                }
×
659

NEW
660
                this._writer.Write(91, (int)field.EvaluationOptionFlags);
×
NEW
661
                this._writer.Write(92, (int)field.FilingOptionFlags);
×
NEW
662
                this._writer.Write(94, (int)field.FieldStateFlags);
×
NEW
663
                this._writer.Write(95, (int)field.EvaluationStatusFlags);
×
NEW
664
                this._writer.Write(96, field.EvaluationErrorCode);
×
NEW
665
                this._writer.Write(300, field.EvaluationErrorMessage);
×
666

NEW
667
                this._writer.Write(93, field.Values.Count);
×
NEW
668
                foreach (var item in field.Values)
×
NEW
669
                {
×
NEW
670
                        this._writer.Write(6, item.Key);
×
NEW
671
                        this.writeCadValue(item.Value);
×
UNCOV
672
                }
×
673

NEW
674
                this._writer.Write(7, "ACFD_FIELD_VALUE");
×
NEW
675
                this.writeCadValue(field.Value);
×
676

NEW
677
                this.writeLongTextValue(301, 9, field.FormatString);
×
NEW
678
                this._writer.Write(98, field.FormatString.Length);
×
NEW
679
        }
×
680

681
        private void writeFieldList(FieldList fieldList)
NEW
682
        {
×
NEW
683
                this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.IdSet);
×
684

NEW
685
                this._writer.Write(90, fieldList.Fields.Count);
×
NEW
686
                foreach (Field field in fieldList.Fields)
×
UNCOV
687
                {
×
NEW
688
                        this._writer.WriteHandle(330, field);
×
NEW
689
                        this.Holder.Objects.Enqueue(field);
×
UNCOV
690
                }
×
691

NEW
692
                this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.FieldList);
×
NEW
693
        }
×
694

695
        private void writeImageDefinitionReactor(ImageDefinitionReactor reactor)
696
        {
26✔
697
                this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.RasterImageDefReactor);
26✔
698

699
                this._writer.Write(90, reactor.ClassVersion);
26✔
700
                this._writer.WriteHandle(330, reactor.Image);
26✔
701
        }
26✔
702

703
        private void writeOsnapPointRef(DimensionAssociation.OsnapPointRef osnapPoint)
NEW
704
        {
×
NEW
705
                if (osnapPoint == null)
×
706
                {
×
NEW
707
                        return;
×
708
                }
709

NEW
710
                this._writer.Write(1, DimensionAssociation.OsnapPointRefClassName);
×
711

NEW
712
                this._writer.Write(72, (short)osnapPoint.ObjectOsnapType);
×
NEW
713
                this._writer.WriteHandle(331, osnapPoint.Geometry);
×
NEW
714
                this._writer.Write(73, (short)osnapPoint.SubentType);
×
NEW
715
                this._writer.Write(91, osnapPoint.GsMarker);
×
NEW
716
                this._writer.Write(40, osnapPoint.GeometryParameter);
×
717

NEW
718
                this._writer.Write(10, osnapPoint.OsnapPoint);
×
719

NEW
720
                this._writer.Write(75, (short)(osnapPoint.HasLastPointRef ? 1 : 0));
×
NEW
721
        }
×
722

723
        private void writeSortentsTable(SortEntitiesTable e)
724
        {
53✔
725
                this._writer.Write(DxfCode.Subclass, DxfSubclassMarker.SortentsTable);
53✔
726

727
                this._writer.WriteHandle(330, e.BlockOwner);
53✔
728

729
                foreach (SortEntitiesTable.Sorter item in e)
451✔
730
                {
146✔
731
                        this._writer.WriteHandle(331, item.Entity);
146✔
732
                        this._writer.Write(5, item.SortHandle);
146✔
733
                }
146✔
734
        }
53✔
735

736
        private void writeSpatialFilter(SpatialFilter filter)
737
        {
26✔
738
                DxfClassMap map = DxfClassMap.Create<SpatialFilter>();
26✔
739

740
                this._writer.Write(100, DxfSubclassMarker.Filter);
26✔
741
                this._writer.Write(100, DxfSubclassMarker.SpatialFilter);
26✔
742

743
                this._writer.Write(70, (short)filter.BoundaryPoints.Count, map);
26✔
744
                foreach (var pt in filter.BoundaryPoints)
182✔
745
                {
52✔
746
                        this._writer.Write(10, pt, map);
52✔
747
                }
52✔
748

749
                this._writer.Write(210, filter.Normal, map);
26✔
750
                this._writer.Write(11, filter.Origin, map);
26✔
751
                this._writer.Write(71, (short)(filter.DisplayBoundary ? 1 : 0), map);
26!
752

753
                this._writer.Write(72, filter.ClipFrontPlane ? 1 : 0, map);
26!
754
                if (filter.ClipFrontPlane)
26!
NEW
755
                {
×
NEW
756
                        this._writer.Write(40, filter.FrontDistance, map);
×
NEW
757
                }
×
758

759
                this._writer.Write(73, filter.ClipBackPlane ? 1 : 0, map);
26!
760
                if (filter.ClipBackPlane)
26!
NEW
761
                {
×
NEW
762
                        this._writer.Write(41, filter.BackDistance, map);
×
NEW
763
                }
×
764

765
                double[] array = new double[24]
26✔
766
                {
26✔
767
                        filter.InverseInsertTransform.M00, filter.InverseInsertTransform.M01, filter.InverseInsertTransform.M02, filter.InverseInsertTransform.M03,
26✔
768
                        filter.InverseInsertTransform.M10, filter.InverseInsertTransform.M11, filter.InverseInsertTransform.M12, filter.InverseInsertTransform.M13,
26✔
769
                        filter.InverseInsertTransform.M20, filter.InverseInsertTransform.M21, filter.InverseInsertTransform.M22, filter.InverseInsertTransform.M23,
26✔
770
                        filter.InsertTransform.M00, filter.InsertTransform.M01, filter.InsertTransform.M02, filter.InsertTransform.M03,
26✔
771
                        filter.InsertTransform.M10, filter.InsertTransform.M11, filter.InsertTransform.M12, filter.InsertTransform.M13,
26✔
772
                        filter.InsertTransform.M20, filter.InsertTransform.M21, filter.InsertTransform.M22, filter.InsertTransform.M23
26✔
773
                };
26✔
774

775
                for (int i = 0; i < array.Length; i++)
1,300✔
776
                {
624✔
777
                        this._writer.Write(40, array[i]);
624✔
778
                }
624✔
779
        }
26✔
780
}
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