<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to get the MText position of a Dimension, it's not the textposition. in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-get-the-mtext-position-of-a-dimension-it-s-not-the/m-p/5971697#M37627</link>
    <description>&lt;P&gt;Hi senl1362:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Thank you so much~&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; That's really help.&lt;/P&gt;&lt;P&gt;swaywood&lt;/P&gt;</description>
    <pubDate>Mon, 04 Jan 2016 13:40:41 GMT</pubDate>
    <dc:creator>swaywood</dc:creator>
    <dc:date>2016-01-04T13:40:41Z</dc:date>
    <item>
      <title>How to get the MText position of a Dimension, it's not the textposition.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-the-mtext-position-of-a-dimension-it-s-not-the/m-p/5966902#M37624</link>
      <description>&lt;P&gt;hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I want to get the dimension text position of a dimension, it may be a RotatedDimension,AlignedDimension or other type of dimension.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I tried to get the textposition, but it's not exactly the text postion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Could anyone tell me how to get it, or how to get the MText object?&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;swaywood&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2015 06:40:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-the-mtext-position-of-a-dimension-it-s-not-the/m-p/5966902#M37624</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2015-12-29T06:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the MText position of a Dimension, it's not the textposition.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-the-mtext-position-of-a-dimension-it-s-not-the/m-p/5966954#M37625</link>
      <description>&lt;PRE&gt;               var peo = new PromptEntityOptions("Select Dimension");
                var per = ed.GetEntity(peo);
                if (per.Status != PromptStatus.OK)
                    return;

                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    var dim = tr.GetObject(per.ObjectId, OpenMode.ForRead) as Dimension;
                    if (dim == null)
                        throw new System.Exception("Selected object is not a dimension");
                    var dimBlk = tr.GetObject(dim.DimBlockId, OpenMode.ForRead) as BlockTableRecord;
                    foreach(var id in dimBlk)
                    {
                        if (id.ObjectClass.DxfName=="MTEXT")
                        {
                            var mt = tr.GetObject(id, OpenMode.ForRead) as MText;
                            ed.WriteMessage("\n Dim Text:");&lt;BR /&gt;                            ed.WriteMessage("\n\t Block: {0}", dimBlk.Name);
                            ed.WriteMessage("\n\t Text: {0}", mt.Contents);
                            ed.WriteMessage("\n\t Position: {0}, {1}", mt.Location.X, mt.Location.Y);
                            ed.WriteMessage("\n\t AttachmentPoint: {0}",Enum.GetName(typeof(AttachmentPoint), mt.Attachment));
                            ed.WriteMessage("\n\t Rotation: {0}", mt.Rotation * 180 / Math.PI);
                            ed.WriteMessage("\n\t Width, Height: {0}, {1}", mt.ActualHeight, mt.ActualWidth);
                        }
                    }
                    tr.Commit();
                }&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Dec 2015 08:43:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-the-mtext-position-of-a-dimension-it-s-not-the/m-p/5966954#M37625</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-12-29T08:43:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the MText position of a Dimension, it's not the textposition.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-the-mtext-position-of-a-dimension-it-s-not-the/m-p/5967049#M37626</link>
      <description>&lt;P&gt;When you are interested in the frame around the Dimension Text, add this to the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[CommandMethod("MtFromDim")]
        public static void MtextFromDimension()
        {
            Document doc = null;
            Database db = null;
            Editor ed = null;


            try
            {
                doc = AcadApp.DocumentManager.MdiActiveDocument;
                if (doc == null)
                    throw new System.Exception("No MdiActiveDocument");
                db = doc.Database;
                ed = doc.Editor;

                var peo = new PromptEntityOptions("Select Dimension");
                var per = ed.GetEntity(peo);
                if (per.Status != PromptStatus.OK)
                    return;

                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    var dim = tr.GetObject(per.ObjectId, OpenMode.ForRead) as Dimension;
                    if (dim == null)
                        throw new System.Exception("Selected object is not a dimension");
                    var dimBlk = tr.GetObject(dim.DimBlockId, OpenMode.ForRead) as BlockTableRecord;
                    foreach(var id in dimBlk)
                    {
                        if (id.ObjectClass.DxfName=="MTEXT")
                        {
                            var mt = tr.GetObject(id, OpenMode.ForRead) as MText;
                            ed.WriteMessage("\n Dim Text:");
                            ed.WriteMessage("\n\t Block: {0}", dimBlk.Name);
                            ed.WriteMessage("\n\t Text: {0}", mt.Contents);
                            ed.WriteMessage("\n\t Position: {0}, {1}", mt.Location.X, mt.Location.Y);
                            ed.WriteMessage("\n\t AttachmentPoint: {0}",Enum.GetName(typeof(AttachmentPoint), mt.Attachment));
                            ed.WriteMessage("\n\t Rotation: {0}", mt.Rotation * 180 / Math.PI);
                            ed.WriteMessage("\n\t Width, Height: {0}, {1}", mt.ActualHeight, mt.ActualWidth);

                            &lt;FONT color="#0000FF"&gt;var mtAngle = mt.Rotation;&lt;/FONT&gt;
                            &lt;FONT color="#0000FF"&gt;var mtPos = mt.Location;&lt;/FONT&gt;
                            &lt;FONT color="#0000FF"&gt;mt.UpgradeOpen();&lt;/FONT&gt;

                            &lt;FONT color="#0000FF"&gt;mt.TransformBy(Matrix3d.Rotation(-mtAngle, Vector3d.ZAxis, mtPos));&lt;/FONT&gt;
                            &lt;FONT color="#0000FF"&gt;var mtBounds = mt.GetBoundingPoints();&lt;/FONT&gt;
                            &lt;FONT color="#0000FF"&gt;mt.TransformBy(Matrix3d.Rotation(mtAngle, Vector3d.ZAxis, mtPos));&lt;/FONT&gt;
                            &lt;FONT color="#0000FF"&gt;for (int i = 0; i &amp;lt; mtBounds.Count; i++)&lt;/FONT&gt;
                                &lt;FONT color="#0000FF"&gt;mtBounds[i]=mtBounds[i].TransformBy(Matrix3d.Rotation(mtAngle, Vector3d.ZAxis, mtPos));&lt;/FONT&gt;
                            ed.WriteMessage("\n\t Lower Left: ({0}, {1})", mtBounds[2].X, mtBounds[2].Y);
                            ed.WriteMessage("\n\t Lower Right: ({0}, {1})", mtBounds[3].X, mtBounds[3].Y);
                            ed.WriteMessage("\n\t Upper Right: ({0}, {1})", mtBounds[1].X, mtBounds[1].Y);
                            ed.WriteMessage("\n\t Upper Left: ({0}, {1})", mtBounds[0].X, mtBounds[0].Y);
 &lt;BR /&gt; 
                            var pl = new Polyline();
                            pl.AddVertexAt(0, new Point2d(mtBounds[2].X, mtBounds[2].Y), 0, 0, 0);
                            pl.AddVertexAt(1, new Point2d(mtBounds[3].X, mtBounds[3].Y), 0, 0, 0);
                            pl.AddVertexAt(2, new Point2d(mtBounds[1].X, mtBounds[1].Y), 0, 0, 0);
                            pl.AddVertexAt(3, new Point2d(mtBounds[0].X, mtBounds[0].Y), 0, 0, 0);
                            pl.Closed = true;
                            pl.LayerId = mt.LayerId;
                            var ms = (BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
                            ms.AppendEntity(pl);
                            tr.AddNewlyCreatedDBObject(pl, true);
                            
                        }
                    }
                    tr.Commit();
                }

            }
            catch (System.Exception ex)
            {
                if (ed != null)
                    ed.WriteMessage("\n Error in MtextFromDimension: {0}", ex.Message);
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/208835i13B9127C3E69F666/image-size/original?v=mpbl-1&amp;amp;px=-1" alt="Screenshot_1.png" title="Screenshot_1.png" border="0" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Dec 2015 11:03:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-the-mtext-position-of-a-dimension-it-s-not-the/m-p/5967049#M37626</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-12-29T11:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to get the MText position of a Dimension, it's not the textposition.</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-get-the-mtext-position-of-a-dimension-it-s-not-the/m-p/5971697#M37627</link>
      <description>&lt;P&gt;Hi senl1362:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Thank you so much~&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; That's really help.&lt;/P&gt;&lt;P&gt;swaywood&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2016 13:40:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-get-the-mtext-position-of-a-dimension-it-s-not-the/m-p/5971697#M37627</guid>
      <dc:creator>swaywood</dc:creator>
      <dc:date>2016-01-04T13:40:41Z</dc:date>
    </item>
  </channel>
</rss>

