-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #486 from DomCR/dynamic-blocks
Dynamic blocks
- Loading branch information
Showing
41 changed files
with
18,535 additions
and
458 deletions.
There are no files selected for viewing
Binary file not shown.
17,508 changes: 17,508 additions & 0 deletions
17,508
samples/dynamic-blocks/dynamic-block-circle.dxf
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using ACadSharp.Entities; | ||
using ACadSharp.IO; | ||
using ACadSharp.Objects.Evaluations; | ||
using ACadSharp.Tables; | ||
using ACadSharp.Tests.TestModels; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace ACadSharp.Tests.IO | ||
{ | ||
public class DynamicBlockTests : IOTestsBase | ||
{ | ||
public static TheoryData<FileModel> DwgDynamicBlocksPaths { get; } = new(); | ||
|
||
static DynamicBlockTests() | ||
{ | ||
loadSamples("dynamic-blocks", "*", DwgDynamicBlocksPaths); | ||
} | ||
|
||
public DynamicBlockTests(ITestOutputHelper output) : base(output) | ||
{ | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(DwgDynamicBlocksPaths))] | ||
public void DynamicBlocksTest(FileModel test) | ||
{ | ||
CadDocument doc; | ||
|
||
if (test.Extension == ".dxf") | ||
{ | ||
DxfReaderConfiguration configuration = new(); | ||
configuration.KeepUnknownEntities = true; | ||
configuration.KeepUnknownNonGraphicalObjects = true; | ||
|
||
doc = DxfReader.Read(test.Path, configuration, this.onNotification); | ||
} | ||
else | ||
{ | ||
DwgReaderConfiguration configuration = new DwgReaderConfiguration(); | ||
configuration.KeepUnknownEntities = true; | ||
configuration.KeepUnknownNonGraphicalObjects = true; | ||
|
||
doc = DwgReader.Read(test.Path, configuration, this.onNotification); | ||
} | ||
|
||
//"my-dynamic-block" handle = 570 | ||
|
||
BlockRecord blk = doc.BlockRecords["my-dynamic-block"]; | ||
|
||
Assert.True(blk.IsDynamic); | ||
|
||
//Dictionary entry | ||
EvaluationGraph eval = blk.XDictionary.GetEntry<EvaluationGraph>("ACAD_ENHANCEDBLOCK"); | ||
|
||
//Extended data related to the dynamic block | ||
var a = blk.ExtendedData.Get(doc.AppIds["AcDbBlockRepETag"]); | ||
var b = blk.ExtendedData.Get(doc.AppIds["AcDbDynamicBlockTrueName"]); | ||
var c = blk.ExtendedData.Get(doc.AppIds["AcDbDynamicBlockGUID"]); | ||
|
||
Insert basic = doc.GetCadObject<Insert>(788); | ||
Insert modified = doc.GetCadObject<Insert>(889); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.