1

I am trying to automatically load dll files to Autocad 2018.

How can i achieve that?

I want to automate so it can do it on startup. With netload everything works.

I have used *.lsp ways. Can someone please help? I have found plenty online of ways but none work.

panoskarajohn
  • 1,846
  • 1
  • 21
  • 37

3 Answers3

4

AutoCAD's official way to load .dll files written in .Net on startup is to use autoloader feature. You basically bundle the .dll with any other files you want into a default folder where AutoCAD reads at startup to load all plug-ins. This is especially good if you want to distribute your plug-in (.dll) as a setup file to install on multiple machines.

First step is to create a bundle folder in "%ProgramData%/Autodesk/ApplicationPlugins". the bundle folder is a normal windows folder that ends with .bundle (ex. MyApp.bundle)

Inside this folder you need to have a folder named ("Contents") and a file named ("PackageContents.xml").

Place .dll inside the contents folder

code inside PackageContents.xml can be as simple as the following (Change things like "MyApp", "MyName", etc.. and it should work for you):

<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage SchemaVersion="1.0" ProductType="Application" Name="MyAPP" AppVersion="1.0" Description="MyAPP, My description" Author="My Name" Icon="./Contents/MyAPPIcon.ico" OnlineDocumentation="http://MyWebSite.com" HelpFile="" ProductCode="{xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx}" FriendlyVersion="1.0" SupportedLocales="Enu" AutodeskProduct="AutoCAD">
  <CompanyDetails Name="My Name" Phone=" " Url="http://MyWebsite.com" Email="MyName@MyWebSite.com" />
  <Components Description="Main">
    <RuntimeRequirements SupportPath="./Contents" OS="Win32|Win64" Platform="AutoCAD*" SeriesMin="R19.0" SeriesMax="R22.0" />
    <ComponentEntry AppName="MyAPP" Version="1.0" ModuleName="./Contents/MyAPP.dll" AppDescription="My description" LoadOnAppearance="True" LoadOnAutoCADStartup="True" LoadOnCommandInvocation="True">
    </ComponentEntry>
  </Components>
</ApplicationPackage>

I think the above is enough to answer your question but if you need more read the article in the following link: http://adndevblog.typepad.com/autocad/2013/01/autodesk-autoloader-white-paper.html

mavios
  • 210
  • 1
  • 8
  • Although this works two i have two questions for you. 1) How does this help me automate commands? 2) Also on the Module Name, what path is that? – panoskarajohn Sep 19 '17 at 10:06
  • Ask and I will try to answer if I can – mavios Sep 19 '17 at 10:10
  • I have wrote a .net plugin. I want to automatically run some custom commands. I want to do it in .Net because it provides bigger flexibility than VBA/ActiveX (Macros). 2. If we look at the xml and see inside Module name="./Contents" --> where does this lead to? Which folder? 3. How the xml helps me with automation? – panoskarajohn Sep 19 '17 at 10:56
  • 1
    "./Contents/MyApp.dll" is "%ProgramData%\Autodesk\ApplicationPlugins\MyApp.bundle\Contents" – mavios Sep 19 '17 at 12:23
  • ok thank you how about though running commands through the xml? – panoskarajohn Sep 19 '17 at 12:28
  • When you using AutoCAD 2013-2018, "./Contents/MyApp.dll" is "%ProgramData%\Autodesk\ApplicationPlugins\MyApp.bundle\Contents". The xml describes the bundle package, the code in that package can customize many things. I will not pretend to be an expert in this, but the link I provided in my answer has very detailed description on how to use it – mavios Sep 19 '17 at 12:31
  • Ok i will give it a shot and let you know. Actually you are right there is info inside your link. – panoskarajohn Sep 19 '17 at 13:30
1

You put your NETLOAD commands in a LSP file, and the add the LSP file to your Startup Suite.

Also keep in mind the paths need to use 2 backslashes like this:

(command "netload" "C:\\Internal Tools\\Detect Overlap\\Type 5\\x86\\Detect Overlap.dll")
braX
  • 11,506
  • 5
  • 20
  • 33
1

It is also quite easy to do with the registry, and is my preferred way. See link below. To deploy, you can either create an installer to set the registry keys, or you can do it right in code if you have some code executing outside of AutoCAD.

https://knowledge.autodesk.com/support/autocad/troubleshooting/caas/sfdcarticles/sfdcarticles/How-to-autoload-DLLs-with-AutoCAD.html

Nik
  • 1,780
  • 1
  • 14
  • 23