如何在AutoCAD 2019中自动加载.dll插件?

问题描述 投票:0回答:3

如何在AutoCAD 2019中自动加载.dll插件?最好不要更改AutoCAD目录中的任何文件(我不是管理员)。我正在尝试加载此插件,该插件在Excel关闭时在excel文件中注册。它是用.net在vb中创建的。

我试过这个但是失败了因为我不是管理员而且无法更改AutoCAD目录中的文件:

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

必须有一个解决方案,不涉及手动编辑AutoCAD目录中的文件。特别是因为这适用于我工作公司的200多台计算机。

我在Visual Studio中使用.net在vb中创建了这个插件,如下所示:

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

如果还有其他东西我可以写在这里以至少自动启用事件注册,而不是总是必须通过在AutoCAD中点击“AddAppEvent”命令来启用它,这将是可爱的。我还想自动加载插件,而不必每次打开autoCAD文件时手动点击“netload”并选择.dll文件。

非常感谢。

.net vb.net dll autoload autocad
3个回答
2
投票

只需使用ApplicationPlugins文件夹即可。

这就是AutoCAD加载插件的方式。 (可以是Dll的)

请参阅此处的示例:

https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2018/ENU/AutoCAD-Customization/files/GUID-40F5E92C-37D8-4D54-9497-CD9F0659F9BB-htm.html


1
投票

至于我对AutoCAD的了解,插件只能通过注册表编辑或编辑链接所提到的文件来自动加载。没有管理员权限,根据我的知识,不会有办法解决这个问题


0
投票

我想到了如何自动加载。它实际上非常简单:

  1. 我创建了一个名为acad.lsp的lsp文件
  2. 该文件调用netload命令加载我的.dll(以及我创建的其他命令)。
  3. 我将文件存储在C:\ Program Files \ Autodesk \ AutoCAD 2019 \ Support中
  4. 现在我每次打开AutoCAD时都会自动加载我的插件!
© www.soinside.com 2019 - 2024. All rights reserved.