From 778b99ff3461baae4487031762393be52d717cae Mon Sep 17 00:00:00 2001 From: DomCR Date: Wed, 20 Sep 2023 07:51:10 +0200 Subject: [PATCH 1/8] unignore --- .../IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs b/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs index c5b8f638..f863b778 100644 --- a/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs +++ b/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs @@ -16,7 +16,6 @@ protected void writeEntity(T entity) case Hatch: case Mesh: case MLine: - case MText: case Solid3D: this.notify($"Entity type not implemented : {entity.GetType().FullName}", NotificationType.NotImplemented); return; From d98e4e554f31852ffb366821d6b68187e8d2f674 Mon Sep 17 00:00:00 2001 From: DomCR Date: Sun, 5 Nov 2023 19:49:13 +0100 Subject: [PATCH 2/8] Layer flags fix --- ACadSharp.Tests/IO/DWG/DwgWriterSingleObjectTests.cs | 10 ++++++++++ .../DWG/DwgStreamWriters/DwgObjectWriter.Entities.cs | 4 +++- ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.cs | 11 +++++++---- ACadSharp/Tables/Layer.cs | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ACadSharp.Tests/IO/DWG/DwgWriterSingleObjectTests.cs b/ACadSharp.Tests/IO/DWG/DwgWriterSingleObjectTests.cs index 45e71c22..293bd7c8 100644 --- a/ACadSharp.Tests/IO/DWG/DwgWriterSingleObjectTests.cs +++ b/ACadSharp.Tests/IO/DWG/DwgWriterSingleObjectTests.cs @@ -40,6 +40,15 @@ public void DefaultLayer() this.Document.Layers.Add(new ACadSharp.Tables.Layer("default_layer")); } + public void SingleMText() + { + MText mtext = new MText(); + + mtext.Value = "HELLO I'm an MTEXT"; + + this.Document.Entities.Add(mtext); + } + public void Deserialize(IXunitSerializationInfo info) { this.Name = info.GetValue(nameof(this.Name)); @@ -68,6 +77,7 @@ static DwgWriterSingleObjectTests() Data.Add(new(nameof(SingleCaseGenerator.Empty))); Data.Add(new(nameof(SingleCaseGenerator.SinglePoint))); Data.Add(new(nameof(SingleCaseGenerator.DefaultLayer))); + Data.Add(new(nameof(SingleCaseGenerator.SingleMText))); } [Theory()] diff --git a/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Entities.cs b/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Entities.cs index 5e817e08..4e054526 100644 --- a/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Entities.cs +++ b/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Entities.cs @@ -18,7 +18,6 @@ private void writeEntity(Entity entity) switch (entity) { case AttributeEntity: - case MText: case Shape: case Solid3D: case MultiLeader: @@ -95,6 +94,9 @@ private void writeEntity(Entity entity) case MLine mLine: this.writeMLine(mLine); break; + case MText mtext: + this.writeMText(mtext); + break; case Point p: this.writePoint(p); break; diff --git a/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.cs b/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.cs index aed5b746..c2d1551e 100644 --- a/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.cs +++ b/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.cs @@ -429,17 +429,20 @@ private void writeLayer(Layer layer) short values = (short)(CadUtils.ToIndex(layer.LineWeight) << 5); //contains frozen (1 bit), - values |= (short)LayerFlags.Frozen; + if (layer.Flags.HasFlag(LayerFlags.Frozen)) + values |= 0b1; //on (2 bit) - if (layer.IsOn) + if (!layer.IsOn) values |= 0b10; //frozen by default in new viewports (4 bit) - values |= (short)LayerFlags.FrozenNewViewports; + if (layer.Flags.HasFlag(LayerFlags.Frozen)) + values |= 0b100; //locked (8 bit) - values |= (short)LayerFlags.Locked; + if (layer.Flags.HasFlag(LayerFlags.Locked)) + values |= 0b1000; //plotting flag (16 bit), if (layer.PlotFlag) diff --git a/ACadSharp/Tables/Layer.cs b/ACadSharp/Tables/Layer.cs index f8b7bff6..1db7ae4f 100644 --- a/ACadSharp/Tables/Layer.cs +++ b/ACadSharp/Tables/Layer.cs @@ -77,7 +77,7 @@ public LineType LineType /// Specifies if the layer is plottable. /// [DxfCodeValue(290)] - public bool PlotFlag { get; set; } + public bool PlotFlag { get; set; } = true; /// /// Specifies the lineweight of an individual object or the default lineweight for the drawing. From 44614632853d167f6cf532993144d263dc96aba7 Mon Sep 17 00:00:00 2001 From: DomCR Date: Sun, 5 Nov 2023 20:02:11 +0100 Subject: [PATCH 3/8] mtext defaults --- ACadSharp/Entities/MText.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ACadSharp/Entities/MText.cs b/ACadSharp/Entities/MText.cs index ecba4cfb..77a95482 100644 --- a/ACadSharp/Entities/MText.cs +++ b/ACadSharp/Entities/MText.cs @@ -72,7 +72,7 @@ public double Height /// Attachment point /// [DxfCodeValue(71)] - public AttachmentPointType AttachmentPoint { get; set; } + public AttachmentPointType AttachmentPoint { get; set; } = AttachmentPointType.TopLeft; /// /// Drawing direction @@ -187,7 +187,7 @@ public double Rotation /// Percentage of default (3-on-5) line spacing to be applied.Valid values range from 0.25 to 4.00 /// [DxfCodeValue(44)] - public double LineSpacing { get; set; } + public double LineSpacing { get; set; } = 1.0; /// /// Background fill setting @@ -221,11 +221,11 @@ public double Rotation public TextColumn Column { get; set; } = new TextColumn(); - public bool IsAnnotative { get; set; } + public bool IsAnnotative { get; set; } = false; - private double _height = 0.0; + private double _height = 1.0; - private XYZ _alignmentPoint = XYZ.Zero; + private XYZ _alignmentPoint = XYZ.AxisX; private double _rotation = 0.0; From 528bc9cd564d87b1cfd022b1fc54ad361290baba Mon Sep 17 00:00:00 2001 From: DomCR Date: Sun, 5 Nov 2023 20:20:55 +0100 Subject: [PATCH 4/8] simplify mtext write operation --- .../DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs b/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs index 3435a829..0dade031 100644 --- a/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs +++ b/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs @@ -17,6 +17,7 @@ protected void writeEntity(T entity) case MLine: case Solid3D: case MultiLeader: + case Wipeout: this.notify($"Entity type not implemented : {entity.GetType().FullName}", NotificationType.NotImplemented); return; } @@ -605,6 +606,7 @@ private void writeMText(MText mtext) this._writer.Write(40, mtext.Height, map); this._writer.Write(41, mtext.RectangleWidth, map); + this._writer.Write(44, mtext.LineSpacing, map); if (this.Version >= ACadVersion.AC1021) { @@ -614,9 +616,9 @@ private void writeMText(MText mtext) this._writer.Write(71, (short)mtext.AttachmentPoint, map); this._writer.Write(72, (short)mtext.DrawingDirection, map); - this._writer.Write(1, mtext.Value, map); + this._writer.Write(1, mtext.Value.Replace("\n", "^J"), map); - if (string.IsNullOrEmpty(mtext.AdditionalText)) + if (!string.IsNullOrEmpty(mtext.AdditionalText)) { for (int i = 0; i < mtext.AdditionalText.Length; i += 250) this._writer.Write(3, mtext.AdditionalText.Substring(i, 250), map); @@ -628,6 +630,8 @@ private void writeMText(MText mtext) this._writer.Write(11, mtext.AlignmentPoint, map); + return; + if (this.Version >= ACadVersion.AC1018) { this._writer.Write(90, (int)mtext.BackgroundFillFlags, map); @@ -640,7 +644,6 @@ private void writeMText(MText mtext) } } - this._writer.Write(44, mtext.LineSpacing, map); this._writer.Write(45, mtext.BackgroundScale, map); this._writer.Write(210, mtext.Normal, map); From 4277147d0cee1439dea2cac2a87ec7bcb03d9488 Mon Sep 17 00:00:00 2001 From: DomCR Date: Tue, 14 Nov 2023 11:54:45 +0100 Subject: [PATCH 5/8] MText dxf writer --- ACadSharp/Entities/MText.cs | 11 +------ .../DxfStreamReader/DxfSectionReaderBase.cs | 4 +-- .../DxfSectionWriterBase.Entities.cs | 30 +++++++------------ 3 files changed, 13 insertions(+), 32 deletions(-) diff --git a/ACadSharp/Entities/MText.cs b/ACadSharp/Entities/MText.cs index 77a95482..424c5a79 100644 --- a/ACadSharp/Entities/MText.cs +++ b/ACadSharp/Entities/MText.cs @@ -81,20 +81,11 @@ public double Height public DrawingDirectionType DrawingDirection { get; set; } /// - /// Specifies the text string for the entity. + /// Specifies the text string for the entity /// - /// - /// The maximum length is 256 characters. - /// [DxfCodeValue(1)] public string Value { get; set; } = string.Empty; - /// - /// Additional text (always in 250-character chunks) - /// - [DxfCodeValue(DxfReferenceType.Optional, 3)] - public string AdditionalText { get; set; } = string.Empty; - /// /// Style of this text entity. /// diff --git a/ACadSharp/IO/DXF/DxfStreamReader/DxfSectionReaderBase.cs b/ACadSharp/IO/DXF/DxfStreamReader/DxfSectionReaderBase.cs index f0c37f5a..6b1b0e3b 100644 --- a/ACadSharp/IO/DXF/DxfStreamReader/DxfSectionReaderBase.cs +++ b/ACadSharp/IO/DXF/DxfStreamReader/DxfSectionReaderBase.cs @@ -299,8 +299,8 @@ private bool readTextEntity(CadEntityTemplate template, DxfMap map, string subcl switch (this._reader.Code) { //TODO: Implement multiline text def codes - case 3 when tmp.CadObject is MText mtext: - mtext.AdditionalText.Concat(this._reader.ValueAsString); + case 1 or 3 when tmp.CadObject is MText mtext: + mtext.Value += this._reader.ValueAsString; return true; case 70: case 74: diff --git a/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs b/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs index 0dade031..506c3d70 100644 --- a/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs +++ b/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs @@ -616,13 +616,7 @@ private void writeMText(MText mtext) this._writer.Write(71, (short)mtext.AttachmentPoint, map); this._writer.Write(72, (short)mtext.DrawingDirection, map); - this._writer.Write(1, mtext.Value.Replace("\n", "^J"), map); - - if (!string.IsNullOrEmpty(mtext.AdditionalText)) - { - for (int i = 0; i < mtext.AdditionalText.Length; i += 250) - this._writer.Write(3, mtext.AdditionalText.Substring(i, 250), map); - } + this.writeMTextValue(mtext.Value); this._writer.WriteName(7, mtext.Style); @@ -630,23 +624,19 @@ private void writeMText(MText mtext) this._writer.Write(11, mtext.AlignmentPoint, map); - return; + this._writer.Write(210, mtext.Normal, map); + } - if (this.Version >= ACadVersion.AC1018) + private void writeMTextValue(string text) + { + string encoded = text?.Replace("\n", "^J"); + + for (int i = 0; i < encoded.Length - 250; i += 250) { - this._writer.Write(90, (int)mtext.BackgroundFillFlags, map); - if (mtext.BackgroundFillFlags.HasFlag(BackgroundFillFlags.UseBackgroundFillColor)) - { - //this._writer.Write(63, mtext.BackgroundColor, map); - this._writer.Write(45, mtext.BackgroundScale, map); - //Transparency of background fill color (not implemented) - //this._writer.Write(441, mtext.BackgroundTransparency, map); - } + this._writer.Write(3, encoded.Substring(i, 250)); } - this._writer.Write(45, mtext.BackgroundScale, map); - - this._writer.Write(210, mtext.Normal, map); + this._writer.Write(1, encoded); } private void writePoint(Point line) From 7eef119e359ffda8deb810ded49a512fdca95c5b Mon Sep 17 00:00:00 2001 From: DomCR Date: Tue, 14 Nov 2023 12:15:56 +0100 Subject: [PATCH 6/8] IsAnnotative --- ACadSharp/Entities/MText.TextColumn.cs | 2 +- ACadSharp/Entities/MText.cs | 4 +- .../DWG/DwgStreamReaders/DwgObjectReader.cs | 2 +- .../DwgObjectWriter.Entities.cs | 42 ++++++++----------- .../DxfSectionWriterBase.Entities.cs | 2 +- 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/ACadSharp/Entities/MText.TextColumn.cs b/ACadSharp/Entities/MText.TextColumn.cs index d5b2239b..1793bb4e 100644 --- a/ACadSharp/Entities/MText.TextColumn.cs +++ b/ACadSharp/Entities/MText.TextColumn.cs @@ -11,7 +11,7 @@ public class TextColumn /// Text column type /// [DxfCodeValue(75)] - public ColumnType ColumnType { get; set; } + public ColumnType ColumnType { get; set; } = ColumnType.NoColumns; /// /// Number of columns diff --git a/ACadSharp/Entities/MText.cs b/ACadSharp/Entities/MText.cs index 424c5a79..ebd07f62 100644 --- a/ACadSharp/Entities/MText.cs +++ b/ACadSharp/Entities/MText.cs @@ -63,10 +63,10 @@ public double Height public double RectangleWidth { get; set; } /// - /// + /// Reference rectangle height /// [DxfCodeValue(46)] - public double ReferenceRectangleHeight { get; set; } + public double RectangleHeight { get; set; } /// /// Attachment point diff --git a/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs b/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs index 1453be06..d18182df 100644 --- a/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs +++ b/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs @@ -2579,7 +2579,7 @@ private CadTemplate readMText() if (this.R2007Plus) { //Rect height BD 46 Reference rectangle height. - mtext.ReferenceRectangleHeight = this._objectReader.ReadBitDouble(); + mtext.RectangleHeight = this._objectReader.ReadBitDouble(); } //Common: diff --git a/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Entities.cs b/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Entities.cs index 4e054526..ad695cbd 100644 --- a/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Entities.cs +++ b/ACadSharp/IO/DWG/DwgStreamWriters/DwgObjectWriter.Entities.cs @@ -1324,7 +1324,7 @@ private void writeShape(Shape shape) //When reading from DXF, the shape is found by iterating over all the text styles //(SHAPEFILE, see paragraph 20.4.56) and when the text style contains a shape file, //iterating over all the shapes until the one with the matching name is found. - this._writer.WriteBitShort(0); //TODO: missing implementation for shapeIndex + this._writer.WriteBitShort(0); //TODO: missing implementation for shapeIndex //Extrusion 3BD 210 this._writer.Write3BitDouble(shape.Normal); @@ -1617,7 +1617,7 @@ private void writeMText(MText mtext) //R2007+: if (this.R2007Plus) { - this._writer.WriteBitDouble(mtext.ReferenceRectangleHeight); + this._writer.WriteBitDouble(mtext.RectangleHeight); } //Common: @@ -1628,7 +1628,6 @@ private void writeMText(MText mtext) //Drawing dir BS 72 Left to right, etc.; see DXF doc this._writer.WriteBitShort((short)mtext.DrawingDirection); - //TODO: Check undocumented values for MText //Extents ht BD ---Undocumented and not present in DXF or entget this._writer.WriteBitDouble(0); //Extents wid BD ---Undocumented and not present in DXF or entget @@ -1685,9 +1684,6 @@ private void writeMText(MText mtext) return; } - throw new System.NotImplementedException("Annotative MText not implemented for the writer"); - //TODO: missing values depending on the reader to get them and process to be able to write -#if false //Version BS Default 0 this._writer.WriteBitShort(0); //Default flag B Default true @@ -1697,51 +1693,49 @@ private void writeMText(MText mtext) //Registered application H Hard pointer this._writer.HandleReference(DwgReferenceType.HardPointer, null); - //TODO: finish Mtext Writer, save redundant fields?? - //Attachment point BL - AttachmentPointType attachmentPoint = (AttachmentPointType)this._writer.WriteBitLong(); + this._writer.WriteBitLong((int)mtext.AttachmentPoint); //X - axis dir 3BD 10 - this._writer.Write3BitDouble(); + this._writer.Write3BitDouble(mtext.AlignmentPoint); //Insertion point 3BD 11 - this._writer.Write3BitDouble(); + this._writer.Write3BitDouble(mtext.InsertPoint); //Rect width BD 40 - this._writer.WriteBitDouble(); + this._writer.WriteBitDouble(mtext.Height); //Rect height BD 41 - this._writer.WriteBitDouble(); + this._writer.WriteBitDouble(mtext.RectangleWidth); //Extents width BD 42 - this._writer.WriteBitDouble(); + this._writer.WriteBitDouble(mtext.HorizontalWidth); //Extents height BD 43 - this._writer.WriteBitDouble(); + this._writer.WriteBitDouble(mtext.VerticalWidth); //END REDUNDANT FIELDS //Column type BS 71 0 = No columns, 1 = static columns, 2 = dynamic columns this._writer.WriteBitShort((short)mtext.Column.ColumnType); + //IF Has Columns data(column type is not 0) if (mtext.Column.ColumnType != ColumnType.NoColumns) { //Column height count BL 72 - int count = this._writer.WriteBitLong(); + this._writer.WriteBitLong(mtext.Column.ColumnCount); //Columnn width BD 44 - mtext.Column.ColumnWidth = this._writer.WriteBitDouble(); + this._writer.WriteBitDouble(mtext.Column.ColumnWidth); //Gutter BD 45 - mtext.Column.ColumnGutter = this._writer.WriteBitDouble(); + this._writer.WriteBitDouble(mtext.Column.ColumnGutter); //Auto height? B 73 - mtext.Column.ColumnAutoHeight = this._writer.WriteBit(); + this._writer.WriteBit(mtext.Column.ColumnAutoHeight); //Flow reversed? B 74 - mtext.Column.ColumnFlowReversed = this._writer.WriteBit(); + this._writer.WriteBit(mtext.Column.ColumnFlowReversed); //IF not auto height and column type is dynamic columns - if (!mtext.Column.ColumnAutoHeight && mtext.Column.ColumnType == ColumnType.DynamicColumns && count > 0) + if (!mtext.Column.ColumnAutoHeight && mtext.Column.ColumnType == ColumnType.DynamicColumns) { - for (int i = 0; i < count; ++i) + foreach (double h in mtext.Column.ColumnHeights) { //Column height BD 46 - mtext.Column.ColumnHeights.Add(this._writer.WriteBitDouble()); + this._writer.WriteBitDouble(h); } } } -#endif } private void writeFaceRecord(VertexFaceRecord face) diff --git a/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs b/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs index 506c3d70..9b2ff342 100644 --- a/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs +++ b/ACadSharp/IO/DXF/DxfStreamWriter/DxfSectionWriterBase.Entities.cs @@ -610,7 +610,7 @@ private void writeMText(MText mtext) if (this.Version >= ACadVersion.AC1021) { - this._writer.Write(46, mtext.ReferenceRectangleHeight, map); + this._writer.Write(46, mtext.RectangleHeight, map); } this._writer.Write(71, (short)mtext.AttachmentPoint, map); From cc110558acdca411ba3706a1bc199c7cff20cd96 Mon Sep 17 00:00:00 2001 From: Nihad Karajko Date: Fri, 17 Nov 2023 16:46:36 +0100 Subject: [PATCH 7/8] Replace double[] with Matrix4 --- .../DWG/DwgStreamReaders/DwgObjectReader.cs | 36 ++++++++++--------- ACadSharp/Objects/MultiLeaderAnnotContext.cs | 4 +-- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs b/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs index 1453be06..93c5c15d 100644 --- a/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs +++ b/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs @@ -3048,23 +3048,25 @@ private MultiLeaderAnnotContext readMultiLeaderAnnotContext(CadMLeaderTemplate t // - Scaling (using scale vector) // - Translation (using location) // Simply read an array of 16 doubles: - double[] matrix = annotContext.TransformationMatrix; - matrix[0] = _objectReader.ReadBitDouble(); - matrix[1] = _objectReader.ReadBitDouble(); - matrix[2] = _objectReader.ReadBitDouble(); - matrix[3] = _objectReader.ReadBitDouble(); - matrix[4] = _objectReader.ReadBitDouble(); - matrix[5] = _objectReader.ReadBitDouble(); - matrix[6] = _objectReader.ReadBitDouble(); - matrix[7] = _objectReader.ReadBitDouble(); - matrix[8] = _objectReader.ReadBitDouble(); - matrix[9] = _objectReader.ReadBitDouble(); - matrix[10] = _objectReader.ReadBitDouble(); - matrix[11] = _objectReader.ReadBitDouble(); - matrix[12] = _objectReader.ReadBitDouble(); - matrix[13] = _objectReader.ReadBitDouble(); - matrix[14] = _objectReader.ReadBitDouble(); - matrix[15] = _objectReader.ReadBitDouble(); + double[] elements = new double[16]; + elements[0] = _objectReader.ReadBitDouble(); + elements[1] = _objectReader.ReadBitDouble(); + elements[2] = _objectReader.ReadBitDouble(); + elements[3] = _objectReader.ReadBitDouble(); + elements[4] = _objectReader.ReadBitDouble(); + elements[5] = _objectReader.ReadBitDouble(); + elements[6] = _objectReader.ReadBitDouble(); + elements[7] = _objectReader.ReadBitDouble(); + elements[8] = _objectReader.ReadBitDouble(); + elements[9] = _objectReader.ReadBitDouble(); + elements[10] = _objectReader.ReadBitDouble(); + elements[11] = _objectReader.ReadBitDouble(); + elements[12] = _objectReader.ReadBitDouble(); + elements[13] = _objectReader.ReadBitDouble(); + elements[14] = _objectReader.ReadBitDouble(); + elements[15] = _objectReader.ReadBitDouble(); + + annotContext.TransformationMatrix = new Matrix4(elements); } //END IF Has contents block //END IF Has text contents diff --git a/ACadSharp/Objects/MultiLeaderAnnotContext.cs b/ACadSharp/Objects/MultiLeaderAnnotContext.cs index acfe04e7..4c73ebe6 100644 --- a/ACadSharp/Objects/MultiLeaderAnnotContext.cs +++ b/ACadSharp/Objects/MultiLeaderAnnotContext.cs @@ -280,8 +280,6 @@ public partial class MultiLeaderAnnotContext : CadObject [DxfCodeValue(93)] public Color BlockContentColor { get; set; } - // TODO ? should double[] be replaced by a TransformationMatrix type? -> CSMath.Matrix4 - /// /// Gets a array of 16 doubles containg the complete transformation /// matrix. @@ -298,7 +296,7 @@ public partial class MultiLeaderAnnotContext : CadObject /// /// [DxfCodeValue(93)] - public double[] TransformationMatrix { get; } = new double[16]; + public Matrix4 TransformationMatrix { get; set; } /// /// Base point From fb1a5ce9f8632f1fad43d11633d5e305234bfecd Mon Sep 17 00:00:00 2001 From: "Dr. Matthias Menningen" Date: Mon, 20 Nov 2023 18:46:05 +0100 Subject: [PATCH 8/8] - use 16 doubles instead of double[16] for >Matrix4. --- .../DWG/DwgStreamReaders/DwgObjectReader.cs | 45 ++++++++++--------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs b/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs index 93c5c15d..53907f7d 100644 --- a/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs +++ b/ACadSharp/IO/DWG/DwgStreamReaders/DwgObjectReader.cs @@ -3047,26 +3047,31 @@ private MultiLeaderAnnotContext readMultiLeaderAnnotContext(CadMLeaderTemplate t // - OCS to WCS (using normal vector), // - Scaling (using scale vector) // - Translation (using location) - // Simply read an array of 16 doubles: - double[] elements = new double[16]; - elements[0] = _objectReader.ReadBitDouble(); - elements[1] = _objectReader.ReadBitDouble(); - elements[2] = _objectReader.ReadBitDouble(); - elements[3] = _objectReader.ReadBitDouble(); - elements[4] = _objectReader.ReadBitDouble(); - elements[5] = _objectReader.ReadBitDouble(); - elements[6] = _objectReader.ReadBitDouble(); - elements[7] = _objectReader.ReadBitDouble(); - elements[8] = _objectReader.ReadBitDouble(); - elements[9] = _objectReader.ReadBitDouble(); - elements[10] = _objectReader.ReadBitDouble(); - elements[11] = _objectReader.ReadBitDouble(); - elements[12] = _objectReader.ReadBitDouble(); - elements[13] = _objectReader.ReadBitDouble(); - elements[14] = _objectReader.ReadBitDouble(); - elements[15] = _objectReader.ReadBitDouble(); - - annotContext.TransformationMatrix = new Matrix4(elements); + double m00 = _objectReader.ReadBitDouble(); + double m10 = _objectReader.ReadBitDouble(); + double m20 = _objectReader.ReadBitDouble(); + double m30 = _objectReader.ReadBitDouble(); + + double m01 = _objectReader.ReadBitDouble(); + double m11 = _objectReader.ReadBitDouble(); + double m21 = _objectReader.ReadBitDouble(); + double m31 = _objectReader.ReadBitDouble(); + + double m02 = _objectReader.ReadBitDouble(); + double m12 = _objectReader.ReadBitDouble(); + double m22 = _objectReader.ReadBitDouble(); + double m32 = _objectReader.ReadBitDouble(); + + double m03 = _objectReader.ReadBitDouble(); + double m13 = _objectReader.ReadBitDouble(); + double m23 = _objectReader.ReadBitDouble(); + double m33 = _objectReader.ReadBitDouble(); + + annotContext.TransformationMatrix = new Matrix4( + m00, m10, m20, m30, + m01, m11, m21, m31, + m02, m12, m22, m32, + m03, m13, m23, m33); } //END IF Has contents block //END IF Has text contents