<?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: ToolPalette Show Active Layer in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5781497#M38938</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just tested AutoCAD MAP 2016 and the same result as for 2012 and 2014.&lt;/P&gt;&lt;P&gt;At the end both the Pline and the MText are placed on the layer's defined by the ToolPalette however for the MTEXT command this is only visible for the user AFTER it&amp;nbsp;is finished.&lt;/P&gt;&lt;P&gt;When using the Pline command it is immediately visible on what layer it will be placed right after the command is activated.&lt;/P&gt;&lt;P&gt;See the differences below.&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/184700iEE604B9FC290FEFB/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Screenshot_1.png" title="Screenshot_1.png" /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 21 Aug 2015 08:45:00 GMT</pubDate>
    <dc:creator>SENL1362</dc:creator>
    <dc:date>2015-08-21T08:45:00Z</dc:date>
    <item>
      <title>ToolPalette Show Active Layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5771129#M38935</link>
      <description>&lt;P&gt;For a long time I am looking for a simple solution fot this problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The temporary current layer is shown in the Layer dropdown box when placing simple tools from a ToolPalette, figure "1".&lt;/P&gt;&lt;P&gt;But this &lt;STRONG&gt;not&lt;/STRONG&gt; the case for MText, which confuses novice users, figure "2".&lt;/P&gt;&lt;P&gt;The Mtext is placed on the activated layer but this must be checked after the placement of the MText.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only solution found so far is using the function&amp;nbsp;ShowActivateMTextLayer, figure "3".&lt;/P&gt;&lt;P&gt;This involves a &lt;EM&gt;GetPoint&lt;/EM&gt; and &lt;EM&gt;SendStringToExecute&lt;/EM&gt; whom&amp;nbsp;i&amp;nbsp;would rather avoid.&lt;/P&gt;&lt;P&gt;And it changes the active layer permanently, although this is acceptable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried al sorts of Refresh functions, like UpdateScreen, Regen, &lt;SPAN&gt;EnableGraphicsFlush,&amp;nbsp;&lt;/SPAN&gt;QueueForGraphicsFlush,&amp;nbsp;&lt;SPAN&gt;FlushGraphics.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any other suggestions?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for any help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/183491i6CD6C52D58729512/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Screenshot_1.png" title="Screenshot_1.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        [CommandMethod("ShActMtLy")]
        public void ShowActivateMTextLayer()
        {
            Document doc = null;
            Database db = null;
            Editor ed = null;

            try
            {
                doc = AcadApp.DocumentManager.MdiActiveDocument;
                db = doc.Database;
                ed = doc.Editor;
               
                var curLayerName = GetLayerName(db.Clayer);
                // The call to ed.GetPoint update's the LayerSelector according to the Actual Current Layer
                PromptPointResult ppr = ed.GetPoint("\n First Corner: ");
                if (ppr.Status != PromptStatus.OK)
                    return;
                // But this get's changed after the point is returned.
                // Send CLAYER command solved that issue.
                doc.SendStringToExecute("CLAYER " + curLayerName + "\n" + "Mtext " + ppr.Value.X + "," + ppr.Value.Y + " ", true, false, false);
            }
            catch (System.Exception ex)
            {
                if (ed != null)
                    ed.WriteMessage("\n Error: " + ex.Message);
                else
                    MessageBox.Show("Error: " + ex.Message, "ShowActivateMTextLayer", MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        public static ObjectId SetLayer(Database db, string layerName)
        {
            if (db==null)
                throw new System.Exception("GetLayerName: db IS NULL");
            if (string.IsNullOrWhiteSpace(layerName))
                throw new System.Exception("SetLayer: layerName IS NULL");

            ObjectId layerId = ObjectId.Null;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                LayerTable layerTable = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForRead);
                if (layerTable.Has(layerName))
                    layerId = layerTable[layerName];
                else
                {
                    LayerTableRecord newLayer = new LayerTableRecord();
                    newLayer.Name = layerName;

                    layerTable.UpgradeOpen();
                    layerTable.Add(newLayer);
                    tr.AddNewlyCreatedDBObject(newLayer, true);
                    layerId = newLayer.ObjectId;
                }
                db.Clayer = layerId;
                tr.Commit();
            }
            return layerId;
        }&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Aug 2015 08:04:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5771129#M38935</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-08-14T08:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: ToolPalette Show Active Layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5781371#M38936</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not see this problem in AutoCAD 2016. In which version are you trying this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the tool properties of an MText if i set the layer as "MText", the created MText was assigned to it already when the command was active.&lt;/P&gt;
&lt;P&gt;To test if this is the case, i&amp;nbsp;had modified the layer color and the MText was displayed in that color.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is a recording :&lt;/P&gt;
&lt;P&gt;&lt;A href="http://autode.sk/1NpFqTW" target="_blank"&gt;http://autode.sk/1NpFqTW&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2015 07:11:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5781371#M38936</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-08-21T07:11:57Z</dc:date>
    </item>
    <item>
      <title>Re: ToolPalette Show Active Layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5781456#M38937</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello&amp;nbsp;&lt;SPAN&gt;Balaji,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you for you're time spend on helping to solve this issue.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The samples are from AutoCAD MAP 2012 and 2014.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So you might be right that this is solved in new versions of AutoCAD.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I'll have a look as soon as possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was looking for somesort of a refresh command, but it's oke when this is solved in 2016.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, thanks for you're help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2015 08:11:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5781456#M38937</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-08-21T08:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: ToolPalette Show Active Layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5781497#M38938</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just tested AutoCAD MAP 2016 and the same result as for 2012 and 2014.&lt;/P&gt;&lt;P&gt;At the end both the Pline and the MText are placed on the layer's defined by the ToolPalette however for the MTEXT command this is only visible for the user AFTER it&amp;nbsp;is finished.&lt;/P&gt;&lt;P&gt;When using the Pline command it is immediately visible on what layer it will be placed right after the command is activated.&lt;/P&gt;&lt;P&gt;See the differences below.&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/184700iEE604B9FC290FEFB/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Screenshot_1.png" title="Screenshot_1.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2015 08:45:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5781497#M38938</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-08-21T08:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: ToolPalette Show Active Layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5781509#M38939</link>
      <description>&lt;P&gt;yes, i am getting your point now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After you&amp;nbsp;select the extents for the MText, the layer name gets updated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are&amp;nbsp;you expecting the layer name change just after the MText&amp;nbsp;tool from the palette is clicked ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I only have vanilla AutoCAD 2016 installed in my system.&lt;/P&gt;
&lt;P&gt;Can you confirm the&amp;nbsp;behavior&amp;nbsp;in AutoCAD Map 2016&amp;nbsp;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2015 08:55:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5781509#M38939</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-08-21T08:55:55Z</dc:date>
    </item>
    <item>
      <title>Re: ToolPalette Show Active Layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5781514#M38940</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;EM&gt;After you&amp;nbsp;select the extents for the MText, the layer name gets updated.&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;But this is after the MText is created. It needs an additional action from the user to confirm the proper placement.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;EM&gt;Are&amp;nbsp;you expecting the layer name change just after the MText&amp;nbsp;tool from the palette is clicked ?&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;Yes that's what our customers like to see, click the command and then the Layer Dropdown box should show the name of the Temporary Current Layer defined in the ToolPalette.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="4"&gt;&lt;EM&gt;Can you confirm the&amp;nbsp;behavior&amp;nbsp;in AutoCAD Map 2016&amp;nbsp;?&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The behavior for 2012, 2014 and 2016 is the same -- thus wrong form MTEXT compared to PLINE.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also note that both the MTEXT and MLEADER commmand's are wrong.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As mentioned in my previous posts i can "repair" it wit the SHACTMTLY command but it will change the active layer permanently.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2015 09:06:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5781514#M38940</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-08-21T09:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: ToolPalette Show Active Layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5784041#M38941</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have logged this behavior in our internal database for our engineering team to analyze it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not see a better workaround than what you already found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may need to reset the CLAYER after the MText command ends.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using ArxDbg, a look at the series of reactor calls indicate a similar reset of the CLAYER after the MText command ends.&lt;/P&gt;
&lt;P&gt;I have attached a screenshot of it and&amp;nbsp;it should be possible to do that manually from your code too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Balaji&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2015 06:06:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5784041#M38941</guid>
      <dc:creator>Balaji_Ram</dc:creator>
      <dc:date>2015-08-24T06:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: ToolPalette Show Active Layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5784069#M38942</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Balaji,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Ok, thanks for the tip.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2015 06:44:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/toolpalette-show-active-layer/m-p/5784069#M38942</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-08-24T06:44:38Z</dc:date>
    </item>
  </channel>
</rss>

