1

How can I load automatically .dll plugins in AutoCAD 2019? Preferably without changing any file in AutoCAD directory (I'm not the admin). I'm trying to load this plugin that registers, in an excel file, when AutoCAD is closed. It was created with .net in vb.

I've tried this but failed because i'm not the admin and cannot change files in AutoCAD directory:

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

There has to be a solution that does not involve manually editing files in AutoCAD's directory. Specially because this is meant to be used in 200+ computers at the company I work company.

I created this plug-in in visual studio with .net in vb, as follows:

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Excel = Microsoft.Office.Interop.Excel
Imports System.IO

Public Class Class1
    <CommandMethod("AddAppEvent")>
    Public Sub AddAppEvent()
        AddHandler Application.SystemVariableChanged, AddressOf appSysVarChanged
    End Sub

    <CommandMethod("RemoveAppEvent")>
    Public Sub RemoveAppEvent()
        RemoveHandler Application.SystemVariableChanged, AddressOf appSysVarChanged
    End Sub

    Public Sub appSysVarChanged(ByVal senderObj As Object,
                                ByVal sysVarChEvtArgs As Autodesk.AutoCAD.ApplicationServices.
                                SystemVariableChangedEventArgs)

        Dim oVal As Object = Application.GetSystemVariable(sysVarChEvtArgs.Name)

        Dim fileTest As String = "C:\Users\rita.aguiar\Documents\AutoCAD plug-in\Registo de Eventos.xlsx"
        If File.Exists(fileTest) Then
            File.Delete(fileTest)
        End If

        Dim oExcel As Object
        oExcel = CreateObject("Excel.Application")
        Dim oBook As Excel.Workbook
        Dim oSheet As Excel.Worksheet

        oBook = oExcel.Workbooks.Add
        oSheet = oExcel.Worksheets(1)

        oSheet.Name = "Fecho do AutoCAD"
        oSheet.Range("A1").Value = "O AutoCAD foi encerrado."
        oBook.SaveAs(fileTest)
        oBook.Close()
        oBook = Nothing
        oExcel.Quit()
        oExcel = Nothing
    End Sub

End Class

It would be lovely if there was something else I could write here to at least enable the register of events automatically, instead of always having to enable it by hitting "AddAppEvent" Command in AutoCAD. And I also wanted to automate the loading of the plugin, instead of having to manually hit "netload" and choose the .dll file everytime I open an autoCAD file.

Many thanks.

Rita Aguiar
  • 65
  • 1
  • 10
  • Can you list the specific plugin you're trying to use, and what you've tried so far that didn't work? – John Stark Sep 06 '18 at 14:11
  • Can you provide the filepath for the compiled plugin? – Batteredburrito Sep 06 '18 at 14:44
  • Also, are you not able to edit the .lsp file mentioned in the link without admin rights? Ive been able to edit and save mine using Notepad++ without admin rights – Batteredburrito Sep 06 '18 at 14:44
  • How do I provide the filepath automatically to autoCAD? Even in Notepad++ I can't, thank you. Also it's not ideal to edit each file in every computer of my company. – Rita Aguiar Sep 06 '18 at 15:10
  • If you provide me with the directory of the DLL file that youve exported i.e C:/User/YourName/Documents etc. I can try to make you the required file. – Batteredburrito Sep 06 '18 at 17:37

5 Answers5

2

Just use the ApplicationPlugins folder.

That's the way AutoCAD loads plugins. (which can be Dll's)

Documentation is here: https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-5E50A846-C80B-4FFD-8DD3-C20B22098008

See An example here: https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-40F5E92C-37D8-4D54-9497-CD9F0659F9BB

Alain
  • 304
  • 3
  • 9
  • I've found that the link is no longer active or the page it leads to has been moved/updated. If it's not too much trouble, could you possibly provide an updated link or refer to another source that contains similar information? It would be a great help to me and other users who may come across this thread in the future. – obfusticatedcode Jul 20 '23 at 13:49
  • Hi, I've updated the links – Alain Jul 27 '23 at 14:28
1

As far as im aware with AutoCAD, plugins can only be auto Loaded with either a Registry edit or by editing the file as mentioned by the link. Without admin rights, there wont be a way to work around this to the best of my knowledge

Batteredburrito
  • 579
  • 1
  • 5
  • 34
  • 1
    you can access a registry edit on windows by running regedit.exe (you can type this into the start menu). Unfortunately, it requires admin credentials so wont be much use and really isnt recommended if you are unsure of what you are doing. Its easy to break software etc – Batteredburrito Sep 06 '18 at 17:36
1

You can bundle all you build files, .cuix file in a folder called "PluginName.bundle" which should also contain a file with name PackageContents.xml and place it in the following location - C:\ProgramData\Autodesk\ApplicationPlugins.

Screenshot of the .bundle folder for a plugin

Check the following link for additional details

Below is an example of what the PackageContents.xml should contain:

<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage SchemaVersion="1.0" AutodeskProduct="AutoCAD" Name="PluginName" Description="Plugin Description" AppVersion="0.0.1" FriendlyVersion="0.0.1" ProductType="Application" SupportedLocales="Enu" AppNameSpace="appstore.exchange.autodesk.com" Author="Anwesh Gangula" HelpFile="./help.html" OnlineDocumentation="vConstruct.com" ProductCode="{030335ce-ee6b-4cd9-84d0-0afa479ed4ac}" UpgradeCode="{08abfbe3-2dab-45aa-817b-68e70212f494}" Icon="./icon.ico">
  <CompanyDetails Name="Anwesh Gangula" Email="myEmail@gmail.com" Url="anweshgangula.com" />
  <Components Description="2017-2023">
    <RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD*" SeriesMin="R19.1" SeriesMax="R24.2" />
    <ComponentEntry AppName="PluginName" Version="0.0.1" ModuleName="./Contents/PluginName.dll" AppDescription="Commands Description" LoadOnCommandInvocation="True" >
      <Commands>
        <Command Global="OpenWPFWindow" />
        <Command Global="AdskGreeting" />
      </Commands>
    </ComponentEntry>
    <ComponentEntry AppName="PluginName" Version="0.0.1" ModuleName="./PluginName.cuix" AppDescription="Customization description" LoadOnAppearance="False" LoadOnAutoCADStartup="True" />
  </Components>
</ApplicationPackage>

Additional reference:

you should create a new GUID for the ProductCode but never change the UpgradeCode one.

Gangula
  • 5,193
  • 4
  • 30
  • 59
0

I figured how to automatically load. It's actually very simply:

  1. I created a lsp file named acad.lsp

  2. The file calls the netload command to load my .dll (and other commands that I created).

  3. I stored the file in C:\Program Files\Autodesk\AutoCAD 2019\Support

  4. Now everytime I open AutoCAD it loads my plugin automatically!

Pang
  • 9,564
  • 146
  • 81
  • 122
Rita Aguiar
  • 65
  • 1
  • 10
0

The link in the accepted answer seems to be broken and the suggested method in that answer to use the ApplicationPlugins folder didn't work for me.

What worked for me is following the below steps as documented by Autodesk in the following link:

To automatically load DLL files you can follow next procedure:

  • Browse with the file explorer to the c:\program files\autodesk\autocad 20xx\support<language> folder

  • Check if there is any file named acad20xxdoc.lsp. If it's there, open with an ASCII editor such as notepad.exe. If it's not there, create it with an ASCII editor.

  • Add the list of DLL's that you want to load following the next structure:

    (command "_netload" "C:/folder1/folder2/my_DLL_1.DLL")
    (command "_netload" "C:/folder1/folder2/my_DLL_2.DLL")
    (command "_netload" "C:/folder1/folder2/my_DLL_3.DLL")
    (command "_netload" "C:/folder1/folder2/my_DLL_4.DLL") 
    

    Update the path and file names to match your needs.

  • Save the acad20xxdoc.lsp

  • Every time that you start a new file or open an existing one it will load the list of DLL.

Gangula
  • 5,193
  • 4
  • 30
  • 59
  • note that althoug this answer works, the correct way to load AutoCAD plugin is [mentioned below](https://stackoverflow.com/a/73361579/6908282) and in the [following link](https://anweshgangula.hashnode.dev/bundle-distribute-autocad-api-plugin) – Gangula Dec 23 '22 at 09:04