Autocad 2018 autoload dll

2019-07-30 08:41发布

问题:

Hi i am trying to 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 used *.lsp ways. Can someone please help. I have found plenty of ways but none work.

回答1:

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



回答2:

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")


回答3:

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