<?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 make .bundle install run a command each time drawing is opened in Visual LISP, AutoLISP and General Customization Forum</title>
    <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-make-bundle-install-run-a-command-each-time-drawing-is/m-p/7767029#M108964</link>
    <description>&lt;P&gt;Yes, they are both available.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, regarding the way the order of execution, notice how the perDocument component entry is BEFORE the perSession component entry?&amp;nbsp; I&amp;nbsp; had to do it this way to&amp;nbsp;force the perSession to run FIRST.&amp;nbsp; Just plain backwards.&amp;nbsp; I'll give a kudos to anyone who can explain the rational for that!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;James&lt;/P&gt;</description>
    <pubDate>Fri, 09 Feb 2018 22:35:05 GMT</pubDate>
    <dc:creator>CADdaddy.com</dc:creator>
    <dc:date>2018-02-09T22:35:05Z</dc:date>
    <item>
      <title>How to make .bundle install run a command each time drawing is opened</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-make-bundle-install-run-a-command-each-time-drawing-is/m-p/7766329#M108962</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've got a project that has&amp;nbsp;one&amp;nbsp;lisp function I want to run at the beginning of the session, "acad.lsp style"...and a different function that I want to run each time a document is opened, "acaddoc.lsp style". Both functions run fine when starting the session but the "per Document" code never runs when opening a new document.&amp;nbsp; Can someone help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is my test code:&lt;/P&gt;
&lt;PRE&gt;(defun c:PerSessionCommand ()
	(princ "\nAddin Per Session running...")
	(princ)
)

(defun c:PerDocumentCommand ()
	(princ "\nAddin Per Document running...")
	(princ)
)&lt;/PRE&gt;
&lt;P&gt;Here&amp;nbsp;are my components from PackageContents.xml&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  &amp;lt;Components&amp;gt;
	&amp;lt;RuntimeRequirements  OS="Win64" Platform="AutoCAD*" SeriesMin="R20.0"  SeriesMax="R22.0" /&amp;gt;

        &amp;lt;ComponentEntry
		AppName="StartupPerDocument"
		ModuleName="./Contents/testStartup.lsp"
		PerDocument="True"
		LoadOnAutoCADStartup="True"&amp;gt;
		&amp;lt;Commands GroupName="StartupPerDocument"&amp;gt;
			&amp;lt;Command Local="PerDocumentCommand" Global="PerDocumentCommand" StartupCommand="True" /&amp;gt;
      		&amp;lt;/Commands&amp;gt;
	&amp;lt;/ComponentEntry&amp;gt;

        &amp;lt;ComponentEntry
		AppName="StartupPerSession"
		ModuleName="./Contents/testStartup.lsp"
		PerDocument="False"
		LoadOnAutoCADStartup="True"&amp;gt;
		&amp;lt;Commands GroupName="StartupPerSession"&amp;gt;
			&amp;lt;Command Local="PerSessionCommand" Global="PerSessionCommand" StartupCommand="True" /&amp;gt;
      		&amp;lt;/Commands&amp;gt;
	&amp;lt;/ComponentEntry&amp;gt;
  &amp;lt;/Components&amp;gt;&lt;/PRE&gt;
&lt;P&gt;This is starting the session when both run fine.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Session.PNG" style="width: 371px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/461270i07969AD97792AF52/image-size/large?v=v2&amp;amp;px=999" role="button" title="Session.PNG" alt="Session.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nothing from addin runs when opening a new document.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Document.PNG" style="width: 316px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/461269i60F5346E594A6AEC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Document.PNG" alt="Document.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I must be missing something.&amp;nbsp; Right?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;James LeVieux&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 18:12:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-make-bundle-install-run-a-command-each-time-drawing-is/m-p/7766329#M108962</guid>
      <dc:creator>CADdaddy.com</dc:creator>
      <dc:date>2018-02-09T18:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to make .bundle install run a command each time drawing is opened</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-make-bundle-install-run-a-command-each-time-drawing-is/m-p/7766987#M108963</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you try to run the PerSessionCommand and PerDocumentCommand in the second drawing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As far as I know: StartupCommand="True" make the command &lt;STRONG&gt;run at startup&lt;/STRONG&gt; (when starting the session), but the testStartup.lsp should be &lt;STRONG&gt;load in each document&lt;/STRONG&gt; because it's the default behavior for LISP applications (LoadReasons mainly apply to .NET or ObjectARX applications).&lt;/P&gt;
&lt;P&gt;Overall you have two CompenentEntry related to the same Module (LISP file).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See &lt;A href="http://adndevblog.typepad.com/autocad/2013/01/autodesk-autoloader-white-paper.html" target="_blank"&gt;&amp;gt;&amp;gt;here&amp;lt;&amp;lt;&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 22:06:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-make-bundle-install-run-a-command-each-time-drawing-is/m-p/7766987#M108963</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-02-09T22:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to make .bundle install run a command each time drawing is opened</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-make-bundle-install-run-a-command-each-time-drawing-is/m-p/7767029#M108964</link>
      <description>&lt;P&gt;Yes, they are both available.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, regarding the way the order of execution, notice how the perDocument component entry is BEFORE the perSession component entry?&amp;nbsp; I&amp;nbsp; had to do it this way to&amp;nbsp;force the perSession to run FIRST.&amp;nbsp; Just plain backwards.&amp;nbsp; I'll give a kudos to anyone who can explain the rational for that!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;James&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 22:35:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-make-bundle-install-run-a-command-each-time-drawing-is/m-p/7767029#M108964</guid>
      <dc:creator>CADdaddy.com</dc:creator>
      <dc:date>2018-02-09T22:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to make .bundle install run a command each time drawing is opened</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-make-bundle-install-run-a-command-each-time-drawing-is/m-p/7804249#M108965</link>
      <description>&lt;P&gt;I never found a solutions but I did find a workaround:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The workaround (that works for me since I'm using cuix menus) is to&amp;nbsp;execute the function in the .mnl lisp file that runs each time a menu is loaded.&amp;nbsp; This ensures that the function is always run when a new drawing is opened and after the drawing is fully initialized.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But this&amp;nbsp;workaround brings another problem:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two separate bundle packages in the&amp;nbsp;"ApplicationPlugins" folder.&amp;nbsp; &amp;nbsp;Each has a separate menu with a separate .mnl file that runs a function upon opening the drawing. Each bundle works correctly when the other bundle is not present.&amp;nbsp; When both&amp;nbsp;bundles are available,&lt;SPAN&gt;&amp;nbsp;only one of the programs run when a new drawing is opened.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This is what the MNL for menu A looks like:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;(defun-q S::STARTUP ( ) 
  (princ (load "MyProgramA.vlx"  "\n...Can't load MyProgramA.vlx"))
  (c:myfunctionA)
  (princ)
)&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This is what the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;MNL for menu B looks like:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;(defun-q S::STARTUP ( ) 
  (princ (load "MyProgramB.vlx"  "\n...Can't load MyProgramB.vlx"))
  (c:myfunctionB)
  (princ)
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It appears that the S::STARTUP is never run on&amp;nbsp;&amp;nbsp;program B because I can see that the menu B is loaded but I find that the functions in "MyProgramB" are not available when a new drawing is opened.&amp;nbsp; Is in not possible to have two S::STARTUP functions?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;James&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 19:30:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-make-bundle-install-run-a-command-each-time-drawing-is/m-p/7804249#M108965</guid>
      <dc:creator>CADdaddy.com</dc:creator>
      <dc:date>2018-02-23T19:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to make .bundle install run a command each time drawing is opened</title>
      <link>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-make-bundle-install-run-a-command-each-time-drawing-is/m-p/7804346#M108966</link>
      <description>&lt;P&gt;No, you cannot have two S::STARTUP function, this is why, typically, the S:STARTUP function is a (defun-q ...) function so that it ca can be defined from several places:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the MNL for menu A:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(if S::STARTUP
  (setq	S::STARTUP
	 (append S::STARTUP
		 '((princ (load "MyProgramA.vlx" "\n...Can't load MyProgramA.vlx"))
		   (c:myfunctionA)
		   (princ)
		  )
	 )
  )
  (defun-q S::STARTUP
	   ()
	   (princ (load "MyProgramA.vlx" "\n...Can't load MyProgramA.vlx"))
	   (c:myfunctionA)
	   (princ)
  )
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the MNL for menu B:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;(if S::STARTUP
  (setq	S::STARTUP
	 (append S::STARTUP
		 '((princ (load "MyProgramB.vlx" "\n...Can't load MyProgramBB.vlx"))
		   (c:myfunctionB)
		   (princ)
		  )
	 )
  )
  (defun-q S::STARTUP
	   ()
	   (princ (load "MyProgramB.vlx" "\n...Can't load MyProgramB.vlx"))
	   (c:myfunctionB)
	   (princ)
  )
)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 20:00:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/how-to-make-bundle-install-run-a-command-each-time-drawing-is/m-p/7804346#M108966</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-02-23T20:00:14Z</dc:date>
    </item>
  </channel>
</rss>

