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 =
Database db = activeDoc.Database;
= new DatabaseSummaryInfoBuilder();
builder.Author = "GoCAD" ;
("Machine Type" , "Milling" );
builder.CustomPropertyTable.Add("Model" , "Vertical" );
builder.CustomPropertyTable.Add("Year" , "2014" );
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.
//Script starts here
; Load the custom plugin
(command "_.Netload" "D:\\\\Temp\\\\Test.dll" )
; Run the command
(command "WriteCustomProp" )
//Script ends here
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 "D:\\Temp\\Test.dwg"
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 :Access drawing properties outside AutoCAD