<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blog nauseam &#187; Startup</title>
	<atom:link href="http://www.blog.cadnauseam.com/tag/startup/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blog.cadnauseam.com</link>
	<description>Mostly AutoCAD discussion, but also music, image manipulation and video</description>
	<lastBuildDate>Wed, 18 Jan 2012 06:02:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>AutoCAD 2012 &#8211; Autoloader mechanism for plug-ins</title>
		<link>http://www.blog.cadnauseam.com/2011/04/20/autocad-2012-autoloader-mechanism-for-plug-ins/</link>
		<comments>http://www.blog.cadnauseam.com/2011/04/20/autocad-2012-autoloader-mechanism-for-plug-ins/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 09:29:38 +0000</pubDate>
		<dc:creator>Steve Johnson</dc:creator>
				<category><![CDATA[AutoCAD]]></category>
		<category><![CDATA[AutoCAD 2012]]></category>
		<category><![CDATA[ClassicArray]]></category>
		<category><![CDATA[Customisation]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Interoperability]]></category>
		<category><![CDATA[LISP]]></category>
		<category><![CDATA[Other Autodesk Products]]></category>
		<category><![CDATA[Win]]></category>
		<category><![CDATA[Autoloader]]></category>
		<category><![CDATA[Plug-in]]></category>
		<category><![CDATA[Startup]]></category>

		<guid isPermaLink="false">http://www.blog.cadnauseam.com/?p=1451</guid>
		<description><![CDATA[<p>One of the less obvious features introduced by AutoCAD 2012 is the Autoloader mechanism that has been provided to make installation of plug-ins (current standard Autodeskspeak for add-ons, apps, utilities, routines, etc.) easier for both developers and users. It may not be immediately obvious, but it&#8217;s a useful and important addition.</p> <p>This mechanism has [...]]]></description>
			<content:encoded><![CDATA[<p>One of the less obvious features introduced by AutoCAD 2012 is the Autoloader mechanism that has been provided to make installation of plug-ins (current standard Autodeskspeak for add-ons, apps, utilities, routines, etc.) easier for both developers and users. It may not be immediately obvious, but it&#8217;s a useful and important addition.</p>
<p>This mechanism has nothing to do with the AppLoad command, the Startup Suite, acad*.lsp, the (autoload) function or anything else that existed in earlier releases. This is completely new, it has not replaced or broken any of the existing loading mechanisms, and is, in short, A Good Thing. Developers don&#8217;t have to use it, but those who do, and their customers, will have certain advantages. I have used it for the <a href="http://www.classicarray.com">ClassicArray</a> loading mechanism, and I expect to see it used by more and more plug-ins over time. It works fine with all of the usual AutoCAD add-on APIs, including LISP.</p>
<p><strong>User perspective</strong><br />
As a user, what this means is that for AutoCAD and related applications from 2012 on, there is a standard loading mechanism for plug-ins. The installation should be straightforward, with no multi-step processes to go through for different AutoCAD variants and releases. The result of the installation should automatically present itself in a standard way, with a short-lived welcome bubble, an extra panel in the new Plug-ins Ribbon tab, plus any other interface additions the developer wants to provide. If you subsequently install another AutoCAD variant or release, the plug-in will automatically appear in that variant with no further user action required, as long as that AutoCAD variant is supported by the plug-in.</p>
<p><strong>Developer perspective</strong><br />
What this means for me as a developer is that I have much less to worry about in terms of installation. All that needs to be done to make the loading happen is for a folder full of &#8216;stuff&#8217; to be copied into a certain location. (There are actually two possible locations, but more on that later).</p>
<p>In Betas of ClassicArray, I just provided the folder, plus instructions that asked the user to copy that folder into place. I could have simplified that further by providing batch files that did the copying. In the end, I created setup executables using the free <a href="http://www.jrsoftware.org/">Inno Setup</a> utility, but that was a much easier job that it would have been if this Autoloader mechanism didn&#8217;t exist. I didn&#8217;t have to worry about discovering what releases were installed, deciphering Registry entries, creating user installaton scripts, or issuing instructions to users to edit files or mess with the AppLoad command. I don&#8217;t have to worry about what happens if the user subsequently installs another AutoCAD variant.</p>
<p>Of course, for developers who support releases prior to 2012, there is no less work to do than before, and some time needs to be spent to learn and implement the new mechanism. In the case of ClassicArray, that was not an issue because it&#8217;s only needed and supported in 2012. I expect this is one of those problems that will resolve itself over time as developers adopt the new mechanism.</p>
<p><strong>The bundle folder</strong><br />
So what is this &#8216;stuff&#8217; that needs copying into place? It&#8217;s called a bundle folder. It&#8217;s just a folder with a name that ends in .bundle (e.g. ClassicArray.bundle), and it typically contains the usual files needed to run your add-in, often tidied up within other folders. The only new thing that it needs to contain is a file called PackageContents.xml. That XML file is the key to the Autoloader mechanism. AutoCAD finds the file, reads it, and acts accordingly in terms of version support, loading program files, partial cuix files and so on.</p>
<p><strong>Bundle folder location</strong><br />
So where does this folder with its XML file have to go? There are two possible locations. If you want the plug-in to be available to all users on the computer, you place it in the Autodesk\ApplicationPlugins folder underneath the system&#8217;s ProgramFiles folder. For example, ClassicArray usually gets put here:</p>
<p><code>C:\Program Files\Autodesk\ApplicationPlugins\ClassicArray.bundle</code></p>
<p>If you only want the plug-in to be loaded for the current user, it goes in the Autodesk\ApplicationPlugins folder underneath the system&#8217;s AppData folder instead, for example:</p>
<p><code>C:\Documents and Settings\[login]\Application Data\Roaming\Autodesk\ApplicationPlugins\ClassicArray.bundle</code></p>
<p>in XP or</p>
<p><code>C:\Users\[login]\AppData\Roaming\Autodesk\ApplicationPlugins\ClassicArray.bundle</code></p>
<p>in Windows 7.</p>
<p>Describing the contents of that all-important XML file is beyond the scope of this post, but I may do a follow-up post if there is enough interest. In either case, the reference material is available in the AutoCAD Help, under Help &gt; Customization Guide &gt; Introduction to Programming Interfaces &gt; Install and Uninstall Plug-In Applications &gt; PackageContents.xml Format.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.cadnauseam.com/2011/04/20/autocad-2012-autoloader-mechanism-for-plug-ins/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>What is loaded at AutoCAD startup, and when?</title>
		<link>http://www.blog.cadnauseam.com/2008/09/01/what-is-loaded-at-autocad-startup-and-when/</link>
		<comments>http://www.blog.cadnauseam.com/2008/09/01/what-is-loaded-at-autocad-startup-and-when/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 06:03:48 +0000</pubDate>
		<dc:creator>Steve Johnson</dc:creator>
				<category><![CDATA[AutoCAD]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[LISP]]></category>
		<category><![CDATA[Tip]]></category>
		<category><![CDATA[AutoLISP]]></category>
		<category><![CDATA[CUI]]></category>
		<category><![CDATA[Startup]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://www.blog.cadnauseam.com/?p=157</guid>
		<description><![CDATA[<p>Warning, CAD nerd stuff ahead. This is a long and technical post and if you&#8217;re using AutoCAD in a largely out-of-the-box state you probably won&#8217;t care about any of it.</p> <p>If your modification of AutoCAD extends beyond the trivial, you may find it useful to know what AutoCAD loads, and in what order things [...]]]></description>
			<content:encoded><![CDATA[<p>Warning, CAD nerd stuff ahead. This is a long and technical post and if you&#8217;re using AutoCAD in a largely out-of-the-box state you probably won&#8217;t care about any of it.</p>
<p>If your modification of AutoCAD extends beyond the trivial, you may find it useful to know what AutoCAD loads, and in what order things are loaded. It is possible for LISP files in particular to tread on each other&#8217;s toes, so knowing what gets loaded when can be useful information for diagnosing such clashes. This post aims to provide that information. It uses AutoCAD 2009 as an example, but the same principles apply to all releases from AutoCAD 2006 onwards.</p>
<p>On startup, the first things AutoCAD loads are its CUI files. It first loads the Enterprise CUI file, then the Main CUI file, then any partial CUI files attached to the Main, then any partial CUI files attached to the Enterprise. I have no idea of the reasoning behind this slightly strange order, but there it is. The order of the partial CUIs loaded in each case is determined by the order in which they appear in the parent CUI files, which is determined by the order in which you attached them. If you don&#8217;t like this order, you can attach and reattach them in the CUI interface, or you can do the same thing much quicker with a text editor if you feel confident enough. If there are LISP files associated with these CUI files, they are not loaded yet. You&#8217;ll need to wait a few paragraphs for that.</p>
<p>Next, if you have created a file called acad.rx in AutoCAD&#8217;s search path, any ARX files listed in that file will be loaded. There are other ways in which developers can load their ARX files at startup, but I won&#8217;t go into that here.</p>
<p>Following that, the acad*.lsp files are loaded. First, Autodesk&#8217;s acad2009.lsp file is loaded. Next, if you have created a file called acad.lsp, that is loaded. These two files are only loaded at first startup, unless the ACADLSPASDOC system variable is set to 1, in which case the acad.lsp file is reloaded with each new drawing. Next comes Autodesk&#8217;s acad2009doc.lsp and any acaddoc.lsp file you may have created, in that order. These two files are loaded at startup and with every new drawing session.</p>
<p>It&#8217;s worth pointing out here that the acad200x.lsp and acaddoc200x.lsp files are Autodesk&#8217;s and are not intended to be modified by users. You <em>can</em> modify them, and adding things in there works fine, but updates and hotfixes can overwrite these files, leaving you to patch things up again afterwards. The acad.lsp and acaddoc.lsp files are <em>yours</em>, and that is where you are best advised to put your additions.</p>
<p>I hesitate to mention VBA because I have long avoided that development environment and my knowledge in that area is very limited, but if you&#8217;re a VBA developer and have created an acad.dvb file in AutoCAD&#8217;s search path, it gets loaded at this point.</p>
<p>Once the acad*.* files are loaded, <em>then</em> come any LISP files associated with the CUI files that were loaded at the beginning. For each CUI file, if there is a *.mnl file of the same name, that will be loaded first (*.mnl files are just *.lsp files renamed). After that, any LISP files that are specified in the CUI file will be loaded, in the order in which they appear in the CUI file itself. This order can be modified in the same ways that the partial CUI loading sequence can be modified; &#8220;delete&#8221; and &#8220;load&#8221; (detach and attach, really) the files within the CUI interface, or hack the CUI file with a text editor.</p>
<p>The CUI-associated LISP files are loaded as described in the above paragraph for each CUI file in turn, in the same order as the CUI files themselves: Enterprise, then Main, then partials to Main, then partials to Enterprise.</p>
<p>The Appload command provides a Startup Suite facility, where you can specify any number of files to load (*.arx, *.lsp, *.dvb, *.dbx, *.vlx or *.fas). If you have done so, those files are loaded at this point, in the order in which they appear in the Startup Suite list.</p>
<p>That&#8217;s all the actual loading done, but we&#8217;re not finished yet. At this point AutoCAD&#8217;s environment should be all ready to do pretty much anything, including things that modify the drawing database, including invoking commands. This was <em>not</em> true earlier on, so if you want to do things like change the drawing or run commands, this should be done using a startup routine rather than called directly at load time from any of the files loaded above.</p>
<p>If you&#8217;ve defined a VBA sub called AcadStartup(), it will be called now. If starting a new drawing, any sub called AcadDocument_Activate() will be called instead. The caveat about my VBA ignorance still applies here.</p>
<p>If a LISP function called (S::STARTUP) has been defined, it will be called next. Where could that be defined? Anywhere in any of the LISP files mentioned above, or in any LISP or other files that are loaded by any of those files, or by any files that are loaded by any of <em>those</em> files, and so on ad infinitum. It could even be defined in one of the ARX files loaded at any point. This would be unusual, but is quite possible.</p>
<p>If there are multiple (S::STARTUP) functions defined in various places, which one wins? Whichever one loaded last. That&#8217;s why the load order can be important, but it&#8217;s also why you should never have an unconditional (defun S::STARTUP &#8230;) definition in your LISP code. Instead, you should append your startup code to any existing (S::STARTUP) function. That way, your startup can cooperate with any others in your environment rather than walking all over it. If there is some interest in that subject, I can cover it in more detail in a future post.</p>
<p>In summary, here is the AutoCAD startup sequence:</p>
<p><strong>A. CUI files loaded:</strong><br />
1. Enterprise<br />
2. Main<br />
3. Partials to Main<br />
4. Partials to Enterprise</p>
<p><strong>B. acad*.* files loaded:</strong><br />
1. Files listed in acad.rx<br />
2. acad2009.lsp<br />
3. acad.lsp<br />
4. acad2009doc.lsp<br />
5. acaddoc.lsp<br />
6. acad.dvb</p>
<p><strong>C. CUI-associated MNL and LSP files loaded:</strong><br />
1. Enterprise named MNL<br />
2. Enterprise loaded LSP and MNL<br />
3. Main named MNL<br />
4. Main loaded LSP and MNL<br />
5. Partials to Main named MNLs<br />
6. Partials to Main loaded LSPs and MNLs<br />
7. Partials to Enterprise named MNLs<br />
8. Partials to Enterprise loaded LSPs and MNLs</p>
<p><strong>D. Startup suite files loaded</strong></p>
<p><strong>E. Startup routines run:</strong><br />
1. AcadStartup() called (AutoCAD startup)<br />
2. AcadDocument_Activate() called (Drawing startup)<br />
3. (S::STARTUP) called</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.cadnauseam.com/2008/09/01/what-is-loaded-at-autocad-startup-and-when/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
	</channel>
</rss>

