A tool to capture Block entity data from DWG files using the AutoCAD .NET API.
Using the NETLOAD command, import the cad-map-dotnet.dll from cad-map-dotnet/bin. You'll need a SQL database formatted appropriately to store the information (see below).
Download SQL Server Express and follow the instructions to set it up using your computer's name as the local host. You can find your computer name on Windows by searching for "System Information" and then looking at "System Name". Then, create a database with default settings and the name CADDB to create a database, as well as the remaining CreateTable_*.sql to generate the remaining tables inside the database.
-
Install the software requirements found at this page: My First AutoCAD Plug-In Overview. Specifically, you'll need Visual Studio 2019 not 2022. Make sure to scroll all the way to the bottom of the page to find the AutoCAD and ObjectARX .NET wizards.
-
After installing the ObjectARX SDK, and the ObjectARX/.NET wizards, import the following References (Project -> Add Reference...) into Visual Studio:
accoremgd.dll,acdbmgd.dll, andacmgd.dlland set their "Copy Local" status toFalse. On a default C drive-based Windows installation, you'll find these inC:\Autodesk\ObjectARX_for_AutoCAD_2023_Win_64bit_dlm\inc. -
Change the
connstrvalue inSettings1.settingsto point at the path of your database. If you're using a non-trusted connection, or any other type of connection, reference the SQL server connection string types at this link. -
Finally, build the project by running it using the Build command (Ctrl+Shift+B by default). You'll find the compiled .dll in
cad-map-dotnet\bin\debugascad-map-dotnet.dll. Load this in AutoCAD using theNETLOADcommand, then run CAD-MAP by running theCADMAPcommand.
Depending on your network and local PC security settings, you may the following errors:
-
In Visual Studio, when attempting to build the .dll:
Couldn’t process file mainForm.resx due to its being in the Internet or Restricted zone or having the mark of the web on the file. Remove the mark of the web if you want to process these files.Solution: openMain.resxin file explorer and select the option to "Unblock" where it says "Security: This file came from another computer and might be blocked to help protect this computer." You can find more information about this error here. -
In AutoCAD, after calling
NETLOAD:System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch.: In your AutoCAD installation folder, you can findacad.exe.config. Open this in a text editor and add the following flag between the<runtime>and</runtime>elements:<loadFromRemoteSources enabled="true"/>. You can find more information about this error here.