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

DomCR / ACadSharp / 12905761471

22 Jan 2025 10:03AM UTC coverage: 2.0% (-74.0%) from 75.963%
12905761471

push

github

DomCR
version 1.0.6

104 of 7676 branches covered (1.35%)

Branch coverage included in aggregate %.

590 of 27024 relevant lines covered (2.18%)

5.13 hits per line

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

0.0
/src/ACadSharp/IO/DXF/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[]
×
17
                {
×
18
                        "$ACADVER",
×
19
                        "$DWGCODEPAGE",
×
20
                        "$LASTSAVEDBY",
×
21
                        "$HANDSEED",
×
22
                        "$ANGBASE",
×
23
                        "$ANGDIR",
×
24
                        "$ATTMODE",
×
25
                        "$AUNITS",
×
26
                        "$AUPREC",
×
27
                        "$CECOLOR",
×
28
                        "$CELTSCALE",
×
29
                        "$CELTYPE",
×
30
                        "$CELWEIGHT",
×
31
                        "$CLAYER",
×
32
                        "$CMLJUST",
×
33
                        "$CMLSCALE",
×
34
                        "$CMLSTYLE",
×
35
                        "$DIMSTYLE",
×
36
                        "$TEXTSIZE",
×
37
                        "$TEXTSTYLE",
×
38
                        "$LUNITS",
×
39
                        "$LUPREC",
×
40
                        "$MIRRTEXT",
×
41
                        "$EXTNAMES",
×
42
                        "$INSBASE",
×
43
                        "$INSUNITS",
×
44
                        "$LTSCALE",
×
45
                        "$LWDISPLAY",
×
46
                        "$PDMODE",
×
47
                        "$PDSIZE",
×
48
                        "$PLINEGEN",
×
49
                        "$PSLTSCALE",
×
50
                        "$SPLINESEGS",
×
51
                        "$SURFU",
×
52
                        "$SURFV",
×
53
                        "$TDCREATE",
×
54
                        "$TDUCREATE",
×
55
                        "$TDUPDATE",
×
56
                        "$TDUUPDATE",
×
57
                        "$TDINDWG",
×
58
                };
×
59

60
                /// <summary>
61
                /// Flag to write all the header variables in the dxf file
62
                /// </summary>
63
                /// <remarks>
64
                /// 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
65
                /// </remarks>
66
                /// <value>
67
                /// false
68
                /// </value>
69
                public bool WriteAllHeaderVariables { get; set; } = false;
×
70

71
                /// <summary>
72
                /// Header variables to write in the dxf file
73
                /// </summary>
74
                public IEnumerable<string> HeaderVariables { get { return this._headerVariables.AsEnumerable(); } }
×
75

76
                private HashSet<string> _headerVariables;
77

78
                public DxfWriterConfiguration()
×
79
                {
×
80
                        this._headerVariables = new HashSet<string>(Variables);
×
81
                }
×
82

83
                /// <summary>
84
                /// Add a Header variable name to be added in the dxf document
85
                /// </summary>
86
                /// <remarks>
87
                /// The name of the variable must exist in <see cref="CadHeader.GetHeaderMap"/>
88
                /// </remarks>
89
                /// <param name="name"></param>
90
                /// <exception cref="ArgumentException"></exception>
91
                public void AddHeaderVariable(string name)
92
                {
×
93
                        Dictionary<string, CadSystemVariable> map = CadHeader.GetHeaderMap();
×
94

95
                        if (!map.ContainsKey(name))
×
96
                        {
×
97
                                throw new ArgumentException($"The variable {name} does not exist in the header", nameof(name));
×
98
                        }
99

100
                        this._headerVariables.Add(name);
×
101
                }
×
102

103
                /// <summary>
104
                /// Remove a Header variable name so is not added in the dxf document
105
                /// </summary>
106
                /// <remarks>
107
                /// The name cannot be a in the <see cref="Variables"/> list
108
                /// </remarks>
109
                /// <param name="name"></param>
110
                /// <returns></returns>
111
                /// <exception cref="ArgumentException"></exception>
112
                public bool RemoveHeaderVariable(string name)
113
                {
×
114
                        if (Variables.Select(v => v.ToLowerInvariant()).Contains(name.ToLowerInvariant()))
×
115
                        {
×
116
                                throw new ArgumentException($"The variable {name} cannot be removed from the set", nameof(name));
×
117
                        }
118

119
                        return this._headerVariables.Remove(name);
×
120
                }
×
121
        }
122
}
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