Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added samples/dynamic-blocks/BLOCKPOINTPARAMETER.dwg
Binary file not shown.
14,438 changes: 14,438 additions & 0 deletions samples/dynamic-blocks/BLOCKPOINTPARAMETER.dxf

Large diffs are not rendered by default.

Binary file added samples/dynamic-blocks/BLOCKROTATIONPARAMETER.dwg
Binary file not shown.
15,172 changes: 15,172 additions & 0 deletions samples/dynamic-blocks/BLOCKROTATIONPARAMETER.dxf

Large diffs are not rendered by default.

68 changes: 67 additions & 1 deletion src/ACadSharp.Tests/IO/DynamicBlockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using ACadSharp.Objects.Evaluations;
using ACadSharp.Tables;
using ACadSharp.Tests.TestModels;
using System;
using System.Linq;
using Xunit;
using Xunit.Abstractions;
Expand Down Expand Up @@ -85,6 +86,60 @@ public void IsolatedTest(FileModel test)
var config = getConfiguration(test);
var doc = this.readDocument(test, config);

switch (test.NoExtensionName)
{
case DxfFileToken.ObjectBlockVisibilityParameter:
this.assertVisibilityParameter(doc);
break;
case DxfFileToken.ObjectBlockRotationParameter:
this.assertRotationParameter(doc);
break;
case DxfFileToken.ObjectBlockPointParameter:
this.assertPointParameter(doc);
break;
default:
throw new System.NotImplementedException();
}
}

private void assertPointParameter(CadDocument doc)
{
//Not implemented in this PR
}

private void assertRotationParameter(CadDocument doc)
{
var original = doc.BlockRecords["dynamic_block"];
foreach (BlockRecord record in doc.BlockRecords.Where(b => b.IsAnonymous))
{
Assert.Equal(original, record.Source);
}

foreach (Insert insert in doc.Entities.OfType<Insert>())
{
if (insert.XDictionary == null)
{
continue;
}

var dict = insert.XDictionary.GetEntry<CadDictionary>("AcDbBlockRepresentation");
var representation = dict.GetEntry<BlockRepresentationData>("AcDbRepData");

Assert.NotEmpty(insert.Block.Source.EvaluationGraph.Nodes.Select(n => n.Expression).OfType<BlockRotationParameter>());

Assert.NotNull(representation);
Assert.Equal(original, representation.Block);

XRecord record = insert.XDictionary
.GetEntry<CadDictionary>("AcDbBlockRepresentation")
.GetEntry<CadDictionary>("AppDataCache")
.GetEntry<CadDictionary>("ACAD_ENHANCEDBLOCKDATA")
.OfType<XRecord>().First();
}
}

private void assertVisibilityParameter(CadDocument doc)
{
var original = doc.BlockRecords["block_visibility_parameter"];
foreach (BlockRecord record in doc.BlockRecords.Where(b => b.IsAnonymous))
{
Expand All @@ -96,9 +151,20 @@ public void IsolatedTest(FileModel test)
var dict = insert.XDictionary.GetEntry<CadDictionary>("AcDbBlockRepresentation");
var representation = dict.GetEntry<BlockRepresentationData>("AcDbRepData");

Assert.NotEmpty(insert.Block.Source.EvaluationGraph.Nodes.Select(n => n.Expression).OfType<BlockVisibilityParameter>());

Assert.NotNull(representation);
Assert.Equal(original, representation.Block);

XRecord record = insert.XDictionary
.GetEntry<CadDictionary>("AcDbBlockRepresentation")
.GetEntry<CadDictionary>("AppDataCache")
.GetEntry<CadDictionary>("ACAD_ENHANCEDBLOCKDATA")
.OfType<XRecord>().First();

var name = record.Entries.FirstOrDefault(e => e.Code == 1).Value as string;
Assert.False(string.IsNullOrEmpty(name));
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/ACadSharp/ACadSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>3.4.3</Version>
<Version>3.4.4</Version>
<PackageOutputPath>../nupkg</PackageOutputPath>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>../ACadSharp.snk</AssemblyOriginatorKeyFile>
Expand Down
6 changes: 5 additions & 1 deletion src/ACadSharp/DxfFileToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,22 @@ public static class DxfFileToken
public const string ObjectEvalGraph = "ACAD_EVALUATION_GRAPH";
public const string ObjectBlockLinearParameter = "BLOCKLINEARPARAMETER";
public const string ObjectBlockVisibilityParameter = "BLOCKVISIBILITYPARAMETER";
public const string ObjectBlockRotationGrip = "BLOCKROTATIONGRIP";
public const string ObjectBlockVisibilityGrip = "BLOCKVISIBILITYGRIP";
public const string ObjectBlockBasePointParameter = "BLOCKBASEPOINTPARAMETER";
public const string ObjectBlockRotationParameter = "BLOCKROTATIONPARAMETER";
public const string ObjectBlockPointParameter = "BLOCKPOINTPARAMETER";
public const string ObjectBlockGripLocationComponent = "BLOCKGRIPLOCATIONCOMPONENT";
public const string ObjectBlockFlipParameter = "BLOCKFLIPPARAMETER";
public const string ObjectBlockFlipAction = "BLOCKFLIPACTION";
public const string ObjectBlockRotateAction = "BLOCKROTATEACTION";
public const string ObjectTableContent = "TABLECONTENT";
public const string ObjectGeoData = "GEODATA";
public const string ObjectGroup = "GROUP";
public const string ObjectTableStyle = "TABLESTYLE";
public const string ObjectCellStyleMap = "CELLSTYLEMAP";
public const string ObjectSpatialFilter = "SPATIAL_FILTER";

//Table tokens
public const string ObjectTableColumn = "COLUMN";
public const string ObjectTableColumnBegin = "TABLECOLUMN_BEGIN";
Expand Down
8 changes: 8 additions & 0 deletions src/ACadSharp/DxfSubclassMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public static class DxfSubclassMarker

public const string BlockAction = "AcDbBlockAction";

public const string BlockActionBasePt = "AcDbBlockActionWithBasePt";

public const string BlockBasePointParameter = "AcDbBlockBasePointParameter";

public const string BlockBegin = "AcDbBlockBegin";
Expand All @@ -52,6 +54,12 @@ public static class DxfSubclassMarker

public const string BlockRepresentationData = "AcDbBlockRepresentationData";

public const string BlockRotationAction = "AcDbBlockRotationAction";

public const string BlockRotationGrip = "AcDbBlockRotationGrip";

public const string BlockRotationParameter = "AcDbBlockRotationParameter";

public const string BlockVisibilityGrip = "AcDbBlockVisibilityGrip";

public const string BlockVisibilityParameter = "AcDbBlockVisibilityParameter";
Expand Down
Loading