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

DomCR / ACadSharp / 13953837134

19 Mar 2025 06:18PM UTC coverage: 76.368% (+0.1%) from 76.22%
13953837134

Pull #581

github

web-flow
Merge a64d42aea into 791c7d93a
Pull Request #581: Implement Material

5530 of 7947 branches covered (69.59%)

Branch coverage included in aggregate %.

126 of 153 new or added lines in 4 files covered. (82.35%)

40 existing lines in 5 files now uncovered.

21822 of 27869 relevant lines covered (78.3%)

75238.77 hits per line

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

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

5
namespace ACadSharp.Objects
6
{
7
        public enum ColorMethod
8
        {
9
                Current = 0,
10
                Override = 1,
11
        }
12

13
        public enum MapSource
14
        {
15
                UseCurrentScene = 0,
16
                UseImageFile = 1,
17
        }
18

19
        public enum ProjectionMethod
20
        {
21
                None = 0,
22
                Planar = 1,
23
                Box = 2,
24
                Cylinder = 3,
25
                Sphere = 4
26
        }
27

28
        public enum TilingMethod
29
        {
30
                None = 0,
31
                Tile = 1,
32
                Crop = 2,
33
                Clamp = 3
34
        }
35

36
        [System.Flags]
37
        public enum AutoTransformMethodFlags
38
        {
39
                /// <summary>
40
                /// None.
41
                /// </summary>
42
                None = 0,
43
                /// <summary>
44
                /// No auto transform.
45
                /// </summary>
46
                NoAutoTransform = 1,
47
                /// <summary>
48
                /// Scale mapper to current entity extents; translate mapper to entity origin.
49
                /// </summary>
50
                ScaleMapper = 2,
51
                /// <summary>
52
                /// Include current block transform in mapper transform.
53
                /// </summary>
54
                IncludeCurrentBlock = 4
55
        }
56

57
        /// <summary>
58
        /// Represents a <see cref="Material"/> object
59
        /// </summary>
60
        /// <remarks>
61
        /// Object name <see cref="DxfFileToken.ObjectMaterial"/> <br/>
62
        /// Dxf class name <see cref="DxfSubclassMarker.Material"/>
63
        /// </remarks>
64
        [DxfName(DxfFileToken.ObjectMaterial)]
65
        [DxfSubClass(DxfSubclassMarker.Material)]
66
        public class Material : NonGraphicalObject
67
        {
68
                /// <inheritdoc/>
69
                public override ObjectType ObjectType => ObjectType.UNLISTED;
×
70

71
                /// <inheritdoc/>
72
                public override string ObjectName => DxfFileToken.ObjectMaterial;
×
73

74
                /// <inheritdoc/>
75
                public override string SubclassMarker => DxfSubclassMarker.Material;
4,076✔
76

77
                /// <summary>
78
                /// Material name.
79
                /// </summary>
80
                [DxfCodeValue(1)]
81
                public override string Name
82
                {
83
                        get
84
                        {
1,164✔
85
                                return base.Name;
1,164✔
86
                        }
1,164✔
87
                        set
88
                        {
987✔
89
                                base.Name = value;
987✔
90
                        }
987✔
91
                }
92

93
                /// <summary>
94
                /// Material description.
95
                /// </summary>
96
                [DxfCodeValue(2)]
97
                public string Description { get; set; }
405✔
98

99
                /// <summary>
100
                /// Ambient color method.
101
                /// </summary>
102
                [DxfCodeValue(70)]
103
                public ColorMethod AmbientColorMethod { get; set; } = ColorMethod.Current;
988✔
104

105
                /// <summary>
106
                /// Ambient color factor.
107
                /// </summary>
108
                /// <value>
109
                /// valid range is 0.0 to 1.0)
110
                /// </value>
111
                [DxfCodeValue(40)]
112
                public double AmbientColorFactor
113
                {
NEW
114
                        get { return this._ambientColorFactor; }
×
115
                        set
116
                        {
1✔
117
                                ObjectExtensions.InRange(value, 0, 1);
1✔
118
                                this._ambientColorFactor = value;
1✔
119
                        }
1✔
120
                }
121

122
                private double _ambientColorFactor = 1.0;
988✔
123

124
                /// <summary>
125
                /// Ambient color value.
126
                /// </summary>
127
                [DxfCodeValue(90)]
128
                public Color AmbientColor { get; set; }
1✔
129

130
                /// <summary>
131
                /// Ambient color method.
132
                /// </summary>
133
                [DxfCodeValue(71)]
134
                public ColorMethod DiffuseColorMethod { get; set; } = ColorMethod.Current;
988✔
135

136
                /// <summary>
137
                /// Diffuse color factor.
138
                /// </summary>
139
                /// <value>
140
                /// valid range is 0.0 to 1.0)
141
                /// </value>
142
                [DxfCodeValue(41)]
143
                public double DiffuseColorFactor
144
                {
NEW
145
                        get { return this._diffuseColorFactor; }
×
146
                        set
147
                        {
1✔
148
                                ObjectExtensions.InRange(value, 0, 1);
1✔
149
                                this._diffuseColorFactor = value;
1✔
150
                        }
1✔
151
                }
152

153
                private double _diffuseColorFactor = 1.0;
988✔
154

155
                /// <summary>
156
                /// Diffuse color value.
157
                /// </summary>
158
                [DxfCodeValue(91)]
159
                public Color DiffuseColor { get; set; }
1✔
160

161
                /// <summary>
162
                /// Diffuse map blend factor.
163
                /// </summary>
164
                [DxfCodeValue(42)]
165
                public double DiffuseMapBlendFactor { get; set; } = 1.0;
989✔
166

167
                /// <summary>
168
                /// Diffuse map source.
169
                /// </summary>
170
                [DxfCodeValue(72)]
171
                public MapSource DiffuseMapSource { get; set; } = MapSource.UseImageFile;
988✔
172

173
                /// <summary>
174
                /// Diffuse map file name.
175
                /// </summary>
176
                /// <remarks>
177
                /// null file name specifies no map.
178
                /// </remarks>
179
                [DxfCodeValue(3)]
NEW
180
                public string DiffuseMapFileName { get; set; }
×
181

182
                /// <summary>
183
                /// Projection method of diffuse map mapper.
184
                /// </summary>
185
                [DxfCodeValue(73)]
186
                public ProjectionMethod DiffuseProjectionMethod { get; set; } = ProjectionMethod.Planar;
988✔
187

188
                /// <summary>
189
                /// Tiling method of diffuse map mapper.
190
                /// </summary>
191
                [DxfCodeValue(74)]
192
                public TilingMethod DiffuseMapper { get; set; } = TilingMethod.Tile;
988✔
193

194
                /// <summary>
195
                /// Auto transform method of diffuse map mapper.
196
                /// </summary>
197
                [DxfCodeValue(75)]
198
                public AutoTransformMethodFlags DiffuseAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
988✔
199

200
                /// <summary>
201
                /// Transform matrix of diffuse map mapper.
202
                /// </summary>
203
                [DxfCodeValue(43)]
204
                public Matrix4 DiffuseMatrix { get; set; } = Matrix4.Identity;
1,182✔
205

206
                /// <summary>
207
                /// Specular gloss factor.
208
                /// </summary>
209
                /// <value>
210
                /// default = 0.5
211
                /// </value>
212
                [DxfCodeValue(44)]
213
                public double SpecularGlossFactor { get; set; } = 0.5;
989✔
214

215
                /// <summary>
216
                /// Specular color method.
217
                /// </summary>
218
                [DxfCodeValue(76)]
219
                public ColorMethod SpecularColorMethod { get; set; } = ColorMethod.Current;
988✔
220

221
                /// <summary>
222
                /// Specular color factor.
223
                /// </summary>
224
                /// <value>
225
                /// valid range is 0.0 to 1.0)
226
                /// </value>
227
                [DxfCodeValue(45)]
228
                public double SpecularColorFactor
229
                {
NEW
230
                        get { return this._specularColorFactor; }
×
231
                        set
232
                        {
1✔
233
                                ObjectExtensions.InRange(value, 0, 1);
1✔
234
                                this._specularColorFactor = value;
1✔
235
                        }
1✔
236
                }
237

238
                private double _specularColorFactor = 1.0;
988✔
239

240
                /// <summary>
241
                /// Specular color.
242
                /// </summary>
243
                [DxfCodeValue(92)]
244
                public Color SpecularColor { get; set; }
1✔
245

246
                /// <summary>
247
                /// Specular map blend factor.
248
                /// </summary>
249
                /// <value>
250
                /// default = 1.0
251
                /// </value>
252
                [DxfCodeValue(46)]
253
                public double SpecularMapBlendFactor { get; set; } = 1.0;
989✔
254

255
                /// <summary>
256
                /// Specular map source.
257
                /// </summary>
258
                [DxfCodeValue(77)]
259
                public MapSource SpecularMapSource { get; set; } = MapSource.UseImageFile;
988✔
260

261
                /// <summary>
262
                /// Specular map file name.
263
                /// </summary>
264
                /// <remarks>
265
                /// null file name specifies no map.
266
                /// </remarks>
267
                [DxfCodeValue(4)]
NEW
268
                public string SpecularMapFileName { get; set; }
×
269

270
                /// <summary>
271
                /// Projection method of specular map mapper.
272
                /// </summary>
273
                [DxfCodeValue(78)]
274
                public ProjectionMethod SpecularProjectionMethod { get; set; } = ProjectionMethod.Planar;
988✔
275

276
                /// <summary>
277
                /// Tiling method of specular map mapper.
278
                /// </summary>
279
                [DxfCodeValue(79)]
280
                public TilingMethod SpecularMapper { get; set; } = TilingMethod.Tile;
988✔
281

282
                /// <summary>
283
                /// Auto transform method of specular map mapper.
284
                /// </summary>
285
                [DxfCodeValue(170)]
286
                public AutoTransformMethodFlags SpecularAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
988✔
287

288
                /// <summary>
289
                /// Transform matrix of specular map mapper.
290
                /// </summary>
291
                [DxfCodeValue(47)]
292
                public Matrix4 SpecularMatrix { get; set; } = Matrix4.Identity;
988✔
293

294
                /// <summary>
295
                /// Blend factor of reflection map.
296
                /// </summary>
297
                [DxfCodeValue(48)]
298
                public double ReflectionMapBlendFactor { get; set; } = 1.0;
989✔
299

300
                /// <summary>
301
                /// Reflection map source.
302
                /// </summary>
303
                [DxfCodeValue(171)]
304
                public MapSource ReflectionMapSource { get; set; } = MapSource.UseImageFile;
988✔
305

306
                /// <summary>
307
                /// Reflection map file name.
308
                /// </summary>
309
                /// <remarks>
310
                /// null file name specifies no map.
311
                /// </remarks>
312
                [DxfCodeValue(6)]
NEW
313
                public string ReflectionMapFileName { get; set; }
×
314

315
                /// <summary>
316
                /// Projection method of specular map mapper.
317
                /// </summary>
318
                [DxfCodeValue(172)]
319
                public ProjectionMethod ReflectionProjectionMethod { get; set; } = ProjectionMethod.Planar;
988✔
320

321
                /// <summary>
322
                /// Tiling method of reflection map mapper.
323
                /// </summary>
324
                [DxfCodeValue(173)]
325
                public TilingMethod ReflectionMapper { get; set; } = TilingMethod.Tile;
988✔
326

327
                /// <summary>
328
                /// Auto transform method of reflection map mapper.
329
                /// </summary>
330
                [DxfCodeValue(174)]
331
                public AutoTransformMethodFlags ReflectionAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
988✔
332

333
                /// <summary>
334
                /// Transform matrix of reflection map mapper.
335
                /// </summary>
336
                [DxfCodeValue(49)]
337
                public Matrix4 ReflectionMatrix { get; set; } = Matrix4.Identity;
1,182✔
338

339
                /// <summary>
340
                /// Opacity percent.
341
                /// </summary>
342
                [DxfCodeValue(140)]
343
                public double Opacity { get; set; } = 1.0;
989✔
344

345
                /// <summary>
346
                /// Opacity map blend factor.
347
                /// </summary>
348
                /// <value>
349
                /// default = 1.0
350
                /// </value>
351
                [DxfCodeValue(141)]
352
                public double OpacityMapBlendFactor { get; set; } = 1.0;
989✔
353

354
                /// <summary>
355
                /// Opacity map source.
356
                /// </summary>
357
                [DxfCodeValue(175)]
358
                public MapSource OpacityMapSource { get; set; } = MapSource.UseImageFile;
988✔
359

360
                /// <summary>
361
                /// Opacity map file name.
362
                /// </summary>
363
                /// <remarks>
364
                /// null file name specifies no map.
365
                /// </remarks>
366
                [DxfCodeValue(7)]
NEW
367
                public string OpacityMapFileName { get; set; }
×
368

369
                /// <summary>
370
                /// Opacity method of specular map mapper.
371
                /// </summary>
372
                [DxfCodeValue(176)]
373
                public ProjectionMethod OpacityProjectionMethod { get; set; } = ProjectionMethod.Planar;
988✔
374

375
                /// <summary>
376
                /// Tiling method of opacity map mapper.
377
                /// </summary>
378
                [DxfCodeValue(177)]
379
                public TilingMethod OpacityMapper { get; set; } = TilingMethod.Tile;
988✔
380

381
                /// <summary>
382
                /// Auto transform method of opacity map mapper.
383
                /// </summary>
384
                [DxfCodeValue(178)]
385
                public AutoTransformMethodFlags OpacityAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
988✔
386

387
                /// <summary>
388
                /// Transform matrix of opacity map mapper.
389
                /// </summary>
390
                [DxfCodeValue(142)]
391
                public Matrix4 OpacityMatrix { get; set; } = Matrix4.Identity;
1,182✔
392

393
                /// <summary>
394
                /// Bump map blend factor.
395
                /// </summary>
396
                /// <value>
397
                /// default = 1.0
398
                /// </value>
399
                [DxfCodeValue(143)]
400
                public double BumpMapBlendFactor { get; set; } = 1.0;
989✔
401

402
                /// <summary>
403
                /// Bump map source.
404
                /// </summary>
405
                [DxfCodeValue(179)]
406
                public MapSource BumpMapSource { get; set; } = MapSource.UseImageFile;
988✔
407

408
                /// <summary>
409
                /// Bump map file name.
410
                /// </summary>
411
                /// <remarks>
412
                /// null file name specifies no map.
413
                /// </remarks>
414
                [DxfCodeValue(8)]
NEW
415
                public string BumpMapFileName { get; set; }
×
416

417
                /// <summary>
418
                /// Bump method of specular map mapper.
419
                /// </summary>
420
                [DxfCodeValue(270)]
421
                public ProjectionMethod BumpProjectionMethod { get; set; } = ProjectionMethod.Planar;
988✔
422

423
                /// <summary>
424
                /// Tiling method of bump map mapper.
425
                /// </summary>
426
                [DxfCodeValue(271)]
427
                public TilingMethod BumpMapper { get; set; } = TilingMethod.Tile;
988✔
428

429
                /// <summary>
430
                /// Auto transform method of bump map mapper.
431
                /// </summary>
432
                [DxfCodeValue(272)]
433
                public AutoTransformMethodFlags BumpAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
988✔
434

435
                /// <summary>
436
                /// Transform matrix of bump map mapper.
437
                /// </summary>
438
                [DxfCodeValue(144)]
439
                public Matrix4 BumpMatrix { get; set; } = Matrix4.Identity;
1,182✔
440

441
                /// <summary>
442
                /// Refraction index.
443
                /// </summary>
444
                [DxfCodeValue(145)]
445
                public double RefractionIndex { get; set; } = 1.0;
989✔
446

447
                /// <summary>
448
                /// Bump map refraction factor.
449
                /// </summary>
450
                /// <value>
451
                /// default = 1.0
452
                /// </value>
453
                [DxfCodeValue(146)]
454
                public double RefractionMapBlendFactor { get; set; } = 1.0;
989✔
455

456
                /// <summary>
457
                /// Refraction map source.
458
                /// </summary>
459
                [DxfCodeValue(273)]
460
                public MapSource RefractionMapSource { get; set; } = MapSource.UseImageFile;
988✔
461

462
                /// <summary>
463
                /// Refraction map file name.
464
                /// </summary>
465
                /// <remarks>
466
                /// null file name specifies no map.
467
                /// </remarks>
468
                [DxfCodeValue(9)]
NEW
469
                public string RefractionMapFileName { get; set; }
×
470

471
                /// <summary>
472
                /// Projection method of refraction map mapper.
473
                /// </summary>
474
                [DxfCodeValue(274)]
475
                public ProjectionMethod RefractionProjectionMethod { get; set; } = ProjectionMethod.Planar;
988✔
476

477
                /// <summary>
478
                /// Tiling method of refraction map mapper.
479
                /// </summary>
480
                [DxfCodeValue(275)]
481
                public TilingMethod RefractionMapper { get; set; } = TilingMethod.Tile;
988✔
482

483
                /// <summary>
484
                /// Auto transform method of refraction map mapper.
485
                /// </summary>
486
                [DxfCodeValue(276)]
487
                public AutoTransformMethodFlags RefractionAutoTransform { get; set; } = AutoTransformMethodFlags.NoAutoTransform;
988✔
488

489
                /// <summary>
490
                /// Transform matrix of refraction map mapper.
491
                /// </summary>
492
                [DxfCodeValue(147)]
493
                public Matrix4 RefractionMatrix { get; set; } = Matrix4.Identity;
988✔
494

495
                //460
496
                //Color Bleed Scale
497

498
                //461        Indirect Dump Scale
499
                //462        Reflectance Scale
500
                //463
501

502
                //Transmittance Scale
503
                //290        Two-sided Material
504
                //464        Luminance
505
                //270        Luminance Mode
506
                //271
507

508
                //Normal Map Method
509
                //465        Normal Map Strength
510
                //42        Normal Map Blend Factor
511
                //72
512

513
                //Normal Map Source
514
                //3        Normal Map Source File Name
515
                //73        Normal Mapper Projection
516
                //74        Normal Mapper Tiling
517
                //75        Normal Mapper Auto Transform
518
                //43        Normal Mapper Transform
519
                //293        Materials Anonymous
520
                //272        Global Illumination Mode
521
                //273        Final Gather Mode
522
                //300
523

524
                //GenProcName
525
                //291        GenProcValBool
526
                //271        GenProcValInt
527
                //469        GenProcValReal
528
                //301        GenProcValText
529
                //292        GenProcTableEnd
530
                //62        GenProcValColorIndex
531
                //420        GenProcValColorRGB
532
                //430        GenProcValColorName
533
                //270        Map UTile
534
                //148        Translucence
535
                //90        Self-Illuminaton
536
                //468        Reflectivity
537
                //93        Illumination Model
538

539
                /// <summary>
540
                /// Channel Flags.
541
                /// </summary>
542
                [DxfCodeValue(94)]
543
                public int ChannelFlags { get; set; }
391✔
544
        }
545
}
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