-
-
Notifications
You must be signed in to change notification settings - Fork 119
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 #419 from nanoLogika/20240619_mme_#6-support-dynam…
…ic-blocks-read-evaluation-graphs-and-block-visibility-parameters Sync Branch 20240619 mme #6 support dynamic blocks read evaluation graphs and block visibility parameters
- Loading branch information
Showing
7 changed files
with
457 additions
and
1 deletion.
There are no files selected for viewing
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
42 changes: 42 additions & 0 deletions
42
src/ACadSharp/IO/Templates/BlockVisibilityParameterTemplate.cs
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,42 @@ | ||
using System.Collections.Generic; | ||
|
||
using ACadSharp.Entities; | ||
using ACadSharp.Objects; | ||
|
||
namespace ACadSharp.IO.Templates { | ||
|
||
internal class BlockVisibilityParameterTemplate : CadTemplate<BlockVisibilityParameter> { | ||
|
||
public BlockVisibilityParameterTemplate(BlockVisibilityParameter cadObject) | ||
: base(cadObject) { | ||
} | ||
|
||
public IDictionary<ulong, Entity> TotalEntityHandles { get; } = new Dictionary<ulong, Entity>(); | ||
|
||
public IDictionary<BlockVisibilityParameter.SubBlock, IList<ulong>> SubBlockHandles { get; } = new Dictionary<BlockVisibilityParameter.SubBlock, IList<ulong>>(); | ||
|
||
public override void Build(CadDocumentBuilder builder) { | ||
base.Build(builder); | ||
|
||
foreach (var cadObjectHandle in this.TotalEntityHandles) { | ||
ulong handle = cadObjectHandle.Key; | ||
if (builder.TryGetCadObject(handle, out Entity entity)) { | ||
this.TotalEntityHandles[handle] = entity; | ||
this.CadObject.Entities.Add(entity); | ||
} | ||
} | ||
|
||
foreach (var subGroup in this.CadObject.SubBlocks) { | ||
if (this.SubBlockHandles.TryGetValue(subGroup, out IList<ulong> subBlockHandles)) { | ||
foreach (ulong handle in subBlockHandles) { | ||
if (this.TotalEntityHandles.TryGetValue(handle, out Entity entity)) { | ||
subGroup.Entities.Add(entity); | ||
} | ||
else if (builder.TryGetCadObject(handle, out Entity entityX)) { | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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,25 @@ | ||
using System.Collections.Generic; | ||
|
||
using ACadSharp.Objects; | ||
|
||
namespace ACadSharp.IO.Templates { | ||
internal class EvaluationGraphTemplate : CadTemplate<EvaluationGraph>{ | ||
|
||
public EvaluationGraphTemplate(EvaluationGraph evaluationGraph) | ||
: base(evaluationGraph) { | ||
} | ||
|
||
public IDictionary<EvaluationGraph.GraphNode, ulong> NodeHandles { get; } = new Dictionary<EvaluationGraph.GraphNode, ulong>(); | ||
|
||
public override void Build(CadDocumentBuilder builder) { | ||
base.Build(builder); | ||
|
||
foreach (EvaluationGraph.GraphNode node in this.CadObject.Nodes) { | ||
var nodeHandle = this.NodeHandles[node]; | ||
if (builder.TryGetCadObject(nodeHandle, out CadObject nodeObject)) { | ||
node.NodeObject = nodeObject; | ||
} | ||
} | ||
} | ||
} | ||
} |
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,131 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using ACadSharp.Attributes; | ||
using ACadSharp.Entities; | ||
|
||
using CSMath; | ||
|
||
|
||
namespace ACadSharp.Objects | ||
{ | ||
|
||
/// <summary> | ||
/// Represents a BLOCKVISIBILITYPARAMETER object, in AutoCAD used to | ||
/// control the visibility state of entities in a dynamic block. | ||
/// </summary> | ||
public class BlockVisibilityParameter : CadObject | ||
{ | ||
|
||
/// <inheritdoc/> | ||
public override ObjectType ObjectType => ObjectType.UNLISTED; | ||
|
||
/// <inheritdoc/> | ||
public override string ObjectName => DxfFileToken.ObjectBlockVisibilityParameter; | ||
|
||
/// <inheritdoc/> | ||
public override string SubclassMarker => DxfSubclassMarker.BlockVisibilityParameter; | ||
|
||
|
||
/// <summary> | ||
/// Gets the list of all <see cref="Entity"/> objects of the dynamic block | ||
/// this <see cref="BlockVisibilityParameter"/> is associated with. | ||
/// </summary> | ||
[DxfCodeValue(331)] | ||
public IList<Entity> Entities { get; private set; } = new List<Entity>(); | ||
|
||
/// <summary> | ||
/// Gets the list of subblocks each containing a subset of the <see cref="Entity"/> | ||
/// objects of the dynamic block this <see cref="BlockVisibilityParameter"/> | ||
/// is associated with. | ||
/// </summary> | ||
public IList<SubBlock> SubBlocks { get; private set; } = new List<SubBlock>(); | ||
|
||
/// <summary> | ||
/// Gets a position presumably used to display a triangle-button in AutoCAD open | ||
/// a dialog to select the subblock that is to be set visible. | ||
/// </summary> | ||
[DxfCodeValue(1010, 1020, 1030)] | ||
public XYZ BasePosition { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets a text presumably describing the purpose of this <see cref="BlockVisibilityParameter"/>. | ||
/// </summary> | ||
[DxfCodeValue(300)] | ||
public string ParameterType { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets a title for the dialog to select the subblock that is to be set visible. | ||
/// </summary> | ||
[DxfCodeValue(301)] | ||
public string Name { get; internal set; } | ||
|
||
/// <summary> | ||
/// Gets a description presumably for the dialog to select the subblock that is to be set visible. | ||
/// </summary> | ||
[DxfCodeValue(302)] | ||
public string Description { get; internal set; } | ||
|
||
/// <summary> | ||
/// Unknown | ||
/// </summary> | ||
[DxfCodeValue(91)] | ||
public int L91 { get; internal set; } | ||
|
||
/// <summary> | ||
/// Represents a named subblock containing <see cref="Entity"/> objects. | ||
/// The visibility of the entities of a subblock can be determined | ||
/// interactively in AutoCAD. | ||
/// </summary> | ||
public class SubBlock : ICloneable | ||
{ | ||
|
||
/// <summary> | ||
/// Gets the name of the subblock. | ||
/// </summary> | ||
[DxfCodeValue(303)] | ||
public string Name { get; set; } | ||
|
||
/// <summary> | ||
/// Get the list of <see cref="Entity"/> objects in this subblock. | ||
/// </summary> | ||
[DxfCodeValue(332)] | ||
public IList<Entity> Entities { get; private set; } = new List<Entity>(); | ||
|
||
|
||
public object Clone() | ||
{ | ||
SubBlock clone = (SubBlock)MemberwiseClone(); | ||
|
||
clone.Entities = new List<Entity>(); | ||
foreach (var item in this.Entities) | ||
{ | ||
clone.Entities.Add((Entity)item.Clone()); | ||
} | ||
|
||
return clone; | ||
} | ||
} | ||
|
||
|
||
/// <inheritdoc/> | ||
public override CadObject Clone() | ||
{ | ||
BlockVisibilityParameter clone = (BlockVisibilityParameter)base.Clone(); | ||
|
||
clone.Entities = new List<Entity>(); | ||
foreach (var item in this.Entities) | ||
{ | ||
clone.Entities.Add((Entity)item.Clone()); | ||
} | ||
|
||
clone.SubBlocks = new List<SubBlock>(); | ||
foreach (var item in this.SubBlocks) | ||
{ | ||
clone.SubBlocks.Add((SubBlock)item.Clone()); | ||
} | ||
|
||
return clone; | ||
} | ||
} | ||
} |
Oops, something went wrong.