<?xml encoding=”UTF-8″>By Balaji Ramamoorthy
In some cases, it might be required to read / write custom properties for AutoCAD drawings without having to open the drawing in AutoCAD. If you already have AutoCAD installed in the system, using accoreconsole.exe provides an easy way to achieve this. Here are the steps :
1) Create a .Net plugin that only references acdbmgd.dll and accoremgd.dll and implement a custom command with this code snippet :
Document activeDoc =
Autodesk.AutoCAD.ApplicationServices.Core.
Application.DocumentManager.MdiActiveDocument;
Database db = activeDoc.Database;
DatabaseSummaryInfoBuilder builder
= <span>new</span><span> DatabaseSummaryInfoBuilder();</span>
builder.Author = <span>"GoCAD"</span><span> ;</span>
builder.CustomPropertyTable.Add
(<span>"Machine Type"</span><span> , <span>"Milling"</span><span> );</span></span>
builder.CustomPropertyTable.Add(<span>"Model"</span><span> , <span>"Vertical"</span><span> );</span></span>
builder.CustomPropertyTable.Add(<span>"Year"</span><span> , <span>"2014"</span><span> );</span></span>
db.SummaryInfo = builder.ToDatabaseSummaryInfo();
2) Create a AutoCAD script file to load the plugin and invoke the custom command. Save the script as a scr file.
<span>//Script starts here</span>
; Load the custom plugin
(command <span>"_.Netload"</span><span> <span>"D:\\Temp\\Test.dll"</span><span> )</span></span>
; Run the command
(command <span>"WriteCustomProp"</span><span> )</span>
save
<span>//Script ends here</span>
3) Run AccoreConsole.exe found in the AutoCAD 2015 install folder and provide the drawing to which custom properties are to be added.
accoreconsole.exe /i <span>"D:\Temp\Test.dwg"</span><span> </span>
/s <span>"D:\Temp\WriteProp.scr"</span><span> </span>
/l en-US
If you do not have AutoCAD installed in the system, it is possible to read the custom properties using the COM API provided by DwgPropX ActiveX control. But this activeX does not provide write access to the properties. You can read about this approach in this blog post :

Leave a Reply to Cado MagengeCancel reply