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

DomCR / ACadSharp / 19853971775

02 Dec 2025 09:38AM UTC coverage: 78.018% (+0.1%) from 77.904%
19853971775

Pull #581

github

web-flow
Merge 25a58cc52 into 63e4398e9
Pull Request #581: Implement Material

7579 of 10537 branches covered (71.93%)

Branch coverage included in aggregate %.

310 of 353 new or added lines in 9 files covered. (87.82%)

12 existing lines in 2 files now uncovered.

28123 of 35224 relevant lines covered (79.84%)

162437.17 hits per line

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

93.98
/src/ACadSharp/Objects/Material.cs
1
using ACadSharp.Attributes;
2
using CSMath;
3
using CSUtilities.Extensions;
4

5
namespace ACadSharp.Objects
6
{
7
        /// <summary>
8
        /// Represents a <see cref="Material"/> object
9
        /// </summary>
10
        /// <remarks>
11
        /// Object name <see cref="DxfFileToken.ObjectMaterial"/> <br/>
12
        /// Dxf class name <see cref="DxfSubclassMarker.Material"/>
13
        /// </remarks>
14
        [DxfName(DxfFileToken.ObjectMaterial)]
15
        [DxfSubClass(DxfSubclassMarker.Material)]
16
        public class Material : NonGraphicalObject
17
        {
18
                /// <summary>
19
                /// Ambient color value.
20
                /// </summary>
21
                [DxfCodeValue(90)]
22
                public Color AmbientColor { get; set; }
2,889✔
23

24
                /// <summary>
25
                /// Ambient color factor.
26
                /// </summary>
27
                /// <value>
28
                /// valid range is 0.0 to 1.0)
29
                /// </value>
30
                [DxfCodeValue(40)]
31
                public double AmbientColorFactor
32
                {
NEW
33
                        get { return this._ambientColorFactor; }
×
34
                        set
35
                        {
1,473✔
36
                                ObjectExtensions.InRange(value, 0, 1);
1,473✔
37
                                this._ambientColorFactor = value;
1,473✔
38
                        }
1,473✔
39
                }
40

41
                /// <summary>
42
                /// Ambient color method.
43
                /// </summary>
44
                [DxfCodeValue(70)]
45
                public ColorMethod AmbientColorMethod { get; set; } = ColorMethod.Current;
11,260✔
46

47
                /// <summary>
48
                /// Auto transform method of bump map mapper.
49
                /// </summary>
50
                [DxfCodeValue(272)]
51
                public AutoTransformMethodFlags BumpAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
7,964✔
52

53
                /// <summary>
54
                /// Bump map blend factor.
55
                /// </summary>
56
                /// <value>
57
                /// default = 1.0
58
                /// </value>
59
                [DxfCodeValue(143)]
60
                public double BumpMapBlendFactor { get; set; } = 1.0;
9,561✔
61

62
                /// <summary>
63
                /// Bump map file name.
64
                /// </summary>
65
                /// <remarks>
66
                /// null file name specifies no map.
67
                /// </remarks>
68
                [DxfCodeValue(8)]
69
                public string BumpMapFileName { get; set; }
2,346✔
70

71
                /// <summary>
72
                /// Bump map source.
73
                /// </summary>
74
                [DxfCodeValue(179)]
75
                public MapSource BumpMapSource { get; set; } = MapSource.UseImageFile;
9,892✔
76

77
                /// <summary>
78
                /// Transform matrix of bump map mapper.
79
                /// </summary>
80
                [DxfCodeValue(144)]
81
                public Matrix4 BumpMatrix { get; set; } = Matrix4.Identity;
9,334✔
82

83
                /// <summary>
84
                /// Bump method of specular map mapper.
85
                /// </summary>
86
                [DxfCodeValue(270)]
87
                public ProjectionMethod BumpProjectionMethod { get; set; } = ProjectionMethod.Planar;
7,964✔
88

89
                /// <summary>
90
                /// Tiling method of bump map mapper.
91
                /// </summary>
92
                [DxfCodeValue(271)]
93
                public TilingMethod BumpTilingMethod { get; set; } = TilingMethod.Tile;
7,964✔
94

95
                /// <summary>
96
                /// Channel Flags.
97
                /// </summary>
98
                [DxfCodeValue(94)]
99
                public int ChannelFlags { get; set; }
1,679✔
100

101
                /// <summary>
102
                /// Material description.
103
                /// </summary>
104
                [DxfCodeValue(2)]
105
                public string Description { get; set; }
3,296✔
106

107
                /// <summary>
108
                /// Auto transform method of diffuse map mapper.
109
                /// </summary>
110
                [DxfCodeValue(75)]
111
                public AutoTransformMethodFlags DiffuseAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
7,964✔
112

113
                /// <summary>
114
                /// Diffuse color value.
115
                /// </summary>
116
                [DxfCodeValue(91)]
117
                public Color DiffuseColor { get; set; }
1,065✔
118

119
                /// <summary>
120
                /// Diffuse color factor.
121
                /// </summary>
122
                /// <value>
123
                /// valid range is 0.0 to 1.0)
124
                /// </value>
125
                [DxfCodeValue(41)]
126
                public double DiffuseColorFactor
127
                {
NEW
128
                        get { return this._diffuseColorFactor; }
×
129
                        set
130
                        {
1,473✔
131
                                ObjectExtensions.InRange(value, 0, 1);
1,473✔
132
                                this._diffuseColorFactor = value;
1,473✔
133
                        }
1,473✔
134
                }
135

136
                /// <summary>
137
                /// Diffuse color method.
138
                /// </summary>
139
                [DxfCodeValue(71)]
140
                public ColorMethod DiffuseColorMethod { get; set; } = ColorMethod.Current;
11,260✔
141

142
                /// <summary>
143
                /// Diffuse map blend factor.
144
                /// </summary>
145
                [DxfCodeValue(42)]
146
                public double DiffuseMapBlendFactor { get; set; } = 1.0;
7,965✔
147

148
                /// <summary>
149
                /// Diffuse map file name.
150
                /// </summary>
151
                /// <remarks>
152
                /// null file name specifies no map.
153
                /// </remarks>
154
                [DxfCodeValue(3)]
155
                public string DiffuseMapFileName { get; set; }
2,707✔
156

157
                /// <summary>
158
                /// Diffuse map source.
159
                /// </summary>
160
                [DxfCodeValue(72)]
161
                public MapSource DiffuseMapSource { get; set; } = MapSource.UseImageFile;
9,664✔
162

163
                /// <summary>
164
                /// Transform matrix of diffuse map mapper.
165
                /// </summary>
166
                [DxfCodeValue(43)]
167
                public Matrix4 DiffuseMatrix { get; set; } = Matrix4.Identity;
9,562✔
168

169
                /// <summary>
170
                /// Projection method of diffuse map mapper.
171
                /// </summary>
172
                [DxfCodeValue(73)]
173
                public ProjectionMethod DiffuseProjectionMethod { get; set; } = ProjectionMethod.Planar;
7,964✔
174

175
                /// <summary>
176
                /// Tiling method of diffuse map mapper.
177
                /// </summary>
178
                [DxfCodeValue(74)]
179
                public TilingMethod DiffuseTilingMethod { get; set; } = TilingMethod.Tile;
7,964✔
180

181
                /// <summary>
182
                /// Material name.
183
                /// </summary>
184
                [DxfCodeValue(1)]
185
                public override string Name
186
                {
187
                        get
188
                        {
13,954✔
189
                                return base.Name;
13,954✔
190
                        }
13,954✔
191
                        set
192
                        {
6,491✔
193
                                base.Name = value;
6,491✔
194
                        }
6,491✔
195
                }
196

197
                /// <inheritdoc/>
198
                public override string ObjectName => DxfFileToken.ObjectMaterial;
73,778✔
199

200
                /// <inheritdoc/>
NEW
201
                public override ObjectType ObjectType => ObjectType.UNLISTED;
×
202

203
                /// <summary>
204
                /// Opacity percent.
205
                /// </summary>
206
                [DxfCodeValue(140)]
207
                public double Opacity { get; set; } = 1.0;
8,193✔
208

209
                /// <summary>
210
                /// Auto transform method of opacity map mapper.
211
                /// </summary>
212
                [DxfCodeValue(178)]
213
                public AutoTransformMethodFlags OpacityAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
7,964✔
214

215
                /// <summary>
216
                /// Opacity map blend factor.
217
                /// </summary>
218
                /// <value>
219
                /// default = 1.0
220
                /// </value>
221
                [DxfCodeValue(141)]
222
                public double OpacityMapBlendFactor { get; set; } = 1.0;
7,965✔
223

224
                /// <summary>
225
                /// Opacity map file name.
226
                /// </summary>
227
                /// <remarks>
228
                /// null file name specifies no map.
229
                /// </remarks>
230
                [DxfCodeValue(7)]
231
                public string OpacityMapFileName { get; set; }
408✔
232

233
                /// <summary>
234
                /// Opacity map source.
235
                /// </summary>
236
                [DxfCodeValue(175)]
237
                public MapSource OpacityMapSource { get; set; } = MapSource.UseImageFile;
11,260✔
238

239
                /// <summary>
240
                /// Transform matrix of opacity map mapper.
241
                /// </summary>
242
                [DxfCodeValue(142)]
243
                public Matrix4 OpacityMatrix { get; set; } = Matrix4.Identity;
8,194✔
244

245
                /// <summary>
246
                /// Opacity method of specular map mapper.
247
                /// </summary>
248
                [DxfCodeValue(176)]
249
                public ProjectionMethod OpacityProjectionMethod { get; set; } = ProjectionMethod.Planar;
7,964✔
250

251
                /// <summary>
252
                /// Tiling method of opacity map mapper.
253
                /// </summary>
254
                [DxfCodeValue(177)]
255
                public TilingMethod OpacityTilingMethod { get; set; } = TilingMethod.Tile;
7,964✔
256

257
                /// <summary>
258
                /// Auto transform method of reflection map mapper.
259
                /// </summary>
260
                [DxfCodeValue(174)]
261
                public AutoTransformMethodFlags ReflectionAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
7,964✔
262

263
                /// <summary>
264
                /// Blend factor of reflection map.
265
                /// </summary>
266
                [DxfCodeValue(48)]
267
                public double ReflectionMapBlendFactor { get; set; } = 1.0;
7,965✔
268

269
                /// <summary>
270
                /// Reflection map file name.
271
                /// </summary>
272
                /// <remarks>
273
                /// null file name specifies no map.
274
                /// </remarks>
275
                [DxfCodeValue(6)]
276
                public string ReflectionMapFileName { get; set; }
408✔
277

278
                /// <summary>
279
                /// Reflection map source.
280
                /// </summary>
281
                [DxfCodeValue(171)]
282
                public MapSource ReflectionMapSource { get; set; } = MapSource.UseImageFile;
11,260✔
283

284
                /// <summary>
285
                /// Transform matrix of reflection map mapper.
286
                /// </summary>
287
                [DxfCodeValue(49)]
288
                public Matrix4 ReflectionMatrix { get; set; } = Matrix4.Identity;
8,194✔
289

290
                /// <summary>
291
                /// Projection method of specular map mapper.
292
                /// </summary>
293
                [DxfCodeValue(172)]
294
                public ProjectionMethod ReflectionProjectionMethod { get; set; } = ProjectionMethod.Planar;
7,964✔
295

296
                /// <summary>
297
                /// Tiling method of reflection map mapper.
298
                /// </summary>
299
                [DxfCodeValue(173)]
300
                public TilingMethod ReflectionTilingMethod { get; set; } = TilingMethod.Tile;
7,964✔
301

302
                /// <summary>
303
                /// Auto transform method of refraction map mapper.
304
                /// </summary>
305
                [DxfCodeValue(276)]
306
                public AutoTransformMethodFlags RefractionAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
7,964✔
307

308
                /// <summary>
309
                /// Refraction index.
310
                /// </summary>
311
                [DxfCodeValue(145)]
312
                public double RefractionIndex { get; set; } = 1.0;
9,333✔
313

314
                /// <summary>
315
                /// Bump map refraction factor.
316
                /// </summary>
317
                /// <value>
318
                /// default = 1.0
319
                /// </value>
320
                [DxfCodeValue(146)]
321
                public double RefractionMapBlendFactor { get; set; } = 1.0;
7,965✔
322

323
                /// <summary>
324
                /// Refraction map file name.
325
                /// </summary>
326
                /// <remarks>
327
                /// null file name specifies no map.
328
                /// </remarks>
329
                [DxfCodeValue(9)]
NEW
330
                public string RefractionMapFileName { get; set; }
×
331

332
                /// <summary>
333
                /// Refraction map source.
334
                /// </summary>
335
                [DxfCodeValue(273)]
336
                public MapSource RefractionMapSource { get; set; } = MapSource.UseImageFile;
9,436✔
337

338
                /// <summary>
339
                /// Transform matrix of refraction map mapper.
340
                /// </summary>
341
                [DxfCodeValue(147)]
342
                public Matrix4 RefractionMatrix { get; set; } = Matrix4.Identity;
7,964✔
343

344
                /// <summary>
345
                /// Projection method of refraction map mapper.
346
                /// </summary>
347
                [DxfCodeValue(274)]
348
                public ProjectionMethod RefractionProjectionMethod { get; set; } = ProjectionMethod.Planar;
7,964✔
349

350
                /// <summary>
351
                /// Tiling method of refraction map mapper.
352
                /// </summary>
353
                [DxfCodeValue(275)]
354
                public TilingMethod RefractionTilingMethod { get; set; } = TilingMethod.Tile;
7,964✔
355

356
                /// <summary>
357
                /// Auto transform method of specular map mapper.
358
                /// </summary>
359
                [DxfCodeValue(170)]
360
                public AutoTransformMethodFlags SpecularAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
7,964✔
361

362
                /// <summary>
363
                /// Specular color.
364
                /// </summary>
365
                [DxfCodeValue(92)]
366
                public Color SpecularColor { get; set; }
1,065✔
367

368
                /// <summary>
369
                /// Specular color factor.
370
                /// </summary>
371
                /// <value>
372
                /// valid range is 0.0 to 1.0)
373
                /// </value>
374
                [DxfCodeValue(45)]
375
                public double SpecularColorFactor
376
                {
NEW
377
                        get { return this._specularColorFactor; }
×
378
                        set
379
                        {
1,473✔
380
                                ObjectExtensions.InRange(value, 0, 1);
1,473✔
381
                                this._specularColorFactor = value;
1,473✔
382
                        }
1,473✔
383
                }
384

385
                /// <summary>
386
                /// Specular color method.
387
                /// </summary>
388
                [DxfCodeValue(76)]
389
                public ColorMethod SpecularColorMethod { get; set; } = ColorMethod.Current;
11,260✔
390

391
                /// <summary>
392
                /// Specular gloss factor.
393
                /// </summary>
394
                /// <value>
395
                /// default = 0.5
396
                /// </value>
397
                [DxfCodeValue(44)]
398
                public double SpecularGlossFactor { get; set; } = 0.5;
9,789✔
399

400
                /// <summary>
401
                /// Specular map blend factor.
402
                /// </summary>
403
                /// <value>
404
                /// default = 1.0
405
                /// </value>
406
                [DxfCodeValue(46)]
407
                public double SpecularMapBlendFactor { get; set; } = 1.0;
7,965✔
408

409
                /// <summary>
410
                /// Specular map file name.
411
                /// </summary>
412
                /// <remarks>
413
                /// null file name specifies no map.
414
                /// </remarks>
415
                [DxfCodeValue(4)]
416
                public string SpecularMapFileName { get; set; }
408✔
417

418
                /// <summary>
419
                /// Specular map source.
420
                /// </summary>
421
                [DxfCodeValue(77)]
422
                public MapSource SpecularMapSource { get; set; } = MapSource.UseImageFile;
11,260✔
423

424
                /// <summary>
425
                /// Transform matrix of specular map mapper.
426
                /// </summary>
427
                [DxfCodeValue(47)]
428
                public Matrix4 SpecularMatrix { get; set; } = Matrix4.Identity;
7,964✔
429

430
                /// <summary>
431
                /// Projection method of specular map mapper.
432
                /// </summary>
433
                [DxfCodeValue(78)]
434
                public ProjectionMethod SpecularProjectionMethod { get; set; } = ProjectionMethod.Planar;
7,964✔
435

436
                /// <summary>
437
                /// Tiling method of specular map mapper.
438
                /// </summary>
439
                [DxfCodeValue(79)]
440
                public TilingMethod SpecularTilingMethod { get; set; } = TilingMethod.Tile;
7,964✔
441

442
                /// <inheritdoc/>
443
                public override string SubclassMarker => DxfSubclassMarker.Material;
47,696✔
444

445
                private double _ambientColorFactor = 1.0;
6,492✔
446

447
                private double _diffuseColorFactor = 1.0;
6,492✔
448

449
                private double _specularColorFactor = 1.0;
6,492✔
450

451
                /// <summary>
452
                /// Initializes a new instance of the <see cref="Material"/> class with the specified name.
453
                /// </summary>
454
                /// <param name="name">The name of the material. This value cannot be null or empty.</param>
455
                public Material(string name) : base(name) { }
7,515✔
456

457
                internal Material()
3,987✔
458
                { }
7,974✔
459

460
                //460
461
                //Color Bleed Scale
462

463
                //461        Indirect Dump Scale
464
                //462        Reflectance Scale
465
                //463
466

467
                //Transmittance Scale
468
                //290        Two-sided Material
469
                //464        Luminance
470
                //270        Luminance Mode
471
                //271
472

473
                //Normal Map Method
474
                //465        Normal Map Strength
475
                //42        Normal Map Blend Factor
476
                //72
477

478
                //Normal Map Source
479
                //3        Normal Map Source File Name
480
                //73        Normal Mapper Projection
481
                //74        Normal Mapper Tiling
482
                //75        Normal Mapper Auto Transform
483
                //43        Normal Mapper Transform
484
                //293        Materials Anonymous
485
                //272        Global Illumination Mode
486
                //273        Final Gather Mode
487
                //300
488

489
                //GenProcName
490
                //291        GenProcValBool
491
                //271        GenProcValInt
492
                //469        GenProcValReal
493
                //301        GenProcValText
494
                //292        GenProcTableEnd
495
                //62        GenProcValColorIndex
496
                //420        GenProcValColorRGB
497
                //430        GenProcValColorName
498
                //270        Map UTile
499
                //148        Translucence
500
                //90        Self-Illuminaton
501
                //468        Reflectivity
502
                //93        Illumination Model
503
        }
504
}
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