<?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: Conditional plug-in load in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3746082#M51892</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Application.DocumentManager.MdiActiveDocument.Name returns the current drawing's filename.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you don't want the command to run in a given document, display a message telling the user that, rather than making it look like an error or failure to load the plug-in, that is, unless you enjoy being bombarded with support requests.&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;</description>
    <pubDate>Fri, 04 Jan 2013 14:40:17 GMT</pubDate>
    <dc:creator>DiningPhilosopher</dc:creator>
    <dc:date>2013-01-04T14:40:17Z</dc:date>
    <item>
      <title>Conditional plug-in load</title>
      <link>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3742737#M51885</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to get my plug-in to successfully load its commands only if certain parameters are met like a prefix in the DWG file name. (I know I would have to use GETSYSTEMVARIABLE("DWGNAME") ) &amp;nbsp;I haven't been able to implement a restriction successfully.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, is there a way to load a plug-in only within the scope of a document and not the entire AutoCAD executable?&lt;/P&gt;&lt;P&gt;This way, if the user has open document A and it's not a valid document of use of the plug-in, he won't be able to use the commands, but if he loads document B with a valid format (name prefix), the plug-ing will automatically load for the document B intance only. Is this possible?&lt;/P&gt;&lt;P&gt;(Working with AutoCAD 2010 and .net 3.5)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P)lease let me know if it's not possible under that configureation but it is for other configurations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 26 Dec 2012 15:53:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3742737#M51885</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2012-12-26T15:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional plug-in load</title>
      <link>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3742926#M51886</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#666699"&gt;&amp;gt;&amp;gt; I haven't been able to implement a restriction successfully&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Not beautiful, but possible: if the test fails (so your DLL should not be loaded) you can raise an unhandled exception within the INITIALIZE part of your DLL (e.g. do a division by 0 or access a file that does not exist or ...., but without try-catch).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#666699"&gt;&amp;gt;&amp;gt; to load a plug-in only within the scope of a document&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;AFAIK no.&lt;/P&gt;&lt;P&gt;But you may test at your commands if a restriction-test fails or succeeds, then execute the internal of your command or bypass it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Wed, 26 Dec 2012 22:08:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3742926#M51886</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-12-26T22:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional plug-in load</title>
      <link>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3743857#M51887</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/389680"&gt;@Alfred.NESWADBA&lt;/a&gt; wrote:&lt;BR /&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#666699"&gt;&amp;gt;&amp;gt; I haven't been able to implement a restriction successfully&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Not beautiful, but possible: if the test fails (so your DLL should not be loaded) you can raise an unhandled exception within the INITIALIZE part of your DLL (e.g. do a division by 0 or access a file that does not exist or ...., but without try-catch).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Sorry, that won't work. Throwing an exception in Initialize() &lt;STRONG&gt;does not prevent the plug-in assembly from loading&lt;/STRONG&gt;, because it is already loaded at that point. After that, there is nothing the OP could do to register the commands when he does want them to be available.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Dec 2012 07:52:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3743857#M51887</guid>
      <dc:creator>DiningPhilosopher</dc:creator>
      <dc:date>2012-12-29T07:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional plug-in load</title>
      <link>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3743859#M51888</link>
      <description>&lt;P&gt;I'm afraid there's no simple (or difficult) way to do what you ask.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The easiest way to accomplish it is to simply check the active document when the command(s) are issued.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It would probably be better to do that, because it wouldn't leave the user wondering why commands are not available in one document but are in others, with no explaination.&lt;/P&gt;</description>
      <pubDate>Sat, 29 Dec 2012 07:55:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3743859#M51888</guid>
      <dc:creator>DiningPhilosopher</dc:creator>
      <dc:date>2012-12-29T07:55:34Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional plug-in load</title>
      <link>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3743884#M51889</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#666699"&gt;&amp;gt;&amp;gt; Sorry, that won't work. Throwing an exception in Initialize() &lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#666699"&gt;&amp;gt;&amp;gt; &lt;STRONG&gt;does not prevent the plug-in assembly from loading&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Yes and sorry, you are absolutly right, I was to focused on the "commands not working". With my solution AutoCAD would have to be restarted to get it running (that's what I use for protection as it's then more difficult to debug). But in this case (when the correct drawing is activated afterwards) the command should work.&lt;/P&gt;&lt;P&gt;I would then suggest to let the command be enabled, but within each command first the test should be done if the command should act in that case or not, if not I would send a message for "why it's not working here".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx for correction!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Sat, 29 Dec 2012 12:47:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3743884#M51889</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-12-29T12:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional plug-in load</title>
      <link>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3745729#M51890</link>
      <description>&lt;P&gt;Once a document meets the requirements and it is loaded then the commands should be avialable to all documents.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jan 2013 20:34:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3745729#M51890</guid>
      <dc:creator>jeff</dc:creator>
      <dc:date>2013-01-03T20:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional plug-in load</title>
      <link>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3746027#M51891</link>
      <description>&lt;PRE&gt;String prefix = "MyCompanyName";
if ( !((String)GETSYSTEMVARIABLE("DWGNAME")).Contains(prefix) )
{
  //Send command load failure message
  return;
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I guess do it this way for each command?&lt;/P&gt;</description>
      <pubDate>Fri, 04 Jan 2013 13:48:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3746027#M51891</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-01-04T13:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional plug-in load</title>
      <link>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3746082#M51892</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Application.DocumentManager.MdiActiveDocument.Name returns the current drawing's filename.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you don't want the command to run in a given document, display a message telling the user that, rather than making it look like an error or failure to load the plug-in, that is, unless you enjoy being bombarded with support requests.&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;</description>
      <pubDate>Fri, 04 Jan 2013 14:40:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/conditional-plug-in-load/m-p/3746082#M51892</guid>
      <dc:creator>DiningPhilosopher</dc:creator>
      <dc:date>2013-01-04T14:40:17Z</dc:date>
    </item>
  </channel>
</rss>

