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

DomCR / ACadSharp / 19852695817

02 Dec 2025 08:53AM UTC coverage: 77.904%. Remained the same
19852695817

Pull #581

github

web-flow
Merge 5b605698d into 63e4398e9
Pull Request #581: Implement Material

7564 of 10537 branches covered (71.79%)

Branch coverage included in aggregate %.

283 of 346 new or added lines in 8 files covered. (81.79%)

18 existing lines in 3 files now uncovered.

28080 of 35217 relevant lines covered (79.73%)

96856.5 hits per line

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

93.75
/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; }
1✔
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
                        {
409✔
36
                                ObjectExtensions.InRange(value, 0, 1);
409✔
37
                                this._ambientColorFactor = value;
409✔
38
                        }
409✔
39
                }
40

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

47
                /// <summary>
48
                /// Auto transform method of bump map mapper.
49
                /// </summary>
50
                [DxfCodeValue(272)]
51
                public AutoTransformMethodFlags BumpAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
1,507✔
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;
1,508✔
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; }
408✔
70

71
                /// <summary>
72
                /// Tiling method of bump map mapper.
73
                /// </summary>
74
                [DxfCodeValue(271)]
75
                public TilingMethod BumpTilingMethod { get; set; } = TilingMethod.Tile;
1,507✔
76

77
                /// <summary>
78
                /// Bump map source.
79
                /// </summary>
80
                [DxfCodeValue(179)]
81
                public MapSource BumpMapSource { get; set; } = MapSource.UseImageFile;
1,915✔
82

83
                /// <summary>
84
                /// Transform matrix of bump map mapper.
85
                /// </summary>
86
                [DxfCodeValue(144)]
87
                public Matrix4 BumpMatrix { get; set; } = Matrix4.Identity;
1,737✔
88

89
                /// <summary>
90
                /// Bump method of specular map mapper.
91
                /// </summary>
92
                [DxfCodeValue(270)]
93
                public ProjectionMethod BumpProjectionMethod { get; set; } = ProjectionMethod.Planar;
1,507✔
94

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

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

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

113
                /// <summary>
114
                /// Diffuse color value.
115
                /// </summary>
116
                [DxfCodeValue(91)]
117
                public Color DiffuseColor { get; set; }
1✔
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
                        {
409✔
131
                                ObjectExtensions.InRange(value, 0, 1);
409✔
132
                                this._diffuseColorFactor = value;
409✔
133
                        }
409✔
134
                }
135

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

142
                /// <summary>
143
                /// Diffuse map blend factor.
144
                /// </summary>
145
                [DxfCodeValue(42)]
146
                public double DiffuseMapBlendFactor { get; set; } = 1.0;
1,508✔
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; }
408✔
156

157
                /// <summary>
158
                /// Tiling method of diffuse map mapper.
159
                /// </summary>
160
                [DxfCodeValue(74)]
161
                public TilingMethod DiffuseTilingMethod { get; set; } = TilingMethod.Tile;
1,507✔
162

163
                /// <summary>
164
                /// Diffuse map source.
165
                /// </summary>
166
                [DxfCodeValue(72)]
167
                public MapSource DiffuseMapSource { get; set; } = MapSource.UseImageFile;
1,915✔
168

169
                /// <summary>
170
                /// Transform matrix of diffuse map mapper.
171
                /// </summary>
172
                [DxfCodeValue(43)]
173
                public Matrix4 DiffuseMatrix { get; set; } = Matrix4.Identity;
1,737✔
174

175
                /// <summary>
176
                /// Projection method of diffuse map mapper.
177
                /// </summary>
178
                [DxfCodeValue(73)]
179
                public ProjectionMethod DiffuseProjectionMethod { get; set; } = ProjectionMethod.Planar;
1,507✔
180

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

197
                /// <inheritdoc/>
198
                public override string ObjectName => DxfFileToken.ObjectMaterial;
2,220✔
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;
1,508✔
208

209
                /// <summary>
210
                /// Auto transform method of opacity map mapper.
211
                /// </summary>
212
                [DxfCodeValue(178)]
213
                public AutoTransformMethodFlags OpacityAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
1,507✔
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;
1,508✔
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
                /// Tiling method of opacity map mapper.
235
                /// </summary>
236
                [DxfCodeValue(177)]
237
                public TilingMethod OpacityTilingMethod { get; set; } = TilingMethod.Tile;
1,507✔
238

239
                /// <summary>
240
                /// Opacity map source.
241
                /// </summary>
242
                [DxfCodeValue(175)]
243
                public MapSource OpacityMapSource { get; set; } = MapSource.UseImageFile;
1,915✔
244

245
                /// <summary>
246
                /// Transform matrix of opacity map mapper.
247
                /// </summary>
248
                [DxfCodeValue(142)]
249
                public Matrix4 OpacityMatrix { get; set; } = Matrix4.Identity;
1,737✔
250

251
                /// <summary>
252
                /// Opacity method of specular map mapper.
253
                /// </summary>
254
                [DxfCodeValue(176)]
255
                public ProjectionMethod OpacityProjectionMethod { get; set; } = ProjectionMethod.Planar;
1,507✔
256

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

263
                /// <summary>
264
                /// Blend factor of reflection map.
265
                /// </summary>
266
                [DxfCodeValue(48)]
267
                public double ReflectionMapBlendFactor { get; set; } = 1.0;
1,508✔
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
                /// Tiling method of reflection map mapper.
280
                /// </summary>
281
                [DxfCodeValue(173)]
282
                public TilingMethod ReflectionTilingMethod { get; set; } = TilingMethod.Tile;
1,507✔
283

284
                /// <summary>
285
                /// Reflection map source.
286
                /// </summary>
287
                [DxfCodeValue(171)]
288
                public MapSource ReflectionMapSource { get; set; } = MapSource.UseImageFile;
1,915✔
289

290
                /// <summary>
291
                /// Transform matrix of reflection map mapper.
292
                /// </summary>
293
                [DxfCodeValue(49)]
294
                public Matrix4 ReflectionMatrix { get; set; } = Matrix4.Identity;
1,737✔
295

296
                /// <summary>
297
                /// Projection method of specular map mapper.
298
                /// </summary>
299
                [DxfCodeValue(172)]
300
                public ProjectionMethod ReflectionProjectionMethod { get; set; } = ProjectionMethod.Planar;
1,507✔
301

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

308
                /// <summary>
309
                /// Refraction index.
310
                /// </summary>
311
                [DxfCodeValue(145)]
312
                public double RefractionIndex { get; set; } = 1.0;
1,508✔
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;
1,508✔
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
                /// Tiling method of refraction map mapper.
334
                /// </summary>
335
                [DxfCodeValue(275)]
336
                public TilingMethod RefractionTilingMethod { get; set; } = TilingMethod.Tile;
1,507✔
337

338
                /// <summary>
339
                /// Refraction map source.
340
                /// </summary>
341
                [DxfCodeValue(273)]
342
                public MapSource RefractionMapSource { get; set; } = MapSource.UseImageFile;
1,915✔
343

344
                /// <summary>
345
                /// Transform matrix of refraction map mapper.
346
                /// </summary>
347
                [DxfCodeValue(147)]
348
                public Matrix4 RefractionMatrix { get; set; } = Matrix4.Identity;
1,507✔
349

350
                /// <summary>
351
                /// Projection method of refraction map mapper.
352
                /// </summary>
353
                [DxfCodeValue(274)]
354
                public ProjectionMethod RefractionProjectionMethod { get; set; } = ProjectionMethod.Planar;
1,507✔
355

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

362
                /// <summary>
363
                /// Specular color.
364
                /// </summary>
365
                [DxfCodeValue(92)]
366
                public Color SpecularColor { get; set; }
1✔
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
                        {
409✔
380
                                ObjectExtensions.InRange(value, 0, 1);
409✔
381
                                this._specularColorFactor = value;
409✔
382
                        }
409✔
383
                }
384

385
                /// <summary>
386
                /// Specular color method.
387
                /// </summary>
388
                [DxfCodeValue(76)]
389
                public ColorMethod SpecularColorMethod { get; set; } = ColorMethod.Current;
1,915✔
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;
1,508✔
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;
1,508✔
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
                /// Tiling method of specular map mapper.
420
                /// </summary>
421
                [DxfCodeValue(79)]
422
                public TilingMethod SpecularTilingMethod { get; set; } = TilingMethod.Tile;
1,507✔
423

424
                /// <summary>
425
                /// Specular map source.
426
                /// </summary>
427
                [DxfCodeValue(77)]
428
                public MapSource SpecularMapSource { get; set; } = MapSource.UseImageFile;
1,915✔
429

430
                /// <summary>
431
                /// Transform matrix of specular map mapper.
432
                /// </summary>
433
                [DxfCodeValue(47)]
434
                public Matrix4 SpecularMatrix { get; set; } = Matrix4.Identity;
1,507✔
435

436
                /// <summary>
437
                /// Projection method of specular map mapper.
438
                /// </summary>
439
                [DxfCodeValue(78)]
440
                public ProjectionMethod SpecularProjectionMethod { get; set; } = ProjectionMethod.Planar;
1,507✔
441

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

445
                private double _ambientColorFactor = 1.0;
1,099✔
446

447
                private double _diffuseColorFactor = 1.0;
1,099✔
448

449
                private double _specularColorFactor = 1.0;
1,099✔
450

451
                //460
452
                //Color Bleed Scale
453

454
                //461        Indirect Dump Scale
455
                //462        Reflectance Scale
456
                //463
457

458
                //Transmittance Scale
459
                //290        Two-sided Material
460
                //464        Luminance
461
                //270        Luminance Mode
462
                //271
463

464
                //Normal Map Method
465
                //465        Normal Map Strength
466
                //42        Normal Map Blend Factor
467
                //72
468

469
                //Normal Map Source
470
                //3        Normal Map Source File Name
471
                //73        Normal Mapper Projection
472
                //74        Normal Mapper Tiling
473
                //75        Normal Mapper Auto Transform
474
                //43        Normal Mapper Transform
475
                //293        Materials Anonymous
476
                //272        Global Illumination Mode
477
                //273        Final Gather Mode
478
                //300
479

480
                //GenProcName
481
                //291        GenProcValBool
482
                //271        GenProcValInt
483
                //469        GenProcValReal
484
                //301        GenProcValText
485
                //292        GenProcTableEnd
486
                //62        GenProcValColorIndex
487
                //420        GenProcValColorRGB
488
                //430        GenProcValColorName
489
                //270        Map UTile
490
                //148        Translucence
491
                //90        Self-Illuminaton
492
                //468        Reflectivity
493
                //93        Illumination Model
494
        }
495
}
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