diff --git a/src/ACadSharp.Tests/IO/LocalSampleTests.cs b/src/ACadSharp.Tests/IO/LocalSampleTests.cs index ccc68222e..b791b9c0b 100644 --- a/src/ACadSharp.Tests/IO/LocalSampleTests.cs +++ b/src/ACadSharp.Tests/IO/LocalSampleTests.cs @@ -48,7 +48,6 @@ public void ReadUserDxf(FileModel test) return; CadDocument doc = DxfReader.Read(test.Path, this.onNotification); - doc.Header.Version = ACadVersion.AC1032; } [Theory] @@ -81,4 +80,4 @@ public void ReadStressFiles(FileModel test) Assert.True(stopwatch.Elapsed.TotalSeconds < 10); } } -} +} \ No newline at end of file diff --git a/src/ACadSharp/ACadSharp.csproj b/src/ACadSharp/ACadSharp.csproj index 8dad013e4..feca81d5e 100644 --- a/src/ACadSharp/ACadSharp.csproj +++ b/src/ACadSharp/ACadSharp.csproj @@ -17,7 +17,7 @@ true README.md - 1.1.19 + 1.1.20 ../nupkg diff --git a/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs b/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs index 184869020..70af34200 100644 --- a/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs +++ b/src/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs @@ -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": @@ -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(); @@ -3144,9 +3142,9 @@ 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(); @@ -3154,6 +3152,7 @@ private CadTemplate readMultiLeader() 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(); @@ -3161,6 +3160,7 @@ private CadTemplate readMultiLeader() 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 @@ -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(); @@ -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) @@ -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? @@ -3556,25 +3561,25 @@ 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(); @@ -3582,15 +3587,14 @@ private CadTemplate readMultiLeaderStyle() 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 @@ -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; } diff --git a/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Entities.cs b/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Entities.cs index 8fc41fb34..9018b2a9c 100644 --- a/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Entities.cs +++ b/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Entities.cs @@ -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); @@ -2449,4 +2449,4 @@ private void writeChildEntities(IEnumerable entities, Seqend seqend) } } } -} +} \ No newline at end of file diff --git a/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Objects.cs b/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Objects.cs index 5066fcfa0..2001a45e3 100644 --- a/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Objects.cs +++ b/src/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Objects.cs @@ -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: @@ -532,14 +530,12 @@ 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) @@ -547,7 +543,7 @@ private void writeMultiLeaderStyle(MultiLeaderStyle mLeaderStyle) // 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) @@ -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? @@ -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 @@ -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 @@ -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) diff --git a/src/ACadSharp/IO/Templates/CadMLeaderStyleTemplate.cs b/src/ACadSharp/IO/Templates/CadMLeaderStyleTemplate.cs index 5467e9c86..b02ba05da 100644 --- a/src/ACadSharp/IO/Templates/CadMLeaderStyleTemplate.cs +++ b/src/ACadSharp/IO/Templates/CadMLeaderStyleTemplate.cs @@ -5,15 +5,17 @@ namespace ACadSharp.IO.Templates { internal class CadMLeaderStyleTemplate : CadTemplate { - 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) { @@ -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; @@ -38,4 +42,4 @@ public override void Build(CadDocumentBuilder builder) } } } -} +} \ No newline at end of file