Skip to content

Commit

Permalink
Merge pull request #294 from DomCR/DimStyle-defaults
Browse files Browse the repository at this point in the history
Dim style defaults
  • Loading branch information
DomCR authored Mar 4, 2024
2 parents 884ee0e + c1fa7c5 commit 5bf7dd6
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 99 deletions.
6 changes: 6 additions & 0 deletions ACadSharp/CadObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,15 @@ internal virtual void UnassignDocument()
this.Document = null;
}

//TODO: Update method to all references
protected T updateTable<T>(T entry, Table<T> table)
where T : TableEntry
{
if (table == null)
{
return entry;
}

if (table.TryGetValue(entry.Name, out T existing))
{
return existing;
Expand Down
4 changes: 2 additions & 2 deletions ACadSharp/Header/CadHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1987,7 +1987,7 @@ public ZeroHandling DimensionToleranceZeroHandling
/// System variable DIMFIT
/// </remarks>
[CadSystemVariable("$DIMFIT", 70)]
public char DimensionFit
public short DimensionFit
{
get { return this.DimensionStyleOverrides.DimensionFit; }
set
Expand Down Expand Up @@ -2051,7 +2051,7 @@ public bool DimensionCursorUpdate
/// System variable DIMATFIT
/// </remarks>
[CadSystemVariable("$DIMATFIT", 70)]
public short DimensionDimensionTextArrowFit
public TextArrowFitType DimensionDimensionTextArrowFit
{
get { return this.DimensionStyleOverrides.DimensionTextArrowFit; }
set
Expand Down
4 changes: 2 additions & 2 deletions ACadSharp/IO/DWG/DwgStreamReaders/DwgHeaderReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ public void Read(int acadMaintenanceVersion, out DwgHeaderHandlesCollection obje
//RC : DIMJUST
_header.DimensionTextHorizontalAlignment = (Tables.DimensionTextHorizontalAlignment)_reader.ReadRawChar();
//RC : DIMFIT
_header.DimensionFit = _reader.ReadRawChar();
_header.DimensionFit = (short)_reader.ReadRawChar();
//B : DIMUPT
_header.DimensionCursorUpdate = _reader.ReadBit();
//RC : DIMTZIN
Expand Down Expand Up @@ -733,7 +733,7 @@ public void Read(int acadMaintenanceVersion, out DwgHeaderHandlesCollection obje
//B : DIMUPT
_header.DimensionCursorUpdate = _reader.ReadBit();
//BS : DIMATFIT
_header.DimensionDimensionTextArrowFit = _reader.ReadBitShort();
_header.DimensionDimensionTextArrowFit = (Tables.TextArrowFitType)_reader.ReadBitShort();
}

//R2007 + Only:
Expand Down
4 changes: 2 additions & 2 deletions ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4225,7 +4225,7 @@ private CadTemplate readDimStyle()
//DIMJUST RC 280
dimStyle.TextHorizontalAlignment = (DimensionTextHorizontalAlignment)this._objectReader.ReadByte();
//DIMFIT RC 287
dimStyle.DimensionFit = this._objectReader.ReadRawChar();
dimStyle.DimensionFit = (short)this._objectReader.ReadRawChar();
//DIMUPT B 288
dimStyle.CursorUpdate = this._objectReader.ReadBit();
//DIMTZIN RC 284
Expand Down Expand Up @@ -4446,7 +4446,7 @@ private CadTemplate readDimStyle()
//DIMUPT B 288
dimStyle.CursorUpdate = this._objectReader.ReadBit();
//DIMFIT BS 287
this._objectReader.ReadBitShort();
dimStyle.DimensionFit = this._objectReader.ReadBitShort();
}

//R2007+:
Expand Down
2 changes: 1 addition & 1 deletion ACadSharp/IO/DWG/DwgStreamWriters/DwgHeaderWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ public void Write()
//B : DIMUPT
this._writer.WriteBit(this._header.DimensionCursorUpdate);
//BS : DIMATFIT
this._writer.WriteBitShort(this._header.DimensionDimensionTextArrowFit);
this._writer.WriteBitShort((short)this._header.DimensionDimensionTextArrowFit);
}

//R2007 + Only:
Expand Down
10 changes: 6 additions & 4 deletions ACadSharp/IO/DXF/DxfStreamReader/DxfTablesSectionReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using ACadSharp.Tables;
using ACadSharp.Tables.Collections;
using ACadSharp.Types.Units;
using CSMath;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -313,7 +314,8 @@ private bool readDimensionStyle(CadTableEntryTemplate<DimensionStyle> template,
tmp.DIMBLK2_Name = this._reader.ValueAsString;
return true;
case 40:
template.CadObject.ScaleFactor = this._reader.ValueAsDouble;
//Somethimes is 0 but it shouldn't be allowed
template.CadObject.ScaleFactor = this._reader.ValueAsDouble <= 0 ? 1.0d : this._reader.ValueAsDouble;
return true;
case 41:
template.CadObject.ArrowSize = this._reader.ValueAsDouble;
Expand Down Expand Up @@ -343,7 +345,7 @@ private bool readDimensionStyle(CadTableEntryTemplate<DimensionStyle> template,
template.CadObject.FixedExtensionLineLength = this._reader.ValueAsDouble;
return true;
case 50:
template.CadObject.JoggedRadiusDimensionTransverseSegmentAngle = this._reader.ValueAsDouble;
template.CadObject.JoggedRadiusDimensionTransverseSegmentAngle = CSMath.MathUtils.DegToRad(this._reader.ValueAsDouble);
return true;
case 69:
template.CadObject.TextBackgroundFillMode = (DimensionTextBackgroundFillMode)this._reader.ValueAsShort;
Expand Down Expand Up @@ -490,13 +492,13 @@ private bool readDimensionStyle(CadTableEntryTemplate<DimensionStyle> template,
template.CadObject.AlternateUnitToleranceZeroHandling = (ZeroHandling)(byte)this._reader.ValueAsShort;
return true;
case 287:
template.CadObject.DimensionFit = (char)this._reader.ValueAsShort;
template.CadObject.DimensionFit = this._reader.ValueAsShort;
return true;
case 288:
template.CadObject.CursorUpdate = this._reader.ValueAsBool;
return true;
case 289:
template.CadObject.DimensionTextArrowFit = this._reader.ValueAsShort;
template.CadObject.DimensionTextArrowFit = (TextArrowFitType)this._reader.ValueAsShort;
return true;
case 290:
template.CadObject.IsExtensionLineLengthFixed = this._reader.ValueAsBool;
Expand Down
Loading

0 comments on commit 5bf7dd6

Please sign in to comment.