Skip to content
Merged
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
3 changes: 1 addition & 2 deletions src/ACadSharp.Tests/IO/LocalSampleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public void ReadUserDxf(FileModel test)
return;

CadDocument doc = DxfReader.Read(test.Path, this.onNotification);
doc.Header.Version = ACadVersion.AC1032;
}

[Theory]
Expand Down Expand Up @@ -81,4 +80,4 @@ public void ReadStressFiles(FileModel test)
Assert.True(stopwatch.Elapsed.TotalSeconds < 10);
}
}
}
}
2 changes: 1 addition & 1 deletion src/ACadSharp/ACadSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<Version>1.1.19</Version>
<Version>1.1.20</Version>
<PackageOutputPath>../nupkg</PackageOutputPath>
</PropertyGroup>

Expand Down
68 changes: 39 additions & 29 deletions src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1054,10 +1054,6 @@ private CadTemplate readUnlistedType(short classNumber)
template = this.readMultiLeader();
break;
case "MLEADERSTYLE":
if (!this.R2010Plus) {
this.notify($"MLEADERSTYLE is not supported for {this._version}.", NotificationType.Warning);
return null;
}
template = this.readMultiLeaderStyle();
break;
case "PDFDEFINITION":
Expand Down Expand Up @@ -3129,12 +3125,14 @@ private CadTemplate readMultiLeader()
// Multileader Common data
// 340 Leader StyleId (handle)
template.LeaderStyleHandle = this.handleReference();

//BL 90 Property Override Flags (int32)
mLeader.PropertyOverrideFlags = (MultiLeaderPropertyOverrideFlags)this._objectReader.ReadBitLong();
//BS 170 LeaderLineType (short)
mLeader.PathType = (MultiLeaderPathType)this._objectReader.ReadBitShort();
//CMC 91 Leade LineColor (Color)
mLeader.LineColor = this._mergedReaders.ReadCmColor();

//H 341 LeaderLineTypeID (handle/LineType)
template.LeaderLineTypeHandle = this.handleReference();

Expand All @@ -3144,23 +3142,25 @@ private CadTemplate readMultiLeader()
mLeader.EnableLanding = this._objectReader.ReadBit();
//B 291 Enable Dogleg
mLeader.EnableDogleg = this._objectReader.ReadBit();

// 41 Dogleg Length / Landing distance
mLeader.LandingDistance = this._objectReader.ReadBitDouble();

// 342 Arrowhead ID
template.ArrowheadHandle = this.handleReference();

// 42 Arrowhead Size
mLeader.ArrowheadSize = this._objectReader.ReadBitDouble();
//BS 172 Content Type
mLeader.ContentType = (LeaderContentType)this._objectReader.ReadBitShort();

//H 343 Text Style ID (handle/TextStyle)
template.MTextStyleHandle = this.handleReference();

// 173 Text Left Attachment Type
mLeader.TextLeftAttachment = (TextAttachmentType)this._objectReader.ReadBitShort();
// 95 Text Right Attachment Type
mLeader.TextRightAttachment = (TextAttachmentType)this._objectReader.ReadBitShort();

// 174 Text Angle Type
mLeader.TextAngle = (TextAngleType)this._objectReader.ReadBitShort();
// 175 Text Alignment Type
Expand Down Expand Up @@ -3523,8 +3523,11 @@ private CadTemplate readMultiLeaderStyle()

this.readCommonNonEntityData(template);

// BS 179 Version expected: 2
var version = this._objectReader.ReadBitShort();
if (this.R2010Plus)
{
// BS 179 Version expected: 2
var version = this._objectReader.ReadBitShort();
}

// BS 170 Content type (see paragraph on LEADER for more details).
mLeaderStyle.ContentType = (LeaderContentType)this._objectReader.ReadBitShort();
Expand All @@ -3533,7 +3536,7 @@ private CadTemplate readMultiLeaderStyle()
// BS 172 Draw leader order (0 = draw leader head first, 1 = draw leader tail first)
mLeaderStyle.LeaderDrawOrder = (LeaderDrawOrderType)this._objectReader.ReadBitShort();
// BL 90 Maximum number of points for leader
mLeaderStyle.MaxLeaderSegmentsPoints = this._objectReader.ReadBitShort();
mLeaderStyle.MaxLeaderSegmentsPoints = this._objectReader.ReadBitLong();
// BD 40 First segment angle (radians)
mLeaderStyle.FirstSegmentAngleConstraint = this._objectReader.ReadBitDouble();
// BD 41 Second segment angle (radians)
Expand All @@ -3542,8 +3545,10 @@ private CadTemplate readMultiLeaderStyle()
mLeaderStyle.PathType = (MultiLeaderPathType)this._objectReader.ReadBitShort();
// CMC 91 Leader line color
mLeaderStyle.LineColor = this._mergedReaders.ReadCmColor();

// H 340 Leader line type handle (hard pointer)
template.LeaderLineTypeHandle = this.handleReference();

// BL 92 Leader line weight
mLeaderStyle.LeaderLineWeight = (LineweightType)this._objectReader.ReadBitLong();
// B 290 Is landing enabled?
Expand All @@ -3556,41 +3561,40 @@ private CadTemplate readMultiLeaderStyle()
mLeaderStyle.LandingDistance = this._objectReader.ReadBitDouble();
// TV 3 Style description
mLeaderStyle.Description = this._mergedReaders.ReadVariableText();

// H 341 Arrow head block handle (hard pointer)
template.ArrowheadHandle = this.handleReference();

// BD 44 Arrow head size
mLeaderStyle.ArrowheadSize = this._objectReader.ReadBitDouble();
// TV 300 Text default
mLeaderStyle.DefaultTextContents = this._mergedReaders.ReadVariableText();

// H 342 Text style handle (hard pointer)
template.MTextStyleHandle = this.handleReference();

// BS 174 Left attachment (see paragraph on LEADER for more details).
mLeaderStyle.TextLeftAttachment = (TextAttachmentType)this._objectReader.ReadBitShort();
// BS 178 Right attachment (see paragraph on LEADER for more details).
mLeaderStyle.TextRightAttachment = (TextAttachmentType)this._objectReader.ReadBitShort();
if (this.R2010Plus)
{// IF IsNewFormat OR DXF file
// BS 175 Text angle type (see paragraph on LEADER for more details).
mLeaderStyle.TextAngle = (TextAngleType)this._objectReader.ReadBitShort();

} // END IF IsNewFormat OR DXF file
// BS 176 Text alignment type
// BS 175 Text angle type (see paragraph on LEADER for more details).
mLeaderStyle.TextAngle = (TextAngleType)this._objectReader.ReadBitShort();
// BS 176 Text alignment type
mLeaderStyle.TextAlignment = (TextAlignmentType)this._objectReader.ReadBitShort();
// CMC 93 Text color
mLeaderStyle.TextColor = this._mergedReaders.ReadCmColor();
// BD 45 Text height
mLeaderStyle.TextHeight = this._objectReader.ReadBitDouble();
// B 292 Text frame enabled
mLeaderStyle.TextFrame = this._objectReader.ReadBit();
if (this.R2010Plus)
{// IF IsNewFormat OR DXF file
// B 297 Always align text left
mLeaderStyle.TextAlignAlwaysLeft = this._objectReader.ReadBit();
}// END IF IsNewFormat OR DXF file
// BD 46 Align space
// B 297 Always align text left
mLeaderStyle.TextAlignAlwaysLeft = this._objectReader.ReadBit();
// BD 46 Align space
mLeaderStyle.AlignSpace = this._objectReader.ReadBitDouble();

// H 343 Block handle (hard pointer)
template.BlockContentHandle = this.handleReference();

// CMC 94 Block color
mLeaderStyle.BlockContentColor = this._mergedReaders.ReadCmColor();
// 3BD 47,49,140 Block scale vector
Expand All @@ -3615,15 +3619,21 @@ private CadTemplate readMultiLeaderStyle()
// BD 143 Break size
mLeaderStyle.BreakGapSize = this._objectReader.ReadBitDouble();

// BS 271 Attachment direction (see paragraph on LEADER for more details).
mLeaderStyle.TextAttachmentDirection = (TextAttachmentDirectionType)this._objectReader.ReadBitShort();
// BS 273 Top attachment (see paragraph on LEADER for more details).
mLeaderStyle.TextBottomAttachment = (TextAttachmentType)this._objectReader.ReadBitShort();
// BS 272 Bottom attachment (see paragraph on LEADER for more details).
mLeaderStyle.TextTopAttachment = (TextAttachmentType)this._objectReader.ReadBitShort();
if (this.R2010Plus)
{
// BS 271 Attachment direction (see paragraph on LEADER for more details).
mLeaderStyle.TextAttachmentDirection = (TextAttachmentDirectionType)this._objectReader.ReadBitShort();
// BS 273 Top attachment (see paragraph on LEADER for more details).
mLeaderStyle.TextBottomAttachment = (TextAttachmentType)this._objectReader.ReadBitShort();
// BS 272 Bottom attachment (see paragraph on LEADER for more details).
mLeaderStyle.TextTopAttachment = (TextAttachmentType)this._objectReader.ReadBitShort();
}

// B 298 Undocumented, found in DXF
mLeaderStyle.UnknownFlag298 = this._objectReader.ReadBit();
if (this.R2013Plus)
{
// B 298 Undocumented, found in DXF
mLeaderStyle.UnknownFlag298 = this._objectReader.ReadBit();
}

return template;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ private void writeMultiLeader(MultiLeader multiLeader)
this._writer.WriteBitLong((int)multiLeader.PropertyOverrideFlags);
// 170 LeaderLineType (short)
this._writer.WriteBitShort((short)multiLeader.PathType);
// 91 Leade LineColor (Color)
// 91 Leader LineColor (Color)
this._writer.WriteCmColor(multiLeader.LineColor);
// 341 LeaderLineTypeID (handle/LineType)
this._writer.HandleReference(DwgReferenceType.HardPointer, multiLeader.LeaderLineType);
Expand Down Expand Up @@ -2449,4 +2449,4 @@ private void writeChildEntities(IEnumerable<Entity> entities, Seqend seqend)
}
}
}
}
}
60 changes: 30 additions & 30 deletions src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Objects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ private void writeObject(CadObject obj)
{
case EvaluationGraph:
case Material:
case MultiLeaderAnnotContext:
case MultiLeaderStyle when !this.R2010Plus:
case SortEntitiesTable:
case UnknownNonGraphicalObject:
case VisualStyle:
Expand Down Expand Up @@ -532,22 +530,20 @@ private void writeMLineStyle(MLineStyle mlineStyle)

private void writeMultiLeaderStyle(MultiLeaderStyle mLeaderStyle)
{
if (!R2010Plus)
if (this.R2010Plus)
{
return;
// BS 179 Version expected: 2
this._writer.WriteBitShort(2);
}

// BS 179 Version expected: 2
this._writer.WriteBitShort(2);

// BS 170 Content type (see paragraph on LEADER for more details).
this._writer.WriteBitShort((short)mLeaderStyle.ContentType);
// BS 171 Draw multi-leader order (0 = draw content first, 1 = draw leader first)
this._writer.WriteBitShort((short)mLeaderStyle.MultiLeaderDrawOrder);
// BS 172 Draw leader order (0 = draw leader head first, 1 = draw leader tail first)
this._writer.WriteBitShort((short)mLeaderStyle.LeaderDrawOrder);
// BL 90 Maximum number of points for leader
this._writer.WriteBitShort((short)mLeaderStyle.MaxLeaderSegmentsPoints);
this._writer.WriteBitLong((short)mLeaderStyle.MaxLeaderSegmentsPoints);
// BD 40 First segment angle (radians)
this._writer.WriteBitDouble(mLeaderStyle.FirstSegmentAngleConstraint);
// BD 41 Second segment angle (radians)
Expand All @@ -556,8 +552,10 @@ private void writeMultiLeaderStyle(MultiLeaderStyle mLeaderStyle)
this._writer.WriteBitShort((short)mLeaderStyle.PathType);
// CMC 91 Leader line color
this._writer.WriteCmColor(mLeaderStyle.LineColor);

// H 340 Leader line type handle (hard pointer)
this._writer.HandleReference(DwgReferenceType.HardPointer, mLeaderStyle.LeaderLineType);

// BL 92 Leader line weight
this._writer.WriteBitLong((short)mLeaderStyle.LeaderLineWeight);
// B 290 Is landing enabled?
Expand All @@ -570,25 +568,24 @@ private void writeMultiLeaderStyle(MultiLeaderStyle mLeaderStyle)
this._writer.WriteBitDouble(mLeaderStyle.LandingDistance);
// TV 3 Style description
this._writer.WriteVariableText(mLeaderStyle.Description);

// H 341 Arrow head block handle (hard pointer)
this._writer.HandleReference(DwgReferenceType.HardPointer, mLeaderStyle.Arrowhead);

// BD 44 Arrow head size
this._writer.WriteBitDouble(mLeaderStyle.ArrowheadSize);
// TV 300 Text default
this._writer.WriteVariableText(mLeaderStyle.DefaultTextContents);

// H 342 Text style handle (hard pointer)
this._writer.HandleReference(DwgReferenceType.HardPointer, mLeaderStyle.TextStyle);

// BS 174 Left attachment (see paragraph on LEADER for more details).
this._writer.WriteBitShort((short)mLeaderStyle.TextLeftAttachment);
// BS 178 Right attachment (see paragraph on LEADER for more details).
this._writer.WriteBitShort((short)mLeaderStyle.TextRightAttachment);
if (R2010Plus)
{
// IF IsNewFormat OR DXF file
// BS 175 Text angle type (see paragraph on LEADER for more details).
this._writer.WriteBitShort((short)mLeaderStyle.TextAngle);
// END IF IsNewFormat OR DXF file
}
// BS 175 Text angle type (see paragraph on LEADER for more details).
this._writer.WriteBitShort((short)mLeaderStyle.TextAngle);
// BS 176 Text alignment type
this._writer.WriteBitShort((short)mLeaderStyle.TextAlignment);
// CMC 93 Text color
Expand All @@ -597,17 +594,14 @@ private void writeMultiLeaderStyle(MultiLeaderStyle mLeaderStyle)
this._writer.WriteBitDouble(mLeaderStyle.TextHeight);
// B 292 Text frame enabled
this._writer.WriteBit(mLeaderStyle.TextFrame);
if (R2010Plus)
{
// IF IsNewFormat OR DXF file
// B 297 Always align text left
this._writer.WriteBit(mLeaderStyle.TextAlignAlwaysLeft);
// END IF IsNewFormat OR DXF file
}
// B 297 Always align text left
this._writer.WriteBit(mLeaderStyle.TextAlignAlwaysLeft);
// BD 46 Align space
this._writer.WriteBitDouble(mLeaderStyle.AlignSpace);

// H 343 Block handle (hard pointer)
this._writer.HandleReference(DwgReferenceType.HardPointer, mLeaderStyle.BlockContent);

// CMC 94 Block color
this._writer.WriteCmColor(mLeaderStyle.BlockContentColor);
// 3BD 47,49,140 Block scale vector
Expand All @@ -632,15 +626,21 @@ private void writeMultiLeaderStyle(MultiLeaderStyle mLeaderStyle)
// BD 143 Break size
this._writer.WriteBitDouble(mLeaderStyle.BreakGapSize);

// BS 271 Attachment direction (see paragraph on LEADER for more details).
this._writer.WriteBitShort((short)mLeaderStyle.TextAttachmentDirection);
// BS 273 Top attachment (see paragraph on LEADER for more details).
this._writer.WriteBitShort((short)mLeaderStyle.TextBottomAttachment);
// BS 272 Bottom attachment (see paragraph on LEADER for more details).
this._writer.WriteBitShort((short)mLeaderStyle.TextTopAttachment);
if (this.R2010Plus)
{
// BS 271 Attachment direction (see paragraph on LEADER for more details).
this._writer.WriteBitShort((short)mLeaderStyle.TextAttachmentDirection);
// BS 273 Top attachment (see paragraph on LEADER for more details).
this._writer.WriteBitShort((short)mLeaderStyle.TextBottomAttachment);
// BS 272 Bottom attachment (see paragraph on LEADER for more details).
this._writer.WriteBitShort((short)mLeaderStyle.TextTopAttachment);
}

// B 298 Undocumented, found in DXF
this._writer.WriteBit(mLeaderStyle.UnknownFlag298);
if (this.R2013Plus)
{
// B 298 Undocumented, found in DXF
this._writer.WriteBit(mLeaderStyle.UnknownFlag298);
}
}

private void writePlotSettings(PlotSettings plot)
Expand Down
20 changes: 12 additions & 8 deletions src/ACadSharp/IO/Templates/CadMLeaderStyleTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ namespace ACadSharp.IO.Templates
{
internal class CadMLeaderStyleTemplate : CadTemplate<MultiLeaderStyle>
{
public CadMLeaderStyleTemplate(MultiLeaderStyle entry) : base(entry) { }
public ulong ArrowheadHandle { get; internal set; }

public ulong LeaderLineTypeHandle { get; internal set; }
public ulong BlockContentHandle { get; internal set; }

public ulong ArrowheadHandle { get; internal set; }
public ulong LeaderLineTypeHandle { get; internal set; }

public ulong MTextStyleHandle { get; internal set; }

public ulong BlockContentHandle { get; internal set; }
public CadMLeaderStyleTemplate(MultiLeaderStyle entry) : base(entry)
{
}

public override void Build(CadDocumentBuilder builder)
{
Expand All @@ -24,9 +26,11 @@ public override void Build(CadDocumentBuilder builder)
this.CadObject.LeaderLineType = lineType;
}

//if (builder.TryGetCadObject(this.ArrowheadHandle, out Arr arrowhead)) {
// this.CadObject.Arrowhead = arrowhead;
//}
if (builder.TryGetCadObject(this.ArrowheadHandle, out BlockRecord arrowhead))
{
this.CadObject.Arrowhead = arrowhead;
}

if (builder.TryGetCadObject(this.MTextStyleHandle, out TextStyle textStyle))
{
this.CadObject.TextStyle = textStyle;
Expand All @@ -38,4 +42,4 @@ public override void Build(CadDocumentBuilder builder)
}
}
}
}
}