Skip to content
Open
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
22 changes: 22 additions & 0 deletions src/ACadSharp.Tests/Tables/TextStyleTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using ACadSharp.Tables;
using ACadSharp.Tables.Collections;
using Xunit;

namespace ACadSharp.Tests.Tables
{
public class TextStyleTests : TableEntryCommonTests<TextStyle>
{
[Fact]
public void DefaultEntryTest()
{
var def = TextStyle.Default;

Assert.True(def.Flags.HasFlag(StyleFlags.XrefDependent));
}

protected override Table<TextStyle> getTable(CadDocument document)
{
return document.TextStyles;
}
}
}
17 changes: 16 additions & 1 deletion src/ACadSharp/Classes/DxfClassCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,20 @@ public static void UpdateDxfClasses(CadDocument doc)
WasZombie = false,
});

//AcDbRasterImageDef
doc.Classes.AddOrUpdate(new DxfClass
{
ApplicationName = "ISM",
CppClassName = DxfSubclassMarker.RasterImageDefReactor,
ClassNumber = (short)(500 + doc.Classes.Count),
DwgVersion = (ACadVersion)20,
DxfName = DxfFileToken.ObjectImageDefinitionReactor,
ItemClassId = 499,
MaintenanceVersion = 0,
ProxyFlags = ProxyFlags.EraseAllowed,
WasZombie = false,
});

//AcDbColor
doc.Classes.AddOrUpdate(new DxfClass
{
Expand Down Expand Up @@ -484,7 +498,8 @@ public static void UpdateDxfClasses(CadDocument doc)
});

//AcDbMLeaderObjectContextData
doc.Classes.AddOrUpdate(new DxfClass {
doc.Classes.AddOrUpdate(new DxfClass
{
CppClassName = DxfSubclassMarker.MultiLeaderObjectContextData,
ClassNumber = (short)(500 + doc.Classes.Count),
DwgVersion = ACadVersion.MC0_0,
Expand Down
6 changes: 3 additions & 3 deletions src/ACadSharp/Header/CadHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,7 @@ public ZeroHandling DimensionZeroHandling
/// System variable 3DDWFPREC
/// </remarks>
[CadSystemVariable("$3DDWFPREC", 40)]
public double Dw3DPrecision { get; set; }
public double Dw3DPrecision { get; set; } = 2.0d;

/// <remarks>
/// System variable DWFFRAME
Expand Down Expand Up @@ -1961,7 +1961,7 @@ public double FacetResolution
/// System variable LENSLENGTH
/// </remarks>
[CadSystemVariable("$LENSLENGTH", 40)]
public double LensLength { get; set; }
public double LensLength { get; set; } = 50.0d;

/// <summary>
/// Controls whether you can create objects outside the grid limits.
Expand Down Expand Up @@ -2829,7 +2829,7 @@ public short SurfaceIsolineCount
/// System variable PSOLWIDTH
/// </remarks>
[CadSystemVariable("$PSOLWIDTH", 40)]
public double SweptSolidWidth { get; set; }
public double SweptSolidWidth { get; set; } = 5.0d;

/// <summary>
/// Sets the default text height when creating new text objects.
Expand Down
2 changes: 1 addition & 1 deletion src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5596,7 +5596,7 @@ 1024 512
}

template.ElementTemplates.Add(elementTemplate);
mlineStyle.Elements.Add(element);
mlineStyle.AddElement(element);
}

return template;
Expand Down
4 changes: 2 additions & 2 deletions src/ACadSharp/IO/DWG/DwgStreamWriters/DwgHeaderWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public void Write()
this._writer.HandleReference(DwgReferenceType.HardPointer, this._header.CurrentDimensionStyle);

//H: CMLSTYLE (hard pointer)
this._writer.HandleReference(DwgReferenceType.HardPointer, null);
this._writer.HandleReference(DwgReferenceType.HardPointer, this._header.CurrentMLineStyle);

//R2000+ Only:
if (this.R2000Plus)
Expand Down Expand Up @@ -843,7 +843,7 @@ public void Write()
//H: DICTIONARY (MATERIALS) (hard pointer)
this._writer.HandleReference(DwgReferenceType.HardPointer, null);
//H: DICTIONARY (COLORS) (hard pointer)
this._writer.HandleReference(DwgReferenceType.HardPointer, null);
this._writer.HandleReference(DwgReferenceType.HardPointer, this._document.Colors);
}

//R2007 +:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ private void writeMLineStyle(MLineStyle mlineStyle)
this._writer.WriteBitDouble(mlineStyle.EndAngle);

//linesinstyle RC Number of lines in this style
this._writer.WriteByte((byte)mlineStyle.Elements.Count);
this._writer.WriteByte((byte)mlineStyle.Elements.Count());
foreach (MLineStyle.Element element in mlineStyle.Elements)
{
//Offset BD Offset of this segment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ protected void writeMLineStyle(MLineStyle style)

this._writer.Write(51, style.StartAngle, map);
this._writer.Write(52, style.EndAngle, map);
this._writer.Write(71, (short)style.Elements.Count, map);
this._writer.Write(71, (short)style.Elements.Count(), map);
foreach (MLineStyle.Element element in style.Elements)
{
this._writer.Write(49, element.Offset, map);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ private void writeMLine(MLine mLine)

if (mLine.Style != null)
{
this._writer.Write(73, (short)mLine.Style.Elements.Count);
this._writer.Write(73, (short)mLine.Style.Elements.Count());
}

this._writer.Write(10, mLine.StartPoint, map);
Expand Down
1 change: 0 additions & 1 deletion src/ACadSharp/Objects/CadDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ public static void CreateDefaultEntries(CadDictionary root)
scales.TryAdd(new Scale { Name = "B6", PaperUnits = 100.0, DrawingUnits = 1.0, IsUnitScale = false });

root.TryAdd(new CadDictionary(AcadVisualStyle));
root.TryAdd(new CadDictionary(AcadFieldList));
root.TryAdd(new CadDictionary(AcadImageDict));
}

Expand Down
53 changes: 45 additions & 8 deletions src/ACadSharp/Objects/MLineStyle.Element.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ACadSharp.Attributes;
using ACadSharp.Extensions;
using ACadSharp.Tables;

namespace ACadSharp.Objects
Expand All @@ -8,22 +9,58 @@ public partial class MLineStyle
public class Element
{
/// <summary>
/// Element offset
/// Element color.
/// </summary>
[DxfCodeValue(62)]
public Color Color { get; set; } = Color.ByLayer;

/// <summary>
/// Element linetype.
/// </summary>
[DxfCodeValue(6)]
public LineType LineType
{
get => _lineType;
set
{
this._lineType = CadObject.updateCollection(value, this.Owner?.Document?.LineTypes);
}
}

/// <summary>
/// Element offset.
/// </summary>
[DxfCodeValue(49)]
public double Offset { get; set; }

/// <summary>
/// Element color
/// Line type where this segment belongs.
/// </summary>
[DxfCodeValue(62)]
public Color Color { get; set; } = Color.ByBlock;
public MLineStyle Owner { get; internal set; }

private LineType _lineType = LineType.ByLayer;

/// <summary>
/// Element linetype
/// Clone the current segment.
/// </summary>
[DxfCodeValue(6)]
public LineType LineType { get; set; } = LineType.ByLayer;
/// <returns></returns>
public MLineStyle.Element Clone()
{
Element clone = MemberwiseClone() as Element;
clone.Owner = null;
clone._lineType = (LineType)(this.LineType?.Clone());
return clone;
}

internal void AssignDocument(CadDocument doc)
{
this._lineType = CadObject.updateCollection(this._lineType, doc.LineTypes);
}

internal void UnassignDocument()
{
this._lineType = this._lineType.CloneTyped();
}
}
}
}
}
Loading