Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2011 Autodesk CP5239 Demand-Loading AutoCAD®.NET Plug-ins James E. Johnson Synergis Software Sr. CAD Developer.

Similar presentations


Presentation on theme: "© 2011 Autodesk CP5239 Demand-Loading AutoCAD®.NET Plug-ins James E. Johnson Synergis Software Sr. CAD Developer."— Presentation transcript:

1 © 2011 Autodesk CP5239 Demand-Loading AutoCAD®.NET Plug-ins James E. Johnson Synergis Software Sr. CAD Developer

2 © 2011 Autodesk Demand-Loading AutoCAD®.NET Plug-ins CP5239 This class will discuss and illustrate required registry settings for demand-loading a.NET or ObjectARX® plug-in. We will examine code samples that illustrate how to make an AutoCAD plug-in add the demand-load registry settings when it is first loaded and how to create a command that removes the registry settings. We will also discuss the new AutoCAD AutoLoader for automatic loading of ObjectARX and.NET plug-ins. This is an Intermediate Level Lecture…

3 © 2011 Autodesk Learning Objectives At the end of this class, you will be able to:  Setting demand-load registry settings  Manage demand-load registry settings from your code.  Prepare code and setups required for installers.  Use the AutoCAD AutoLoader to automatically load plug-ins.

4 © 2011 Autodesk Setting demand-load registry settings

5 © 2011 Autodesk Setting demand-load registry settings  Demand load settings are stored in one of two places in the registry:  HKEY_LOCAL_MACHINE (for all users requires privileges for installers)  HKEY_CURRENT_USER (for current user only) The decision on which will depend on if the application is to be shared across all users but also if using an installer that the user has privileges to write to HKEY_LOCAL_MACHINE.

6 © 2011 Autodesk Setting demand-load registry settings HKEY_LOCAL_MACHINE\Software\Autodesk\AutoCAD\R18.2\ACAD-A001:409 Under the Software\Autodesk\AutoCAD key is Release version key (e.g. R18.2) A001 is the product ID for AutoCAD 2012. 409 is English version

7 © 2011 Autodesk Loading applications on AutoCAD Startup Under HKEY_LOCAL_MACHINE\Software\Autodesk\AutoCAD\R18.2\ACAD- A001:409\Applications we add a registry key for our application. This shows an application named CSharpPlugin added. With settings to demand load the application on startup.

8 © 2011 Autodesk Loading applications on AutoCAD Startup  A registry reg file could be created to create this file with the following contents, in the next section we will look at some code examples to create these settings with code and later with an installer: Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R18.2\ACAD- A001:409\Applications\CSharpPlugin] "DESCRIPTION"="C# sample plugin" "LOADCTRLS"=dword:00000002 "LOADER"="C:\\Users\\Administrator\\Documents\\Visual Studio 2010\\Projects\\CSharpPlugin\\CSharpPlugin\\bin\\Release\\CSharpPlugin.dll" "MANAGED"=dword:00000001

9 © 2011 Autodesk Loading applications on AutoCAD Startup "DESCRIPTION" is any text string to describe the application "LOADCTRLS" defines the action demand load action 0x01 Load the application upon detection of proxy object. 0x02 Load the application upon startup. 0x04 Load the application upon invocation of a command. 0x08 Load the application upon request by the user or another application. 0x10 Do not load the application. 0x20 Load the application transparently. A value of 2 like the sample ‘reg’ file contents will demand load the application on startup and is used to load the application when AutoCAD starts, a setting of 4 with some additional values will load on command invocation. These are the two settings most commonly used for.NET plugin applications.  "LOADER" must contain the location of the application  "MANAGED" must be set to 1 for.NET applications

10 © 2011 Autodesk Loading applications on AutoCAD Startup "DESCRIPTION" is any text string to describe the application "LOADCTRLS" defines the action demand load action 0x01 Load the application upon detection of proxy object. 0x02 Load the application upon startup. 0x04 Load the application upon invocation of a command. 0x08 Load the application upon request by the user or another application. 0x10 Do not load the application. 0x20 Load the application transparently. A value of 2 like the sample ‘reg’ file contents will demand load the application on startup and is used to load the application when AutoCAD starts, a setting of 4 with some additional values will load on command invocation. These are the two settings most commonly used for.NET plugin applications.  "LOADER" must contain the location of the application  "MANAGED" must be set to 1 for.NET applications

11 © 2011 Autodesk Loading applications on Command Invocation Creating a sub key under the Application key named commands allows setting up the demand loading to load the application on command invocation. Add string settings to the key for each command in the application that you want to be able to load the application... To load the command on invocation of the command you would set LOADCTRLS to 4 Add string settings to the key for

12 © 2011 Autodesk Loading applications on Command Invocation In addition to the “Commands” key you can also create a key named “Groups” then add string settings for any command groups that your application uses. The only group used in the example is LOADGROUP.

13 © 2011 Autodesk Loading applications on Command Invocation Note: In AutoCAD the DEMANDLOAD system variable controls the demand loading options of ObjectARX applications. The legitimate for the system variable may be used in combination. They are defined as follows:  0 Disables demand loading of all ObjectARX applications.  1 Enables demand loading of ObjectARX applications upon detection of proxy objects.  2 Enables demand loading of ObjectARX applications upon command invocation.  3 Enables demand loading for both proxy objects and command invocation

14 © 2011 Autodesk Manage demand-load registry settings from your code

15 © 2011 Autodesk Manage demand-load registry settings from your code In simple applications it is often easy to add code in the application to add or remove the demand load registry settings… Look at example code…

16 © 2011 Autodesk Prepare code and setups required for installers

17 © 2011 Autodesk Prepare code and setups required for installers To create demand loading in a setup project requires doing similar setup in your Setup project as we did above in the example demand loading code. In Visual Studio Create a new setup project and open the registry editor...

18 © 2011 Autodesk Prepare code and setups required for installers Under Applications key add a key for the name of the application this does not need to be the name of the DLL. Add string values for demand loading... Create registry ‘keys’ for each version of AutoCAD the application is targeted to run in... There are properties for not creating that may need to be set...

19 © 2011 Autodesk Use the AutoCAD® AutoLoader to automatically load plug-ins

20 © 2011 Autodesk Use the AutoCAD® AutoLoader to automatically load plug-ins A new feature with AutoCAD® 2012 is the plug-in auto loader mechanism which uses a package format to make deployment of custom applications easy. The package format is a folder with an extension of ‘.bundle’ in the folder is an XML file that defines the plug-in components and folders containing the application(s). This makes it easy to target multiple operating systems and product releases since the parameters of your plug-in are defined in the XML file. The plug-in defined by each package is loaded into AutoCAD by placing it in one of the ApplicationPlugins folders on your local drive.

21 © 2011 Autodesk Use the AutoCAD® AutoLoader to automatically load plug-ins There are two different ApplicationPlugins folders that you can use:  %ProgramFiles%\Autodesk\ApplicationPlugins (Any User)  %AppData%\Roaming\Autodesk\ApplicationPlugins (Only Current User) When AutoCAD starts, both ApplicationPlugins folders are checked for plug-in applications. Packages found are automatically registered and loaded based on the metadata in the XML file of each package.

22 © 2011 Autodesk Use the AutoCAD® AutoLoader to automatically load plug-ins In AutoCAD a command and a system variable are associated with the plug-in autoloader: APPAUTOLOADER - Command LIST - displays a list of plugins Reload - reloads plugins APPAUTOLOAD - System Variable (initial value = 14) The load behavior for plug-ins is controlled with this system variable  0 Do not load plug-in applications at any time  1 Display all messages when loading plug-in applications  2 Load plug-in applications at startup (initial)  4 Load plug-in applications when a new drawing is opened (initial)  8 Load plug-in applications when they appear in the plug-ins folder (initial) With a default setting of 14 plug-ins are automatically registered with AutoCAD and when a new plug-in is installed during the current session.

23 © 2011 Autodesk Use the AutoCAD® AutoLoader to automatically load plug-ins Sample Of a PackageContents.xml

24 © 2011 Autodesk Thanks for Attending…

25 © 2011 Autodesk Autodesk, AutoCAD* [*if/when mentioned in the pertinent material, followed by an alphabetical list of all other trademarks mentioned in the material] are registered trademarks or trademarks of Autodesk, Inc., and/or its subsidiaries and/or affiliates in the USA and/or other countries. All other brand names, product names, or trademarks belong to their respective holders. Autodesk reserves the right to alter product and services offerings, and specifications and pricing at any time without notice, and is not responsible for typographical or graphical errors that may appear in this document. © 2011 Autodesk, Inc. All rights reserved.


Download ppt "© 2011 Autodesk CP5239 Demand-Loading AutoCAD®.NET Plug-ins James E. Johnson Synergis Software Sr. CAD Developer."

Similar presentations


Ads by Google