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

DomCR / ACadSharp / 13887177011

16 Mar 2025 08:38PM UTC coverage: 76.243% (+0.02%) from 76.22%
13887177011

Pull #581

github

web-flow
Merge 2dd5efb75 into 5d7d96527
Pull Request #581: Implement Material

5504 of 7921 branches covered (69.49%)

Branch coverage included in aggregate %.

32 of 35 new or added lines in 4 files covered. (91.43%)

3 existing lines in 1 file now uncovered.

21694 of 27752 relevant lines covered (78.17%)

75560.62 hits per line

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

81.48
/src/ACadSharp/Objects/Material.cs
1
using ACadSharp.Attributes;
2
using CSUtilities.Extensions;
3

4
namespace ACadSharp.Objects
5
{
6
        public enum AmbientColorMethod
7
        {
8
                Current = 0,
9
                Override = 1,
10

11
        }
12

13
        /// <summary>
14
        /// Represents a <see cref="Material"/> object
15
        /// </summary>
16
        /// <remarks>
17
        /// Object name <see cref="DxfFileToken.ObjectMaterial"/> <br/>
18
        /// Dxf class name <see cref="DxfSubclassMarker.Material"/>
19
        /// </remarks>
20
        [DxfName(DxfFileToken.ObjectMaterial)]
21
        [DxfSubClass(DxfSubclassMarker.Material)]
22
        public class Material : NonGraphicalObject
23
        {
24
                /// <inheritdoc/>
25
                public override ObjectType ObjectType => ObjectType.UNLISTED;
×
26

27
                /// <inheritdoc/>
28
                public override string ObjectName => DxfFileToken.ObjectMaterial;
×
29

30
                /// <inheritdoc/>
31
                public override string SubclassMarker => DxfSubclassMarker.Material;
29,298✔
32

33
                /// <summary>
34
                /// Material name.
35
                /// </summary>
36
                [DxfCodeValue(1)]
37
                public override string Name
38
                {
39
                        get
40
                        {
1,164✔
41
                                return base.Name;
1,164✔
42
                        }
1,164✔
43
                        set
44
                        {
582✔
45
                                base.Name = value;
582✔
46
                        }
582✔
47
                }
48

49
                /// <summary>
50
                /// Material description.
51
                /// </summary>
52
                [DxfCodeValue(2)]
NEW
53
                public string Description { get; set; }
×
54

55
                /// <summary>
56
                /// Ambient color method.
57
                /// </summary>
58
                [DxfCodeValue(70)]
59
                public AmbientColorMethod AmbientColorMethod { get; set; } = AmbientColorMethod.Current;
583✔
60

61
                /// <summary>
62
                /// Ambient color factor.
63
                /// </summary>
64
                /// <value>
65
                /// valid range is 0.0 to 1.0)
66
                /// </value>
67
                [DxfCodeValue(40)]
68
                public double AmbientColorFactor
69
                {
NEW
70
                        get { return this._ambientColorFactor; }
×
71
                        set
72
                        {
1✔
73
                                ObjectExtensions.InRange(value, 0, 1, $"{nameof(AmbientColorFactor)} valid values are from 0.0 to 1.0");
1✔
74
                                this._ambientColorFactor = value;
1✔
75
                        }
1✔
76
                }
77

78
                private double _ambientColorFactor = 1.0;
583✔
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 method.
88
                /// </summary>
89
                [DxfCodeValue(71)]
90
                public AmbientColorMethod DiffuseColorMethod { get; set; } = AmbientColorMethod.Current;
583✔
91

92
                /// <summary>
93
                /// Diffuse color factor.
94
                /// </summary>
95
                /// <value>
96
                /// valid range is 0.0 to 1.0)
97
                /// </value>
98
                [DxfCodeValue(41)]
99
                public double DiffuseColorFactor
100
                {
NEW
101
                        get { return this._diffuseColorFactor; }
×
102
                        set
103
                        {
1✔
104
                                ObjectExtensions.InRange(value, 0, 1, $"{nameof(DiffuseColorFactor)} valid values are from 0.0 to 1.0");
1✔
105
                                this._diffuseColorFactor = value;
1✔
106
                        }
1✔
107
                }
108

109
                private double _diffuseColorFactor = 1.0;
583✔
110

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

117
                /// <summary>
118
                /// Diffuse map blend factor.
119
                /// </summary>
120
                [DxfCodeValue(42)]
121
                public double DiffuseMapBlendFactor { get; set; } = 1.0;
584✔
122

123
                //72
124

125
                //Diffuse map source(default = 1) :
126

127
                //0 = Use current scene
128

129
                //1 = Use image file(specified by file name; null file name specifies no map)
130

131
                //3
132

133
                //Diffuse map file name(string, default = null string)
134

135
                //73
136

137
                //Projection method of diffuse map mapper(default = 1):
138

139
                //1 = Planar
140

141
                //2 = Box
142

143
                //3 = Cylinder
144

145
                //4 = Sphere
146

147
                //74
148

149
                //Tiling method of diffuse map mapper(default = 1):
150

151
                //1 = Tile
152

153
                //2 = Crop
154

155
                //3 = Clamp
156

157
                //75
158

159
                //Auto transform method of diffuse map mapper(bitset, default = 1) :
160

161
                //1= No auto transform
162

163
                //2 = Scale mapper to current entity extents; translate mapper to entity origin
164

165
                //4 = Include current block transform in mapper transform
166

167
                //43
168

169
                //Transform matrix of diffuse map mapper(16 reals; row major format; default = identity matrix)
170

171
                //44
172

173
                //Specular gloss factor(real, default = 0.5)
174

175
                //76
176

177
                //Specular color method(default = 0) :
178

179
                //0 = Use current color
180

181
                //1 = Override current color
182

183
                //45
184

185
                //Specular color factor(real, default = 1.0; valid range is 0.0 to 1.0)
186

187
                //92
188

189
                //Specular color value(unsigned 32-bit integer representing an AcCmEntityColor)
190

191
                //46
192

193
                //Specular map blend factor(real; default = 1.0)
194

195
                //77
196

197
                //Specular map source(default = 1) :
198

199
                //0 = Use current scene
200

201
                //1 = Use image file(specified by file name; null file name specifies no map)
202

203
                //4
204

205
                //Specular map file name(string; default = null string)
206

207
                //78
208

209
                //Projection method of specular map mapper(default = 1):
210

211
                //1 = Planar
212

213
                //2 = Box
214

215
                //3 = Cylinder
216

217
                //4 = Sphere
218

219
                //79
220

221
                //Tiling method of specular map mapper(default = 1):
222

223
                //1 = Tile
224

225
                //2 = Crop
226

227
                //3 = Clamp
228

229
                //170
230

231
                //Auto transform method of specular map mapper(bitset; default = 1):
232

233
                //1 = No auto transform
234

235
                //2 = Scale mapper to current entity extents; translate mapper to entity origin
236

237
                //4 = Include current block transform in mapper transform
238

239
                //47
240

241
                //Transform matrix of specular map mapper(16 reals; row major format; default = identity matrix)
242

243
                //48
244

245
                //Blend factor of reflection map(real, default = 1.0)
246

247
                //171
248

249
                //Reflection map source(default = 1) :
250

251
                //0 = Use current scene
252

253
                //1 = Use image file(specified by file name; null file name specifies no map)
254

255
                //6
256

257
                //Reflection map file name(string; default = null string)
258

259
                //172
260

261
                //Projection method of reflection map mapper(default = 1):
262

263
                //1 = Planar
264

265
                //2 = Box
266

267
                //3 = Cylinder
268

269
                //4 = Sphere
270

271
                //173
272

273
                //Tiling method of reflection map mapper(default = 1):
274

275
                //1 = Tile
276

277
                //2 = Crop
278

279
                //3 = Clamp
280

281
                //174
282

283
                //Auto transform method of reflection map mapper(bitset; default = 1):
284

285
                //1 = No auto transform
286

287
                //2 = Scale mapper to current entity extents; translate mapper to entity origin
288

289
                //4 = Include current block transform in mapper transform
290

291
                //49
292

293
                //Transform matrix of reflection map mapper(16 reals; row major format; default = identity matrix)
294

295
                //140
296

297
                //Opacity percent(real; default = 1.0)
298

299
                //141
300

301
                //Blend factor of opacity map(real; default = 1.0)
302

303
                //175
304

305
                //Opacity map source(default = 1) :
306

307
                //0 = Use current scene
308

309
                //1 = Use image file(specified by file name; null file name specifies no map)
310

311
                //7
312

313
                //Opacity map file name(string; default = null string)
314

315
                //176
316

317
                //Projection method of opacity map mapper(default = 1):
318

319
                //1 = Planar
320

321
                //2 = Box
322

323
                //3 = Cylinder
324

325
                //4 = Sphere
326

327
                //177
328

329
                //Tiling method of opacity map mapper(default = 1):
330

331
                //1 = Tile
332

333
                //2 = Crop
334

335
                //3 = Clamp
336

337
                //178
338

339
                //Auto transform method of opacity map mapper(bitset; default = 1):
340

341
                //1 = No auto transform
342

343
                //2 = Scale mapper to current entity extents; translate mapper to entity origin
344

345
                //4 = Include current block transform in mapper transform
346

347
                //142
348

349
                //Transform matrix of opacity map mapper(16 reals; row major format; default = identity matrix)
350

351
                //143
352

353
                //Blend factor of bump map(real; default = 1.0)
354

355
                //179
356

357
                //Bump map source(default = 1) :
358

359
                //0 = Use current scene
360

361
                //1 = Use image file(specified by file name; null file name specifies no map)
362

363
                //8
364

365
                //Bump map file name(string; default = null string)
366

367
                //270
368

369
                //Projection method of bump map mapper(default = 1):
370

371
                //1 = Planar
372

373
                //2 = Box
374

375
                //3 = Cylinder
376

377
                //4 = Sphere
378

379
                //271
380

381
                //Tiling method of bump map mapper(default = 1):
382

383
                //1 = Tile
384

385
                //2 = Crop
386

387
                //3 = Clamp
388

389
                //272
390

391
                //Auto transform method of bump map mapper(bitset; default = 1):
392

393
                //1 = No auto transform
394

395
                //2 = Scale mapper to current entity extents; translate mapper to entity origin
396

397
                //4 = Include current block transform in mapper transform
398

399
                //144
400

401
                //Transform matrix of bump map mapper(16 reals; row major format; default = identity matrix)
402

403
                //145
404

405
                //Refraction index(real; default = 1.0)
406

407
                //146
408

409
                //Blend factor of refraction map(real; default = 1.0)
410

411
                //273
412

413
                //Refraction map source(default = 1) :
414

415
                //0 = Use current scene
416

417
                //1 = Use image file(specified by file name; null file name specifies no map)
418

419
                //9
420

421
                //Refraction map file name(string; default = null string)
422

423
                //274
424

425
                //Projection method of refraction map mapper(default = 1):
426

427
                //1 = Planar
428

429
                //2 = Box
430

431
                //3 = Cylinder
432

433
                //4 = Sphere
434

435
                //275
436

437
                //Tiling method of refraction map mapper(default = 1):
438

439
                //1 = Tile
440

441
                //2 = Crop
442

443
                //3 = Clamp
444

445
                //276
446

447
                //Auto transform method of refraction map mapper(bitset; default = 1):
448

449
                //1 = No auto transform
450

451
                //2 = Scale mapper to current entity extents; translate mapper to entity origin
452

453
                //4 = Include current block transform in mapper transform
454

455
                //147
456

457
                //Transform matrix of refraction map mapper(16 reals; row major format; default = identity matrix)
458

459
                //460
460

461
                //Color Bleed Scale
462
                //461        Indirect Dump Scale
463
                //462        Reflectance Scale
464
                //463
465

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

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

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

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