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

DomCR / ACadSharp / 19797132272

30 Nov 2025 09:48AM UTC coverage: 77.922% (+0.009%) from 77.913%
19797132272

Pull #581

github

web-flow
Merge 4b0333ce7 into 2b708502d
Pull Request #581: Implement Material

7540 of 10499 branches covered (71.82%)

Branch coverage included in aggregate %.

128 of 156 new or added lines in 4 files covered. (82.05%)

6 existing lines in 1 file now uncovered.

27980 of 35085 relevant lines covered (79.75%)

97169.91 hits per line

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

87.5
/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
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
32
        {
33
                Current = 0,
34

35
                Override = 1,
36
        }
37

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

42
                UseImageFile = 1,
43
        }
44

45
        public enum ProjectionMethod
46
        {
47
                None = 0,
48

49
                Planar = 1,
50

51
                Box = 2,
52

53
                Cylinder = 3,
54

55
                Sphere = 4
56
        }
57

58
        public enum TilingMethod
59
        {
60
                None = 0,
61

62
                Tile = 1,
63

64
                Crop = 2,
65

66
                Clamp = 3
67
        }
68

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

198
                /// <summary>
199
                /// Ambient color method.
200
                /// </summary>
201
                [DxfCodeValue(71)]
202
                public ColorMethod DiffuseColorMethod { get; set; } = ColorMethod.Current;
1,099✔
203

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

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

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

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

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

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

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

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

262
                /// <inheritdoc/>
NEW
263
                public override ObjectType ObjectType => ObjectType.UNLISTED;
×
264

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

507
                private double _ambientColorFactor = 1.0;
1,099✔
508

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

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

513
                //460
514
                //Color Bleed Scale
515

516
                //461        Indirect Dump Scale
517
                //462        Reflectance Scale
518
                //463
519

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

526
                //Normal Map Method
527
                //465        Normal Map Strength
528
                //42        Normal Map Blend Factor
529
                //72
530

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

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