<?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 stop initializing my .net plugin in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-stop-initializing-my-net-plugin/m-p/9919782#M17815</link>
    <description>&lt;P&gt;I prefer calling a method that tests a variable at the start of each command and returning if the condition to fail is met (after displaying a helpful message). That way, the user sees a message explaining why the command is not available, as opposed to just "Unknown command", which is likely to trigger a request for support.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;in my IExtensionApplication instance I need to stop loading the plugin for certain conditions. What I would like to achieve is that the commands from my dll are not getting defined/can not be used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to this blog post I should be able to achieve this by throwing an exception in my IExtensionApplication instance. But this is not working, even when I throw that exception the commands are defined (AutoCAD 2021).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there another way?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Dec 2020 01:52:50 GMT</pubDate>
    <dc:creator>ActivistInvestor</dc:creator>
    <dc:date>2020-12-07T01:52:50Z</dc:date>
    <item>
      <title>How to stop initializing my .net plugin</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-stop-initializing-my-net-plugin/m-p/9917242#M17814</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;in my IExtensionApplication instance I need to stop loading the plugin for certain conditions. What I would like to achieve is that the commands from my dll are not getting defined/can not be used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to this blog post I should be able to achieve this by throwing an exception in my IExtensionApplication instance. But this is not working, even when I throw that exception the commands are defined (AutoCAD 2021).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there another way?&lt;/P&gt;</description>
      <pubDate>Sat, 05 Dec 2020 09:04:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-stop-initializing-my-net-plugin/m-p/9917242#M17814</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-12-05T09:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop initializing my .net plugin</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-stop-initializing-my-net-plugin/m-p/9919782#M17815</link>
      <description>&lt;P&gt;I prefer calling a method that tests a variable at the start of each command and returning if the condition to fail is met (after displaying a helpful message). That way, the user sees a message explaining why the command is not available, as opposed to just "Unknown command", which is likely to trigger a request for support.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;in my IExtensionApplication instance I need to stop loading the plugin for certain conditions. What I would like to achieve is that the commands from my dll are not getting defined/can not be used.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;According to this blog post I should be able to achieve this by throwing an exception in my IExtensionApplication instance. But this is not working, even when I throw that exception the commands are defined (AutoCAD 2021).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there another way?&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Dec 2020 01:52:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-stop-initializing-my-net-plugin/m-p/9919782#M17815</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2020-12-07T01:52:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop initializing my .net plugin</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-stop-initializing-my-net-plugin/m-p/9926039#M17816</link>
      <description>&lt;P&gt;Thanks this is what I do now. But the requirement is to not to load the commands. So users can not see what commands are available.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2020 09:06:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-stop-initializing-my-net-plugin/m-p/9926039#M17816</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-12-09T09:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop initializing my .net plugin</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-stop-initializing-my-net-plugin/m-p/9926204#M17817</link>
      <description>&lt;P&gt;@Anonymous&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case you have not define command with CommandMethod attribute, but define with help of Autodesk.AutoCAD.Internal.Utils.AddCommand(string cmdGroupName, string cmdGlobalName, string cmdLocalName, CommandFlags cmdFlags, CommandCallback func) method in your IExtensionApplication.Initialize method only if you condition allowed it.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Internal;
 
// This line is not mandatory, but improves loading performances
[assembly: ExtensionApplication(typeof(CommandUtils.MyPlugin))]
 
namespace CommandUtils
{
  public class MyPlugin : IExtensionApplication
  {
    static bool condition = false;
    void IExtensionApplication.Initialize()
    {
      
      if (condition)
      {
         Utils.AddCommand("RIVILIS", "TEST1", "ТЕСТ1", CommandFlags.Modal, CommandHandler1);
         Utils.AddCommand("RIVILIS", "TEST2", "ТЕСТ2", CommandFlags.Modal, CommandHandler2);
      }
    }
 
    void IExtensionApplication.Terminate()
    {
      if (condition)
      {
	 Utils.RemoveCommand("RIVILIS", "TEST1");
	 Utils.RemoveCommand("RIVILIS", "TEST2");
      }
    }
    public void CommandHandler1()
    {
      Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
      ed.WriteMessage("\nCommand Test1");
    }
    public void CommandHandler2()
    {
      Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
      ed.WriteMessage("\nCommand Test2");
    }
  }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 09 Dec 2020 10:50:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-stop-initializing-my-net-plugin/m-p/9926204#M17817</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2020-12-09T10:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to stop initializing my .net plugin</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-stop-initializing-my-net-plugin/m-p/9942474#M17818</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/481027"&gt;@Alexander.Rivilis&lt;/a&gt;awesome, exactly what I need, thank you&lt;/P&gt;</description>
      <pubDate>Tue, 15 Dec 2020 21:37:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-stop-initializing-my-net-plugin/m-p/9942474#M17818</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-12-15T21:37:24Z</dc:date>
    </item>
  </channel>
</rss>

