Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
[2021/03/08]
Browse files Browse the repository at this point in the history
* The Insert Sync method will not modify any value assigned to the attribute Value property.
* (fixed) A couple errors when writing the style overrides of a dimension to the extended data.
* (fixed) Error when reading frozen layers from a DXF.
* (fixed) Round off issues when transforming insert attributes, this may also affect other text based entities and attribute definitions.
The MathHelper.NormalizeAngle method will check if the normalized angle is very close to 360 or -360 and return 0 in these cases.
* (fixed) Error when saving to a file an absolute rotation value of complex linetypes.
* (fixed) Negative scale values should be allowed in the Insert constructor as it is in the Scale property. Deleted the Insert constructor "public Insert(Block block, Vector3 position, double scale)", change the Scale property instead.
  • Loading branch information
haplokuon committed Mar 8, 2021
1 parent 9c4feed commit aee2e64
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 22 deletions.
9 changes: 9 additions & 0 deletions doc/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
## Change history

### [2021/03/08]
* The Insert Sync method will not modify any value assigned to the attribute Value property.
* (fixed) A couple errors when writing the style overrides of a dimension to the extended data.
* (fixed) Error when reading frozen layers from a DXF.
* (fixed) Round off issues when transforming insert attributes, this may also affect other text based entities and attribute definitions.
The MathHelper.NormalizeAngle method will check if the normalized angle is very close to 360 or -360 and return 0 in these cases.
* (fixed) Error when saving to a file an absolute rotation value of complex linetypes.
* (fixed) Negative scale values should be allowed in the Insert constructor as it is in the Scale property. Deleted the Insert constructor "public Insert(Block block, Vector3 position, double scale)", change the Scale property instead.

### [2.4.1 - 2020/12/06]
* Added LayerStates accessible trough the Layers.StateManager. For more details see LayerStateManager() sample.
* Added some workarounds for invalid values in buggy DXF files.
Expand Down
40 changes: 27 additions & 13 deletions netDxf/Entities/Insert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,32 +286,46 @@ internal EndSequence EndSequence
#region public methods

/// <summary>
/// Updates the actual insert with the attribute properties currently defined in the block. This does not affect any values assigned to attributes in each block.
/// Updates the attribute list of the actual insert with the attribute definition list of the referenced block. This does not affect any value assigned to the Value property.
/// </summary>
/// <remarks>This method will automatically call the TransformAttributes method, to keep all attributes position and orientation up to date.</remarks>
/// <remarks></remarks>
/// <remarks>
/// This method will automatically call the TransformAttributes method, to keep all attributes position and orientation up to date.<br />
/// This method will does not change the values assigned to attributes in the actual insert, besides the ones modified by the TransformAttributes() method;
/// position, normal, rotation, text height, width factor, oblique angle, is backwards, is upside down, and alignment values.
/// </remarks>
public void Sync()
{
List<Attribute> atts = new List<Attribute>(this.block.AttributeDefinitions.Count);
List<Attribute> atts = new List<Attribute>();

// remove all attributes in the actual insert
// remove all attributes that have no attribute definition in the block
foreach (Attribute att in this.attributes)
{
this.OnAttributeRemovedEvent(att);
att.Handle = null;
att.Owner = null;
string tag = att.Tag;
if (this.block.AttributeDefinitions.ContainsTag(tag))
{
atts.Add(att);
}
else
{
this.OnAttributeRemovedEvent(att);
att.Handle = null;
att.Owner = null;
}
}

// add any new attributes from the attribute definitions of the block
foreach (AttributeDefinition attdef in this.block.AttributeDefinitions.Values)
{
Attribute att = new Attribute(attdef)
if (this.attributes.AttributeWithTag(attdef.Tag) == null)
{
Owner = this
};
Attribute att = new Attribute(attdef)
{
Owner = this
};

atts.Add(att);
this.OnAttributeAddedEvent(att);
atts.Add(att);
this.OnAttributeAddedEvent(att);
}
}
this.attributes = new AttributeCollection(atts);

Expand Down
2 changes: 1 addition & 1 deletion netDxf/IO/DxfWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3706,7 +3706,7 @@ private void AddDimensionStyleOverridesXData(XDataDictionary xdata, DimensionSty
break;
case DimensionStyleOverrideType.FitTextMove:
xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 279));
xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) (DimensionStyleFitOptions) styleOverride.Value));
xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) (DimensionStyleFitTextMove) styleOverride.Value));
break;
case DimensionStyleOverrideType.AngularPrecision:
xdataEntry.XDataRecord.Add(new XDataRecord(XDataCode.Int16, (short) 179));
Expand Down
2 changes: 1 addition & 1 deletion netDxf/MathHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ public static Vector2 FindIntersection(Vector2 point0, Vector2 dir0, Vector2 poi
public static double NormalizeAngle(double angle)
{
double normalized = angle % 360.0;
if (IsZero(normalized))
if (IsZero(normalized) || IsEqual(Math.Abs(normalized), 360.0))
{
return 0.0;
}
Expand Down
6 changes: 3 additions & 3 deletions netDxf/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("netDxf")]
[assembly: AssemblyCopyright("Daniel Carvajal © 2020")]
[assembly: AssemblyCopyright("Daniel Carvajal © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -58,6 +58,6 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("2.4.1.0")]
[assembly: AssemblyFileVersion("2.4.1.0")]
[assembly: AssemblyVersion("2.4.2.0")]
[assembly: AssemblyFileVersion("2.4.2.0")]
[assembly: CLSCompliant(true)]
8 changes: 4 additions & 4 deletions netDxf/Tables/Linetype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,14 +620,14 @@ private static LinetypeSegment ReadLineTypeComplexSegment(string[] data, double
scale = 0.1;
}
}
else if (data[i].StartsWith("R=", StringComparison.InvariantCultureIgnoreCase))
else if (data[i].StartsWith("A=", StringComparison.InvariantCultureIgnoreCase))
{
rotationType = LinetypeSegmentRotationType.Relative;
rotationType = LinetypeSegmentRotationType.Absolute;
rotation = ReadRotation(value);
}
else if (data[i].StartsWith("Q=", StringComparison.InvariantCultureIgnoreCase))
else if (data[i].StartsWith("R=", StringComparison.InvariantCultureIgnoreCase))
{
rotationType = LinetypeSegmentRotationType.Absolute;
rotationType = LinetypeSegmentRotationType.Relative;
rotation = ReadRotation(value);
}
else if (data[i].StartsWith("U=", StringComparison.InvariantCultureIgnoreCase))
Expand Down

0 comments on commit aee2e64

Please sign in to comment.