Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementation of MULTILEADER and MULTILEADERSTYLE #169

Merged
merged 30 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
43614d7
Implement Multileader
Sep 15, 2023
4d25097
Merge pull request #5 from mme1950/20230915_mme_Multileader
nka1994 Sep 15, 2023
15b59ba
Update Multileader Summary and DwgMergedReader Advance Method
Sep 29, 2023
b93c5b4
Update from Original Repository
Sep 29, 2023
24b4f8f
Draw Multileader to sample_AC1032.dwg
Oct 4, 2023
1e827f7
Improve Clone Function for Multileader
Oct 4, 2023
24fc426
Styles do not need to be cloned
Oct 4, 2023
06f7112
- some refactoring
Oct 4, 2023
1bd0fe8
Change Arrowhead Data Type for BlockRecord
Oct 4, 2023
68d8ed0
Replace BlockRecord with ContentsBlock
Oct 4, 2023
318a9f6
Add SubclassMarker for Multileader
Oct 4, 2023
ec01a04
Add SubclassMarker for MLeaderStyle
Oct 4, 2023
ca176e4
Add Constructor for MultiLeaderStyle
Oct 4, 2023
0f36506
Add Constructor for MultiLeaderAnnotContext and Clone BlockAttributes…
Oct 4, 2023
99e190f
Implement Missing Clone Methods
Oct 4, 2023
d14b04e
Merge branch 'master' into master
nka1994 Oct 10, 2023
38987f9
Improve MultiLeader
Oct 16, 2023
5d48490
Correct After Review
Oct 16, 2023
b729831
Merge branch 'master' into master
nka1994 Oct 30, 2023
8e1a0e6
Corrections
Oct 30, 2023
8c2b328
Fix MultiLeader Clone
Oct 31, 2023
b1ded16
Add MultiLeader Sample DWG
Oct 31, 2023
b6c5987
Implement Asserts for MultiLeader
Oct 31, 2023
ac6fa2d
Corrections
Nov 3, 2023
759b778
Fix Color Tests and Add MultiLeader to Ignore List
Nov 3, 2023
9a63d0b
Update Comments
Nov 3, 2023
b3f82d2
- comments improved
Nov 3, 2023
50f57b6
Baseline Merge, Comments Improved
Nov 3, 2023
e60a94a
Fix DwgObjectReader
Nov 3, 2023
f5fb8e0
Update MultiLeader.cs
DomCR Nov 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 142 additions & 0 deletions ACadSharp.Tests/IO/MultiLeaderTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
using ACadSharp.Entities;
using ACadSharp.IO;
using System.Collections.Generic;
using System.IO;
using Xunit;
using Xunit.Abstractions;

namespace ACadSharp.Tests.IO
{
public class MultiLeaderTests : IOTestsBase
{
public MultiLeaderTests(ITestOutputHelper output) : base(output)
{
}

[Fact]
public void MultiLeaderDwg()
{
string inPath = Path.Combine($"{_samplesFolder}", "multileader", "sample_MLeader_AC1032.dwg");
CadDocument doc = DwgReader.Read(inPath);

// There are 14 multileaders in DWG file
Assert.Equal(14, doc.Entities.Count);

List<Entity> entities = new List<Entity>(doc.Entities);

MultiLeader multiLeader;

multiLeader = (MultiLeader)entities[0];
Assert.Equal(@"MULTILEADER TEST", multiLeader.ContextData.TextLabel);
Assert.Equal(TextAttachmentPointType.Left, multiLeader.TextAttachmentPoint);
Assert.Equal(TextAttachmentType.MiddleOfTopLine, multiLeader.TextLeftAttachment);
Assert.False(multiLeader.TextFrame);
Assert.Equal(8, multiLeader.LandingDistance);
Assert.Equal(TextAttachmentDirectionType.Horizontal, multiLeader.TextAttachmentDirection);

multiLeader = (MultiLeader)entities[1];
Assert.Equal(@"MULTILEADER\PTEST\P123", multiLeader.ContextData.TextLabel);
Assert.Equal(TextAttachmentPointType.Left, multiLeader.TextAttachmentPoint);
Assert.Equal(TextAttachmentType.MiddleOfTopLine, multiLeader.TextLeftAttachment);
Assert.False(multiLeader.TextFrame);
Assert.Equal(8, multiLeader.LandingDistance);
Assert.Equal(TextAttachmentDirectionType.Horizontal, multiLeader.TextAttachmentDirection);

multiLeader = (MultiLeader)entities[2];
Assert.Equal(@"MULTILEADER\PTEST\P123", multiLeader.ContextData.TextLabel);
Assert.Equal(TextAttachmentPointType.Center, multiLeader.TextAttachmentPoint);
Assert.Equal(TextAttachmentType.MiddleOfTopLine, multiLeader.TextLeftAttachment);
Assert.False(multiLeader.TextFrame);
Assert.Equal(8, multiLeader.LandingDistance);
Assert.Equal(TextAttachmentDirectionType.Horizontal, multiLeader.TextAttachmentDirection);

multiLeader = (MultiLeader)entities[3];
Assert.Equal(@"MULTILEADER\PTEST\P123", multiLeader.ContextData.TextLabel);
Assert.Equal(TextAttachmentPointType.Right, multiLeader.TextAttachmentPoint);
Assert.Equal(TextAttachmentType.MiddleOfTopLine, multiLeader.TextLeftAttachment);
Assert.False(multiLeader.TextFrame);
Assert.Equal(8, multiLeader.LandingDistance);
Assert.Equal(TextAttachmentDirectionType.Horizontal, multiLeader.TextAttachmentDirection);

multiLeader = (MultiLeader)entities[4];
Assert.Equal(@"MULTILEADER\PTEST\P123", multiLeader.ContextData.TextLabel);
Assert.Equal(TextAttachmentPointType.Right, multiLeader.TextAttachmentPoint);
Assert.Equal(TextAttachmentType.MiddleOfTopLine, multiLeader.TextLeftAttachment);
Assert.True(multiLeader.TextFrame);
Assert.Equal(8, multiLeader.LandingDistance);
Assert.Equal(TextAttachmentDirectionType.Horizontal, multiLeader.TextAttachmentDirection);

multiLeader = (MultiLeader)entities[5];
Assert.Equal(@"MULTILEADER\PTEST\P123", multiLeader.ContextData.TextLabel);
Assert.Equal(TextAttachmentPointType.Right, multiLeader.TextAttachmentPoint);
Assert.Equal(TextAttachmentType.MiddleOfTopLine, multiLeader.TextLeftAttachment);
Assert.True(multiLeader.TextFrame);
Assert.Equal(8, multiLeader.LandingDistance);
Assert.Equal(TextAttachmentDirectionType.Horizontal, multiLeader.TextAttachmentDirection);

multiLeader = (MultiLeader)entities[6];
Assert.Equal(@"MULTILEADER\PTEST\P123", multiLeader.ContextData.TextLabel);
Assert.Equal(TextAttachmentPointType.Right, multiLeader.TextAttachmentPoint);
Assert.Equal(TextAttachmentType.MiddleOfTopLine, multiLeader.TextLeftAttachment);
Assert.True(multiLeader.TextFrame);
Assert.Equal(16, multiLeader.LandingDistance);
Assert.Equal(TextAttachmentDirectionType.Horizontal, multiLeader.TextAttachmentDirection);

multiLeader = (MultiLeader)entities[7];
Assert.Equal(@"MULTILEADER\PTEST\P123", multiLeader.ContextData.TextLabel);
Assert.Equal(TextAttachmentPointType.Right, multiLeader.TextAttachmentPoint);
Assert.Equal(TextAttachmentType.MiddleOfTopLine, multiLeader.TextLeftAttachment);
Assert.True(multiLeader.TextFrame);
Assert.Equal(16, multiLeader.LandingDistance);
Assert.Equal(TextAttachmentDirectionType.Horizontal, multiLeader.TextAttachmentDirection);

multiLeader = (MultiLeader)entities[8];
Assert.Equal(@"MULTILEADER\PTEST\P123", multiLeader.ContextData.TextLabel);
Assert.Equal(TextAttachmentPointType.Right, multiLeader.TextAttachmentPoint);
Assert.Equal(TextAttachmentType.MiddleOfTopLine, multiLeader.TextLeftAttachment);
Assert.True(multiLeader.TextFrame);
Assert.Equal(16, multiLeader.LandingDistance);
Assert.Equal(TextAttachmentDirectionType.Horizontal, multiLeader.TextAttachmentDirection);

multiLeader = (MultiLeader)entities[9];
Assert.Equal(@"MULTILEADER\PTEST\P123", multiLeader.ContextData.TextLabel);
Assert.Equal(TextAttachmentPointType.Right, multiLeader.TextAttachmentPoint);
Assert.Equal(TextAttachmentType.MiddleOfTopLine, multiLeader.TextLeftAttachment);
Assert.True(multiLeader.TextFrame);
Assert.Equal(16, multiLeader.LandingDistance);
Assert.Equal(TextAttachmentDirectionType.Horizontal, multiLeader.TextAttachmentDirection);

multiLeader = (MultiLeader)entities[10];
Assert.Equal(@"MULTILEADER\PTEST\P123", multiLeader.ContextData.TextLabel);
Assert.Equal(TextAttachmentPointType.Right, multiLeader.TextAttachmentPoint);
Assert.Equal(TextAttachmentType.MiddleOfTopLine, multiLeader.TextLeftAttachment);
Assert.True(multiLeader.TextFrame);
Assert.Equal(16, multiLeader.LandingDistance);
Assert.Equal(TextAttachmentDirectionType.Horizontal, multiLeader.TextAttachmentDirection);

multiLeader = (MultiLeader)entities[11];
Assert.Equal(@"MULTILEADER TEST", multiLeader.ContextData.TextLabel);
Assert.Equal(TextAttachmentPointType.Left, multiLeader.TextAttachmentPoint);
Assert.Equal(TextAttachmentType.BottomLine, multiLeader.TextLeftAttachment);
Assert.False(multiLeader.TextFrame);
Assert.Equal(8, multiLeader.LandingDistance);
Assert.Equal(TextAttachmentDirectionType.Horizontal, multiLeader.TextAttachmentDirection);

multiLeader = (MultiLeader)entities[12];
Assert.Equal(@"MULTILEADER TEST", multiLeader.ContextData.TextLabel);
Assert.Equal(TextAttachmentPointType.Left, multiLeader.TextAttachmentPoint);
Assert.Equal(TextAttachmentType.TopOfTopLine, multiLeader.TextLeftAttachment);
Assert.False(multiLeader.TextFrame);
Assert.Equal(8, multiLeader.LandingDistance);
Assert.Equal(TextAttachmentDirectionType.Horizontal, multiLeader.TextAttachmentDirection);

multiLeader = (MultiLeader)entities[13];
Assert.Equal(@"MULTILEADER TEST", multiLeader.ContextData.TextLabel);
Assert.Equal(TextAttachmentPointType.Left, multiLeader.TextAttachmentPoint);
Assert.Equal(TextAttachmentType.TopOfTopLine, multiLeader.TextLeftAttachment);
Assert.False(multiLeader.TextFrame);
Assert.Equal(8, multiLeader.LandingDistance);
Assert.Equal(TextAttachmentDirectionType.Vertical, multiLeader.TextAttachmentDirection);
}
}
}
9 changes: 9 additions & 0 deletions ACadSharp/AttachmentType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace ACadSharp {

public enum AttachmentType : short {

CenterExtents = 0,

InsertionPoint = 1
}
}
1 change: 1 addition & 0 deletions ACadSharp/DxfFileToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public static class DxfFileToken
public const string ObjectScale = "SCALE";
public const string ObjectSortEntsTable = "SORTENTSTABLE";
public const string ObjectXRecord = "XRECORD";
public const string ObjectMLeaderContextData = "CONTEXT_DATA";

#endregion
}
Expand Down
3 changes: 3 additions & 0 deletions ACadSharp/DxfSubclassMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public static class DxfSubclassMarker
public const string Vertex = "AcDbVertex";
public const string Polyline = "AcDb2dPolyline";
public const string Leader = "AcDbLeader";
public const string MLeader = "AcDbMLeader";
public const string MLeaderStyle = "AcDbMLeaderStyle";
public const string MultiLeaderAnnotContext = "AcDbMultiLeaderAnnotContext";
public const string LwPolyline = "AcDbPolyline";
public const string PolylineVertex = "AcDb2dVertex";
public const string Polyline3d = "AcDb3dPolyline";
Expand Down
Loading
Loading