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

DomCR / ACadSharp / 19830573451

01 Dec 2025 04:53PM UTC coverage: 77.934% (+0.03%) from 77.904%
19830573451

Pull #581

github

web-flow
Merge 5895abbc9 into 63e4398e9
Pull Request #581: Implement Material

7560 of 10525 branches covered (71.83%)

Branch coverage included in aggregate %.

255 of 313 new or added lines in 8 files covered. (81.47%)

12 existing lines in 2 files now uncovered.

28062 of 35183 relevant lines covered (79.76%)

96926.42 hits per line

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

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

5
namespace ACadSharp.Objects
6
{
7
        [System.Flags]
8
        public enum AutoTransformMethodFlags : byte
9
        {
10
                /// <summary>
11
                /// None.
12
                /// </summary>
13
                None = 0,
14

15
                /// <summary>
16
                /// No auto transform.
17
                /// </summary>
18
                NoAutoTransform = 1,
19

20
                /// <summary>
21
                /// Scale mapper to current entity extents; translate mapper to entity origin.
22
                /// </summary>
23
                ScaleMapper = 2,
24

25
                /// <summary>
26
                /// Include current block transform in mapper transform.
27
                /// </summary>
28
                IncludeCurrentBlock = 4
29
        }
30

31
        public enum ColorMethod : byte
32
        {
33
                Current = 0,
34

35
                Override = 1,
36
        }
37

38
        public enum MapSource : byte
39
        {
40
                UseCurrentScene = 0,
41

42
                UseImageFile = 1,
43

44
                Procedural = 2,
45
        }
46

47
        public enum ProjectionMethod : byte
48
        {
49
                None = 0,
50

51
                Planar = 1,
52

53
                Box = 2,
54

55
                Cylinder = 3,
56

57
                Sphere = 4
58
        }
59

60
        public enum TilingMethod : byte
61
        {
62
                None = 0,
63

64
                Tile = 1,
65

66
                Crop = 2,
67

68
                Clamp = 3
69
        }
70

71
        /// <summary>
72
        /// Represents a <see cref="Material"/> object
73
        /// </summary>
74
        /// <remarks>
75
        /// Object name <see cref="DxfFileToken.ObjectMaterial"/> <br/>
76
        /// Dxf class name <see cref="DxfSubclassMarker.Material"/>
77
        /// </remarks>
78
        [DxfName(DxfFileToken.ObjectMaterial)]
79
        [DxfSubClass(DxfSubclassMarker.Material)]
80
        public class Material : NonGraphicalObject
81
        {
82
                /// <summary>
83
                /// Ambient color value.
84
                /// </summary>
85
                [DxfCodeValue(90)]
86
                public Color AmbientColor { get; set; }
1✔
87

88
                /// <summary>
89
                /// Ambient color factor.
90
                /// </summary>
91
                /// <value>
92
                /// valid range is 0.0 to 1.0)
93
                /// </value>
94
                [DxfCodeValue(40)]
95
                public double AmbientColorFactor
96
                {
NEW
97
                        get { return this._ambientColorFactor; }
×
98
                        set
99
                        {
409✔
100
                                ObjectExtensions.InRange(value, 0, 1);
409✔
101
                                this._ambientColorFactor = value;
409✔
102
                        }
409✔
103
                }
104

105
                /// <summary>
106
                /// Ambient color method.
107
                /// </summary>
108
                [DxfCodeValue(70)]
109
                public ColorMethod AmbientColorMethod { get; set; } = ColorMethod.Current;
1,915✔
110

111
                /// <summary>
112
                /// Auto transform method of bump map mapper.
113
                /// </summary>
114
                [DxfCodeValue(272)]
115
                public AutoTransformMethodFlags BumpAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
1,099✔
116

117
                /// <summary>
118
                /// Bump map blend factor.
119
                /// </summary>
120
                /// <value>
121
                /// default = 1.0
122
                /// </value>
123
                [DxfCodeValue(143)]
124
                public double BumpMapBlendFactor { get; set; } = 1.0;
1,100✔
125

126
                /// <summary>
127
                /// Bump map file name.
128
                /// </summary>
129
                /// <remarks>
130
                /// null file name specifies no map.
131
                /// </remarks>
132
                [DxfCodeValue(8)]
NEW
133
                public string BumpMapFileName { get; set; }
×
134

135
                /// <summary>
136
                /// Tiling method of bump map mapper.
137
                /// </summary>
138
                [DxfCodeValue(271)]
139
                public TilingMethod BumpMapper { get; set; } = TilingMethod.Tile;
1,099✔
140

141
                /// <summary>
142
                /// Bump map source.
143
                /// </summary>
144
                [DxfCodeValue(179)]
145
                public MapSource BumpMapSource { get; set; } = MapSource.UseImageFile;
1,099✔
146

147
                /// <summary>
148
                /// Transform matrix of bump map mapper.
149
                /// </summary>
150
                [DxfCodeValue(144)]
151
                public Matrix4 BumpMatrix { get; set; } = Matrix4.Identity;
1,329✔
152

153
                /// <summary>
154
                /// Bump method of specular map mapper.
155
                /// </summary>
156
                [DxfCodeValue(270)]
157
                public ProjectionMethod BumpProjectionMethod { get; set; } = ProjectionMethod.Planar;
1,099✔
158

159
                /// <summary>
160
                /// Channel Flags.
161
                /// </summary>
162
                [DxfCodeValue(94)]
163
                public int ChannelFlags { get; set; }
463✔
164

165
                /// <summary>
166
                /// Material description.
167
                /// </summary>
168
                [DxfCodeValue(2)]
169
                public string Description { get; set; }
408✔
170

171
                /// <summary>
172
                /// Auto transform method of diffuse map mapper.
173
                /// </summary>
174
                [DxfCodeValue(75)]
175
                public AutoTransformMethodFlags DiffuseAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
1,507✔
176

177
                /// <summary>
178
                /// Diffuse color value.
179
                /// </summary>
180
                [DxfCodeValue(91)]
181
                public Color DiffuseColor { get; set; }
1✔
182

183
                /// <summary>
184
                /// Diffuse color factor.
185
                /// </summary>
186
                /// <value>
187
                /// valid range is 0.0 to 1.0)
188
                /// </value>
189
                [DxfCodeValue(41)]
190
                public double DiffuseColorFactor
191
                {
NEW
192
                        get { return this._diffuseColorFactor; }
×
193
                        set
194
                        {
409✔
195
                                ObjectExtensions.InRange(value, 0, 1);
409✔
196
                                this._diffuseColorFactor = value;
409✔
197
                        }
409✔
198
                }
199

200
                /// <summary>
201
                /// Diffuse color method.
202
                /// </summary>
203
                [DxfCodeValue(71)]
204
                public ColorMethod DiffuseColorMethod { get; set; } = ColorMethod.Current;
1,915✔
205

206
                /// <summary>
207
                /// Diffuse map blend factor.
208
                /// </summary>
209
                [DxfCodeValue(42)]
210
                public double DiffuseMapBlendFactor { get; set; } = 1.0;
1,508✔
211

212
                /// <summary>
213
                /// Diffuse map file name.
214
                /// </summary>
215
                /// <remarks>
216
                /// null file name specifies no map.
217
                /// </remarks>
218
                [DxfCodeValue(3)]
219
                public string DiffuseMapFileName { get; set; }
408✔
220

221
                /// <summary>
222
                /// Tiling method of diffuse map mapper.
223
                /// </summary>
224
                [DxfCodeValue(74)]
225
                public TilingMethod DiffuseTilingMethod { get; set; } = TilingMethod.Tile;
1,507✔
226

227
                /// <summary>
228
                /// Diffuse map source.
229
                /// </summary>
230
                [DxfCodeValue(72)]
231
                public MapSource DiffuseMapSource { get; set; } = MapSource.UseImageFile;
1,915✔
232

233
                /// <summary>
234
                /// Transform matrix of diffuse map mapper.
235
                /// </summary>
236
                [DxfCodeValue(43)]
237
                public Matrix4 DiffuseMatrix { get; set; } = Matrix4.Identity;
1,737✔
238

239
                /// <summary>
240
                /// Projection method of diffuse map mapper.
241
                /// </summary>
242
                [DxfCodeValue(73)]
243
                public ProjectionMethod DiffuseProjectionMethod { get; set; } = ProjectionMethod.Planar;
1,507✔
244

245
                /// <summary>
246
                /// Material name.
247
                /// </summary>
248
                [DxfCodeValue(1)]
249
                public override string Name
250
                {
251
                        get
252
                        {
2,196✔
253
                                return base.Name;
2,196✔
254
                        }
2,196✔
255
                        set
256
                        {
1,098✔
257
                                base.Name = value;
1,098✔
258
                        }
1,098✔
259
                }
260

261
                /// <inheritdoc/>
262
                public override string ObjectName => DxfFileToken.ObjectMaterial;
2,220✔
263

264
                /// <inheritdoc/>
NEW
265
                public override ObjectType ObjectType => ObjectType.UNLISTED;
×
266

267
                /// <summary>
268
                /// Opacity percent.
269
                /// </summary>
270
                [DxfCodeValue(140)]
271
                public double Opacity { get; set; } = 1.0;
1,508✔
272

273
                /// <summary>
274
                /// Auto transform method of opacity map mapper.
275
                /// </summary>
276
                [DxfCodeValue(178)]
277
                public AutoTransformMethodFlags OpacityAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
1,099✔
278

279
                /// <summary>
280
                /// Opacity map blend factor.
281
                /// </summary>
282
                /// <value>
283
                /// default = 1.0
284
                /// </value>
285
                [DxfCodeValue(141)]
286
                public double OpacityMapBlendFactor { get; set; } = 1.0;
1,100✔
287

288
                /// <summary>
289
                /// Opacity map file name.
290
                /// </summary>
291
                /// <remarks>
292
                /// null file name specifies no map.
293
                /// </remarks>
294
                [DxfCodeValue(7)]
NEW
295
                public string OpacityMapFileName { get; set; }
×
296

297
                /// <summary>
298
                /// Tiling method of opacity map mapper.
299
                /// </summary>
300
                [DxfCodeValue(177)]
301
                public TilingMethod OpacityMapper { get; set; } = TilingMethod.Tile;
1,099✔
302

303
                /// <summary>
304
                /// Opacity map source.
305
                /// </summary>
306
                [DxfCodeValue(175)]
307
                public MapSource OpacityMapSource { get; set; } = MapSource.UseImageFile;
1,099✔
308

309
                /// <summary>
310
                /// Transform matrix of opacity map mapper.
311
                /// </summary>
312
                [DxfCodeValue(142)]
313
                public Matrix4 OpacityMatrix { get; set; } = Matrix4.Identity;
1,329✔
314

315
                /// <summary>
316
                /// Opacity method of specular map mapper.
317
                /// </summary>
318
                [DxfCodeValue(176)]
319
                public ProjectionMethod OpacityProjectionMethod { get; set; } = ProjectionMethod.Planar;
1,099✔
320

321
                /// <summary>
322
                /// Auto transform method of reflection map mapper.
323
                /// </summary>
324
                [DxfCodeValue(174)]
325
                public AutoTransformMethodFlags ReflectionAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
1,507✔
326

327
                /// <summary>
328
                /// Blend factor of reflection map.
329
                /// </summary>
330
                [DxfCodeValue(48)]
331
                public double ReflectionMapBlendFactor { get; set; } = 1.0;
1,508✔
332

333
                /// <summary>
334
                /// Reflection map file name.
335
                /// </summary>
336
                /// <remarks>
337
                /// null file name specifies no map.
338
                /// </remarks>
339
                [DxfCodeValue(6)]
340
                public string ReflectionMapFileName { get; set; }
408✔
341

342
                /// <summary>
343
                /// Tiling method of reflection map mapper.
344
                /// </summary>
345
                [DxfCodeValue(173)]
346
                public TilingMethod ReflectionTilingMethod { get; set; } = TilingMethod.Tile;
1,507✔
347

348
                /// <summary>
349
                /// Reflection map source.
350
                /// </summary>
351
                [DxfCodeValue(171)]
352
                public MapSource ReflectionMapSource { get; set; } = MapSource.UseImageFile;
1,915✔
353

354
                /// <summary>
355
                /// Transform matrix of reflection map mapper.
356
                /// </summary>
357
                [DxfCodeValue(49)]
358
                public Matrix4 ReflectionMatrix { get; set; } = Matrix4.Identity;
1,737✔
359

360
                /// <summary>
361
                /// Projection method of specular map mapper.
362
                /// </summary>
363
                [DxfCodeValue(172)]
364
                public ProjectionMethod ReflectionProjectionMethod { get; set; } = ProjectionMethod.Planar;
1,507✔
365

366
                /// <summary>
367
                /// Auto transform method of refraction map mapper.
368
                /// </summary>
369
                [DxfCodeValue(276)]
370
                public AutoTransformMethodFlags RefractionAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
1,099✔
371

372
                /// <summary>
373
                /// Refraction index.
374
                /// </summary>
375
                [DxfCodeValue(145)]
376
                public double RefractionIndex { get; set; } = 1.0;
1,100✔
377

378
                /// <summary>
379
                /// Bump map refraction factor.
380
                /// </summary>
381
                /// <value>
382
                /// default = 1.0
383
                /// </value>
384
                [DxfCodeValue(146)]
385
                public double RefractionMapBlendFactor { get; set; } = 1.0;
1,100✔
386

387
                /// <summary>
388
                /// Refraction map file name.
389
                /// </summary>
390
                /// <remarks>
391
                /// null file name specifies no map.
392
                /// </remarks>
393
                [DxfCodeValue(9)]
NEW
394
                public string RefractionMapFileName { get; set; }
×
395

396
                /// <summary>
397
                /// Tiling method of refraction map mapper.
398
                /// </summary>
399
                [DxfCodeValue(275)]
400
                public TilingMethod RefractionMapper { get; set; } = TilingMethod.Tile;
1,099✔
401

402
                /// <summary>
403
                /// Refraction map source.
404
                /// </summary>
405
                [DxfCodeValue(273)]
406
                public MapSource RefractionMapSource { get; set; } = MapSource.UseImageFile;
1,099✔
407

408
                /// <summary>
409
                /// Transform matrix of refraction map mapper.
410
                /// </summary>
411
                [DxfCodeValue(147)]
412
                public Matrix4 RefractionMatrix { get; set; } = Matrix4.Identity;
1,099✔
413

414
                /// <summary>
415
                /// Projection method of refraction map mapper.
416
                /// </summary>
417
                [DxfCodeValue(274)]
418
                public ProjectionMethod RefractionProjectionMethod { get; set; } = ProjectionMethod.Planar;
1,099✔
419

420
                /// <summary>
421
                /// Auto transform method of specular map mapper.
422
                /// </summary>
423
                [DxfCodeValue(170)]
424
                public AutoTransformMethodFlags SpecularAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
1,507✔
425

426
                /// <summary>
427
                /// Specular color.
428
                /// </summary>
429
                [DxfCodeValue(92)]
430
                public Color SpecularColor { get; set; }
1✔
431

432
                /// <summary>
433
                /// Specular color factor.
434
                /// </summary>
435
                /// <value>
436
                /// valid range is 0.0 to 1.0)
437
                /// </value>
438
                [DxfCodeValue(45)]
439
                public double SpecularColorFactor
440
                {
NEW
441
                        get { return this._specularColorFactor; }
×
442
                        set
443
                        {
409✔
444
                                ObjectExtensions.InRange(value, 0, 1);
409✔
445
                                this._specularColorFactor = value;
409✔
446
                        }
409✔
447
                }
448

449
                /// <summary>
450
                /// Specular color method.
451
                /// </summary>
452
                [DxfCodeValue(76)]
453
                public ColorMethod SpecularColorMethod { get; set; } = ColorMethod.Current;
1,915✔
454

455
                /// <summary>
456
                /// Specular gloss factor.
457
                /// </summary>
458
                /// <value>
459
                /// default = 0.5
460
                /// </value>
461
                [DxfCodeValue(44)]
462
                public double SpecularGlossFactor { get; set; } = 0.5;
1,508✔
463

464
                /// <summary>
465
                /// Specular map blend factor.
466
                /// </summary>
467
                /// <value>
468
                /// default = 1.0
469
                /// </value>
470
                [DxfCodeValue(46)]
471
                public double SpecularMapBlendFactor { get; set; } = 1.0;
1,508✔
472

473
                /// <summary>
474
                /// Specular map file name.
475
                /// </summary>
476
                /// <remarks>
477
                /// null file name specifies no map.
478
                /// </remarks>
479
                [DxfCodeValue(4)]
480
                public string SpecularMapFileName { get; set; }
408✔
481

482
                /// <summary>
483
                /// Tiling method of specular map mapper.
484
                /// </summary>
485
                [DxfCodeValue(79)]
486
                public TilingMethod SpecularTilingMethod { get; set; } = TilingMethod.Tile;
1,507✔
487

488
                /// <summary>
489
                /// Specular map source.
490
                /// </summary>
491
                [DxfCodeValue(77)]
492
                public MapSource SpecularMapSource { get; set; } = MapSource.UseImageFile;
1,915✔
493

494
                /// <summary>
495
                /// Transform matrix of specular map mapper.
496
                /// </summary>
497
                [DxfCodeValue(47)]
498
                public Matrix4 SpecularMatrix { get; set; } = Matrix4.Identity;
1,507✔
499

500
                /// <summary>
501
                /// Projection method of specular map mapper.
502
                /// </summary>
503
                [DxfCodeValue(78)]
504
                public ProjectionMethod SpecularProjectionMethod { get; set; } = ProjectionMethod.Planar;
1,507✔
505

506
                /// <inheritdoc/>
507
                public override string SubclassMarker => DxfSubclassMarker.Material;
4,832✔
508

509
                private double _ambientColorFactor = 1.0;
1,099✔
510

511
                private double _diffuseColorFactor = 1.0;
1,099✔
512

513
                private double _specularColorFactor = 1.0;
1,099✔
514

515
                //460
516
                //Color Bleed Scale
517

518
                //461        Indirect Dump Scale
519
                //462        Reflectance Scale
520
                //463
521

522
                //Transmittance Scale
523
                //290        Two-sided Material
524
                //464        Luminance
525
                //270        Luminance Mode
526
                //271
527

528
                //Normal Map Method
529
                //465        Normal Map Strength
530
                //42        Normal Map Blend Factor
531
                //72
532

533
                //Normal Map Source
534
                //3        Normal Map Source File Name
535
                //73        Normal Mapper Projection
536
                //74        Normal Mapper Tiling
537
                //75        Normal Mapper Auto Transform
538
                //43        Normal Mapper Transform
539
                //293        Materials Anonymous
540
                //272        Global Illumination Mode
541
                //273        Final Gather Mode
542
                //300
543

544
                //GenProcName
545
                //291        GenProcValBool
546
                //271        GenProcValInt
547
                //469        GenProcValReal
548
                //301        GenProcValText
549
                //292        GenProcTableEnd
550
                //62        GenProcValColorIndex
551
                //420        GenProcValColorRGB
552
                //430        GenProcValColorName
553
                //270        Map UTile
554
                //148        Translucence
555
                //90        Self-Illuminaton
556
                //468        Reflectivity
557
                //93        Illumination Model
558
        }
559
}
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