Skip to content

Commit

Permalink
mline nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
DomCR committed Sep 13, 2023
1 parent 3566966 commit 35fd2ce
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
15 changes: 14 additions & 1 deletion ACadSharp/Entities/MLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,18 @@ public partial class MLine : Entity
/// Do not modify this field without also updating the associated entry in the MLINESTYLE dictionary
/// </remarks>
[DxfCodeValue(DxfReferenceType.Handle | DxfReferenceType.Name, 340)]
public MLStyle MLStyle { get; set; }
public MLStyle MLStyle
{
get { return _style; }
set
{
if (value == null)
{
throw new System.ArgumentNullException(nameof(value), "Multi line style cannot be null");
}
this._style = value;
}
}

/// <summary>
/// Scale factor
Expand Down Expand Up @@ -72,6 +83,8 @@ public partial class MLine : Entity
[DxfCodeValue(DxfReferenceType.Count, 72)]
public List<Vertex> Vertices { get; set; } = new List<Vertex>();

private MLStyle _style = MLStyle.Default;

public MLine() : base() { }

public override CadObject Clone()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,11 @@ private void writeMLine(MLine mLine)
this._writer.Write(70, (short)mLine.Justification);
this._writer.Write(71, (short)mLine.Flags);
this._writer.Write(72, (short)mLine.Vertices.Count);
this._writer.Write(73, (short)mLine.MLStyle.Elements.Count);

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

this._writer.Write(10, mLine.StartPoint, map);

Expand Down
17 changes: 17 additions & 0 deletions ACadSharp/Objects/MLStyle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ namespace ACadSharp.Objects
[DxfSubClass(DxfSubclassMarker.MLineStyle)]
public partial class MLStyle : CadObject, INamedCadObject
{
/// <summary>
/// Default multiline style name
/// </summary>
public const string DefaultName = "Standard";

/// <summary>
/// Gets the default MLine style
/// </summary>
public static MLStyle Default { get { return new MLStyle(DefaultName); } }

/// <inheritdoc/>
public override ObjectType ObjectType => ObjectType.MLINESTYLE;

Expand Down Expand Up @@ -67,5 +77,12 @@ public partial class MLStyle : CadObject, INamedCadObject
/// </summary>
[DxfCodeValue(DxfReferenceType.Count, 71)]
public List<MLStyle.Element> Elements { get; } = new List<Element>();

internal MLStyle() { }

public MLStyle(string name)
{
this.Name = name;
}
}
}
4 changes: 2 additions & 2 deletions ACadSharp/Tables/Layer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ namespace ACadSharp.Tables
public class Layer : TableEntry
{
/// <summary>
/// Default layer 0, it will always exist in a file.
/// Default layer 0, it will always exist in a file
/// </summary>
public const string DefaultName = "0";

/// <summary>
/// Default layer in all cad formats, it will always exist in a file.
/// Default layer in all cad formats, it will always exist in a file
/// </summary>
public static Layer Default { get { return new Layer(DefaultName); } }

Expand Down

0 comments on commit 35fd2ce

Please sign in to comment.