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

DomCR / ACadSharp / 25971283199

16 May 2026 07:49PM UTC coverage: 76.777% (+0.03%) from 76.744%
25971283199

push

github

DomCR
#PR1073 v3.6.11

8600 of 12137 branches covered (70.86%)

Branch coverage included in aggregate %.

30839 of 39231 relevant lines covered (78.61%)

157749.57 hits per line

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

75.0
/src/ACadSharp/IO/DxfWriterConfiguration.cs
1
using ACadSharp.Header;
2
using System;
3
using System.Collections.Generic;
4
using System.Linq;
5

6
namespace ACadSharp.IO
7
{
8
        /// <summary>
9
        /// Configuration for writing DWG files.
10
        /// </summary>
11
        public class DxfWriterConfiguration : CadWriterConfiguration
12
        {
13
                /// <summary>
14
                /// Variables that must be writen in a dxf file
15
                /// </summary>
16
                public static readonly string[] Variables = new string[]
1✔
17
                {
1✔
18
                        "$ACADVER",
1✔
19
                        "$DWGCODEPAGE",
1✔
20
                        "$LASTSAVEDBY",
1✔
21
                        "$HANDSEED",
1✔
22
                        "$ANGBASE",
1✔
23
                        "$ANGDIR",
1✔
24
                        "$ATTMODE",
1✔
25
                        "$AUNITS",
1✔
26
                        "$AUPREC",
1✔
27
                        "$CECOLOR",
1✔
28
                        "$CELTSCALE",
1✔
29
                        "$CELTYPE",
1✔
30
                        "$CELWEIGHT",
1✔
31
                        "$CLAYER",
1✔
32
                        "$CMLJUST",
1✔
33
                        "$CMLSCALE",
1✔
34
                        "$CMLSTYLE",
1✔
35
                        "$DIMSTYLE",
1✔
36
                        "$TEXTSIZE",
1✔
37
                        "$TEXTSTYLE",
1✔
38
                        "$LUNITS",
1✔
39
                        "$LUPREC",
1✔
40
                        "$MIRRTEXT",
1✔
41
                        "$EXTNAMES",
1✔
42
                        "$INSBASE",
1✔
43
                        "$INSUNITS",
1✔
44
                        "$MEASUREMENT",
1✔
45
                        "$LTSCALE",
1✔
46
                        "$LWDISPLAY",
1✔
47
                        "$PDMODE",
1✔
48
                        "$PDSIZE",
1✔
49
                        "$PLINEGEN",
1✔
50
                        "$PSLTSCALE",
1✔
51
                        "$SPLINESEGS",
1✔
52
                        "$SURFU",
1✔
53
                        "$SURFV",
1✔
54
                        "$TDCREATE",
1✔
55
                        "$TDUCREATE",
1✔
56
                        "$TDUPDATE",
1✔
57
                        "$TDUUPDATE",
1✔
58
                        "$TDINDWG",
1✔
59
                };
1✔
60

61
                /// <summary>
62
                /// Flag to write all the header variables in the dxf file
63
                /// </summary>
64
                /// <remarks>
65
                /// Some variables are version sensitive, writing all the variables may cause a crash in other applications, to write an specific variable add it to the <see cref="AddHeaderVariable"/> set
66
                /// </remarks>
67
                /// <value>
68
                /// false
69
                /// </value>
70
                public bool WriteAllHeaderVariables { get; set; } = false;
114,750✔
71

72
                /// <summary>
73
                /// Write the Dxf optional values.
74
                /// </summary>
75
                /// <remarks>
76
                /// The values are marked with the attribute flag <see cref="DxfReferenceType.Optional"/>.
77
                /// </remarks>
78
                /// <value>
79
                /// default: true
80
                /// </value>
81
                public bool WriteOptionalValues { get; set; } = true;
918✔
82

83
                /// <summary>
84
                /// Header variables to write in the dxf file
85
                /// </summary>
86
                public IEnumerable<string> HeaderVariables { get { return this._headerVariables.AsEnumerable(); } }
342,873✔
87

88
                private HashSet<string> _headerVariables;
89

90
                public DxfWriterConfiguration()
459✔
91
                {
459✔
92
                        this._headerVariables = new HashSet<string>(Variables);
459✔
93
                }
459✔
94

95
                /// <summary>
96
                /// Add a Header variable name to be added in the dxf document
97
                /// </summary>
98
                /// <remarks>
99
                /// The name of the variable must exist in <see cref="CadHeader.GetHeaderMap"/>
100
                /// </remarks>
101
                /// <param name="name"></param>
102
                /// <exception cref="ArgumentException"></exception>
103
                public void AddHeaderVariable(string name)
104
                {
×
105
                        Dictionary<string, CadSystemVariable> map = CadHeader.GetHeaderMap();
×
106

107
                        if (!map.ContainsKey(name))
×
108
                        {
×
109
                                throw new ArgumentException($"The variable {name} does not exist in the header", nameof(name));
×
110
                        }
111

112
                        this._headerVariables.Add(name);
×
113
                }
×
114

115
                /// <summary>
116
                /// Remove a Header variable name so is not added in the dxf document
117
                /// </summary>
118
                /// <remarks>
119
                /// The name cannot be a in the <see cref="Variables"/> list
120
                /// </remarks>
121
                /// <param name="name"></param>
122
                /// <returns></returns>
123
                /// <exception cref="ArgumentException"></exception>
124
                public bool RemoveHeaderVariable(string name)
125
                {
×
126
                        if (Variables.Select(v => v.ToLowerInvariant()).Contains(name.ToLowerInvariant()))
×
127
                        {
×
128
                                throw new ArgumentException($"The variable {name} cannot be removed from the set", nameof(name));
×
129
                        }
130

131
                        return this._headerVariables.Remove(name);
×
132
                }
×
133
        }
134
}
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