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

DomCR / ACadSharp / 12347592457

16 Dec 2024 07:04AM UTC coverage: 75.599% (+0.2%) from 75.438%
12347592457

Pull #486

github

web-flow
Merge 3288cd95f into b3a0f2146
Pull Request #486: Dynamic blocks

5136 of 7499 branches covered (68.49%)

Branch coverage included in aggregate %.

49 of 92 new or added lines in 9 files covered. (53.26%)

10 existing lines in 3 files now uncovered.

20470 of 26372 relevant lines covered (77.62%)

36747.45 hits per line

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

95.12
/src/ACadSharp/IO/Templates/CadBlockRecordTemplate.cs
1
using ACadSharp.Blocks;
2
using ACadSharp.Entities;
3
using ACadSharp.IO.DWG;
4
using ACadSharp.Objects;
5
using ACadSharp.Tables;
6
using CSUtilities.Extensions;
7
using System.Collections.Generic;
8

9
namespace ACadSharp.IO.Templates
10
{
11
        internal class CadBlockRecordTemplate : CadTableEntryTemplate<BlockRecord>
12
        {
13
                public ulong? FirstEntityHandle { get; set; }
3,876✔
14

15
                public ulong? LastEntityHandle { get; set; }
759✔
16

17
                public ulong? BeginBlockHandle { get; set; }
2,670✔
18

19
                public ulong? EndBlockHandle { get; set; }
2,670✔
20

21
                public ulong? LayoutHandle { get; set; }
6,257✔
22

23
                public List<ulong> OwnedObjectsHandlers { get; set; } = new List<ulong>();
28,421✔
24

25
                public List<ulong> InsertHandles { get; set; } = new List<ulong>();
4,541✔
26

27
                public string LayerName { get; set; }
×
28

29
                public CadBlockRecordTemplate() : base(new BlockRecord()) { }
5,958✔
30

31
                public CadBlockRecordTemplate(BlockRecord block) : base(block) { }
6,417✔
32

33
                public override void Build(CadDocumentBuilder builder)
34
                {
3,117✔
35
                        base.Build(builder);
3,117✔
36

37
                        if (this.CadObject.Name == "*U16")
3,117!
NEW
38
                        {
×
39
                                //Is dynamic if Flags.Contains(Anonymous)
40
                                //Block reference -> ExtendedData["AcDbRegAppTableRecord"].Value[ACadSharp.DxfCode.ExtendedDataHandle] => handle
NEW
41
                        }
×
42

43
                        if (builder.TryGetCadObject(this.LayoutHandle, out Layout layout))
3,117✔
44
                        {
830✔
45
                                this.CadObject.Layout = layout;
830✔
46
                        }
830✔
47

48
                        if (this.FirstEntityHandle.HasValue)
3,117✔
49
                        {
375✔
50
                                foreach (Entity e in this.getEntitiesCollection<Entity>(builder, this.FirstEntityHandle.Value, this.LastEntityHandle.Value))
10,055✔
51
                                {
4,465✔
52
                                        this.addEntity(builder, e);
4,465✔
53
                                }
4,465✔
54
                        }
375✔
55
                        else
56
                        {
2,742✔
57
                                foreach (ulong handle in this.OwnedObjectsHandlers)
51,470✔
58
                                {
21,622✔
59
                                        if (builder.TryGetCadObject(handle, out Entity child))
21,622✔
60
                                        {
21,314✔
61
                                                this.addEntity(builder, child);
21,314✔
62
                                        }
21,314✔
63
                                }
21,622✔
64
                        }
2,742✔
65
                }
3,117✔
66

67
                public void SetBlockToRecord(CadDocumentBuilder builder)
68
                {
1,323✔
69
                        if (builder.TryGetCadObject(this.BeginBlockHandle, out Block block))
1,323✔
70
                        {
1,323✔
71
                                if (!block.Name.IsNullOrEmpty())
1,323✔
72
                                {
1,323✔
73
                                        this.CadObject.Name = block.Name;
1,323✔
74
                                }
1,323✔
75

76
                                block.Flags = this.CadObject.BlockEntity.Flags;
1,323✔
77
                                block.BasePoint = this.CadObject.BlockEntity.BasePoint;
1,323✔
78
                                block.XrefPath = this.CadObject.BlockEntity.XrefPath;
1,323✔
79
                                block.Comments = this.CadObject.BlockEntity.Comments;
1,323✔
80

81
                                this.CadObject.BlockEntity = block;
1,323✔
82
                        }
1,323✔
83

84
                        if (builder.TryGetCadObject(this.EndBlockHandle, out BlockEnd blockEnd))
1,323✔
85
                        {
1,323✔
86
                                this.CadObject.BlockEnd = blockEnd;
1,323✔
87
                        }
1,323✔
88
                }
1,323✔
89

90
                private void addEntity(CadDocumentBuilder builder, Entity entity)
91
                {
25,779✔
92
                        if (!builder.KeepUnknownEntities && entity is UnknownEntity)
25,779✔
93
                        {
20✔
94
                                return;
20✔
95
                        }
96

97
                        this.CadObject.Entities.Add(entity);
25,759✔
98
                }
25,779✔
99
        }
100
}
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

© 2025 Coveralls, Inc