Search code examples
autocadvberubberduck

Rubberduck in Autocad


I see that v2.0: 75% there post mentions Autocad and there is an AutoCADApp.cs file, but I can't seem to find a reference for using Rubberduck outside of Office, under some random host application. There is this Adding a new Host Application to Rubberduck but that is already done for Autocad.

Using Rubberduck under Autocad requires building from source? Or is there a procedure to use the already installed release package?


Solution

  • Disclaimer: I'm heavily involved with the Rubberduck project.

    Likely you're simply missing the registry keys for AutoCAD's VBE to notice your ducky.

    Rubberduck's installer searches for the bitness of your Microsoft Office install, and then registers itself using that bitness.

    So if you have 32-bit Office and 32-bit CAD, you're all set. Ditto with 64-bit Office and 64-bit CAD. In your case you probably have 32-bit Office but 64-bit CAD, and so there's no registry key to tell a 64-bit VBE to load an add-in called Rubberduck.

    You can run the PowerShell script you found in the project's wiki (it creates both 32 and 64 bit addin keys), or create the missing HKCU registry key manually, but then the add-in will be seen, but still won't load, because the COM interop stuff was registered under 32-bit nodes, and CAD will expect RD to be registered under 64-bit nodes. To register for 64-bit, you'll have to run (as administrator) a 64-bit regasm.exe command, as described in the "troubleshooting 'add-in could not be loaded'" section of the installer wiki:

    Note: the bitness of your OS is irrelevant.

    Bring up an administrative command prompt (cmd.exe), and execute one of the following commands:

    32-bit host:

    c:\windows\microsoft.net\framework\v4.0.30319\regasm.exe "(path to install folder)\rubberduck.dll" /codebase /tlb
    

    64-bit host:

    c:\windows\microsoft.net\framework64\v4.0.30319\regasm.exe "(path to install folder)\rubberduck.dll" /codebase /tlb
    

    Note that these registration steps are required even if you build the addin yourself from the source code.