<?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 Random &amp;quot;OK&amp;quot; showing up in MTEXT in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/random-quot-ok-quot-showing-up-in-mtext/m-p/3475764#M55350</link>
    <description>&lt;P&gt;Hey everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've found some example code on how to create Leaderline and have been playing around with it. So far so good, but when I create my leaderline and the Mtext generates, it is always preceeded by an "OK" and i can't figure out where it's coming from. I've tried using TrimStart on a number of the strings to no avail. I know it must be something insanely simple but it can't seem to get it. Any input would be awesome!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;

namespace DimensionLibrary
{
    public class DimensionCommands
    {
        static ObjectId GetArrowObjectId(string newArrName)
        {
            ObjectId arrObjId = ObjectId.Null;

            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;

            // Get the current value of DIMBLK
            string oldArrName = Application.GetSystemVariable("DIMBLK") as string;

            // Set DIMBLK to the new style
            // (this action may create a new block)
            Application.SetSystemVariable("DIMBLK", newArrName);

            // Reset the previous value of DIMBLK
            if (oldArrName.Length != 0)
                Application.SetSystemVariable("DIMBLK", oldArrName);

            // Now get the objectId of the block
            Transaction tr = db.TransactionManager.StartTransaction();
            using (tr)
            {
                BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);

                arrObjId = bt[newArrName];
                tr.Commit();
            }
            return arrObjId;
        }

        [CommandMethod("MLTEST")]
        static public void CreateMultiLeader()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;
            string bname = "";
            string bx = "";
            string by = "";
            string bz = "";

            const string arrowName = "_DOT";
            ObjectId arrId = GetArrowObjectId(arrowName);

            ////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////

            PromptEntityOptions options = new PromptEntityOptions("\nSelect block reference");

            options.SetRejectMessage("\nSelect only block reference");

            options.AddAllowedClass(typeof(BlockReference), false);

            PromptEntityResult acSSPrompt = ed.GetEntity(options);

            using (Transaction tx = db.TransactionManager.StartTransaction())
            {
                BlockReference blockRef = tx.GetObject(acSSPrompt.ObjectId, OpenMode.ForRead) as BlockReference;
                BlockTableRecord block = null;
                if (blockRef.IsDynamicBlock)
                {
                    block = tx.GetObject(blockRef.BlockTableRecord,
                                OpenMode.ForRead) as BlockTableRecord;

                    if (block.IsAnonymous)
                    {
                        //get the real dynamic block name.
                        block =
                            tx.GetObject(blockRef.DynamicBlockTableRecord,
                                OpenMode.ForRead) as BlockTableRecord;
                    }
                }
                else
                {
                    block = tx.GetObject(blockRef.BlockTableRecord,
                                OpenMode.ForRead) as BlockTableRecord;
                }


                if (block != null)
                {
                    
                    bname = block.Name;
                    bx = acSSPrompt.PickedPoint.X.ToString();
                    by = acSSPrompt.PickedPoint.Y.ToString();
                    bz = acSSPrompt.PickedPoint.Z.ToString();

                    ed.WriteMessage("Block name is : " + block.Name + "\n");
                    ed.WriteMessage("X is :" + bx + "\n");
                    ed.WriteMessage("Y is :" + by + "\n");
                    ed.WriteMessage("Z is :" + bz + "\n");
                }
                tx.Commit();
                                

                // Get the start point of the leader
                PromptPointResult result = ed.GetPoint("\nSpecify leader arrowhead location: ");

                if (result.Status != PromptStatus.OK)
                    return;

                Point3d startPt = result.Value;

                // Get the end point of the leader
                PromptPointOptions opts = new PromptPointOptions("\nSpecify landing location: ");
                opts.BasePoint = startPt;
                opts.UseBasePoint = true;
                result = ed.GetPoint(opts);

                if (result.Status != PromptStatus.OK)
                    return;

                Point3d endPt = result.Value;
                ////////////////////////////////////////////////////////////////////////////////
                ////////////////////////////////////////////////////////////////////////////////


                Transaction tr = db.TransactionManager.StartTransaction();
                using (tr)
                {
                    try
                    {
                        BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                        BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                        // Create the MLeader
                        MLeader mld = new MLeader();
                        int ldNum = mld.AddLeader();
                        int lnNum = mld.AddLeaderLine(ldNum);
                        mld.AddFirstVertex(lnNum, startPt);
                        mld.AddLastVertex(lnNum, endPt);
                        mld.ArrowSymbolId = arrId;
                        mld.LeaderLineType = LeaderType.SplineLeader;


                        // Create the MText
                        MText mt = new MText();
                        PromptStringOptions psopts = new PromptStringOptions("Please input a label for your leader line");                     

                        psopts.DefaultValue = bname + "\n" + "X:" + bx + "\n" + "Y:" + by + "\n" + "Z:" + bz;
                        PromptResult pres = ed.GetString(psopts);


                        mt.Contents = pres.ToString();
                        mt.Location = endPt;
                        mld.ContentType = ContentType.MTextContent;
                        mld.MText = mt;

                        // Add the MLeader
                        btr.AppendEntity(mld);
                        tr.AddNewlyCreatedDBObject(mld, true);

                        //Commit the transaction
                        tr.Commit();

                    }
                    catch
                    {
                        // Would also happen automatically
                        // if we didn't commit
                        tr.Abort();
                    }
                }
            }
        }
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 May 2012 15:29:50 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2012-05-29T15:29:50Z</dc:date>
    <item>
      <title>Random "OK" showing up in MTEXT</title>
      <link>https://forums.autodesk.com/t5/net-forum/random-quot-ok-quot-showing-up-in-mtext/m-p/3475764#M55350</link>
      <description>&lt;P&gt;Hey everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've found some example code on how to create Leaderline and have been playing around with it. So far so good, but when I create my leaderline and the Mtext generates, it is always preceeded by an "OK" and i can't figure out where it's coming from. I've tried using TrimStart on a number of the strings to no avail. I know it must be something insanely simple but it can't seem to get it. Any input would be awesome!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;

namespace DimensionLibrary
{
    public class DimensionCommands
    {
        static ObjectId GetArrowObjectId(string newArrName)
        {
            ObjectId arrObjId = ObjectId.Null;

            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;

            // Get the current value of DIMBLK
            string oldArrName = Application.GetSystemVariable("DIMBLK") as string;

            // Set DIMBLK to the new style
            // (this action may create a new block)
            Application.SetSystemVariable("DIMBLK", newArrName);

            // Reset the previous value of DIMBLK
            if (oldArrName.Length != 0)
                Application.SetSystemVariable("DIMBLK", oldArrName);

            // Now get the objectId of the block
            Transaction tr = db.TransactionManager.StartTransaction();
            using (tr)
            {
                BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);

                arrObjId = bt[newArrName];
                tr.Commit();
            }
            return arrObjId;
        }

        [CommandMethod("MLTEST")]
        static public void CreateMultiLeader()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;
            string bname = "";
            string bx = "";
            string by = "";
            string bz = "";

            const string arrowName = "_DOT";
            ObjectId arrId = GetArrowObjectId(arrowName);

            ////////////////////////////////////////////////////////////////////////////////
            ////////////////////////////////////////////////////////////////////////////////

            PromptEntityOptions options = new PromptEntityOptions("\nSelect block reference");

            options.SetRejectMessage("\nSelect only block reference");

            options.AddAllowedClass(typeof(BlockReference), false);

            PromptEntityResult acSSPrompt = ed.GetEntity(options);

            using (Transaction tx = db.TransactionManager.StartTransaction())
            {
                BlockReference blockRef = tx.GetObject(acSSPrompt.ObjectId, OpenMode.ForRead) as BlockReference;
                BlockTableRecord block = null;
                if (blockRef.IsDynamicBlock)
                {
                    block = tx.GetObject(blockRef.BlockTableRecord,
                                OpenMode.ForRead) as BlockTableRecord;

                    if (block.IsAnonymous)
                    {
                        //get the real dynamic block name.
                        block =
                            tx.GetObject(blockRef.DynamicBlockTableRecord,
                                OpenMode.ForRead) as BlockTableRecord;
                    }
                }
                else
                {
                    block = tx.GetObject(blockRef.BlockTableRecord,
                                OpenMode.ForRead) as BlockTableRecord;
                }


                if (block != null)
                {
                    
                    bname = block.Name;
                    bx = acSSPrompt.PickedPoint.X.ToString();
                    by = acSSPrompt.PickedPoint.Y.ToString();
                    bz = acSSPrompt.PickedPoint.Z.ToString();

                    ed.WriteMessage("Block name is : " + block.Name + "\n");
                    ed.WriteMessage("X is :" + bx + "\n");
                    ed.WriteMessage("Y is :" + by + "\n");
                    ed.WriteMessage("Z is :" + bz + "\n");
                }
                tx.Commit();
                                

                // Get the start point of the leader
                PromptPointResult result = ed.GetPoint("\nSpecify leader arrowhead location: ");

                if (result.Status != PromptStatus.OK)
                    return;

                Point3d startPt = result.Value;

                // Get the end point of the leader
                PromptPointOptions opts = new PromptPointOptions("\nSpecify landing location: ");
                opts.BasePoint = startPt;
                opts.UseBasePoint = true;
                result = ed.GetPoint(opts);

                if (result.Status != PromptStatus.OK)
                    return;

                Point3d endPt = result.Value;
                ////////////////////////////////////////////////////////////////////////////////
                ////////////////////////////////////////////////////////////////////////////////


                Transaction tr = db.TransactionManager.StartTransaction();
                using (tr)
                {
                    try
                    {
                        BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
                        BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

                        // Create the MLeader
                        MLeader mld = new MLeader();
                        int ldNum = mld.AddLeader();
                        int lnNum = mld.AddLeaderLine(ldNum);
                        mld.AddFirstVertex(lnNum, startPt);
                        mld.AddLastVertex(lnNum, endPt);
                        mld.ArrowSymbolId = arrId;
                        mld.LeaderLineType = LeaderType.SplineLeader;


                        // Create the MText
                        MText mt = new MText();
                        PromptStringOptions psopts = new PromptStringOptions("Please input a label for your leader line");                     

                        psopts.DefaultValue = bname + "\n" + "X:" + bx + "\n" + "Y:" + by + "\n" + "Z:" + bz;
                        PromptResult pres = ed.GetString(psopts);


                        mt.Contents = pres.ToString();
                        mt.Location = endPt;
                        mld.ContentType = ContentType.MTextContent;
                        mld.MText = mt;

                        // Add the MLeader
                        btr.AppendEntity(mld);
                        tr.AddNewlyCreatedDBObject(mld, true);

                        //Commit the transaction
                        tr.Commit();

                    }
                    catch
                    {
                        // Would also happen automatically
                        // if we didn't commit
                        tr.Abort();
                    }
                }
            }
        }
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2012 15:29:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/random-quot-ok-quot-showing-up-in-mtext/m-p/3475764#M55350</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-29T15:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: Random "OK" showing up in MTEXT</title>
      <link>https://forums.autodesk.com/t5/net-forum/random-quot-ok-quot-showing-up-in-mtext/m-p/3475910#M55351</link>
      <description>&lt;P&gt;Just change this line within the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;mt.Contents = pres.StringResult;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800000" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2012 16:48:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/random-quot-ok-quot-showing-up-in-mtext/m-p/3475910#M55351</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-05-29T16:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Random "OK" showing up in MTEXT</title>
      <link>https://forums.autodesk.com/t5/net-forum/random-quot-ok-quot-showing-up-in-mtext/m-p/3475918#M55352</link>
      <description>&lt;P&gt;Perfect!!!!!!! Thanks again Hallex, I owe you one&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2012 16:50:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/random-quot-ok-quot-showing-up-in-mtext/m-p/3475918#M55352</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-05-29T16:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: Random "OK" showing up in MTEXT</title>
      <link>https://forums.autodesk.com/t5/net-forum/random-quot-ok-quot-showing-up-in-mtext/m-p/3475950#M55353</link>
      <description>&lt;P&gt;Glad I could help,&lt;/P&gt;&lt;P&gt;Cheers, bro &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300" face="arial,helvetica,sans-serif"&gt;~'J'~&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2012 17:04:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/random-quot-ok-quot-showing-up-in-mtext/m-p/3475950#M55353</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2012-05-29T17:04:18Z</dc:date>
    </item>
  </channel>
</rss>

