Read / Write custom drawing properties without opening drawing in AutoCAD

<?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 :

Access drawing properties outside AutoCAD


Comments

5 responses to “Read / Write custom drawing properties without opening drawing in AutoCAD”

  1. Will Parker Avatar
    Will Parker

    Is there any way to read drawing properties without using any autocad api? I want to be able to access this data through the windows command prompt and by the same means as windows explorer is able to access it.

  2. Hi Will,
    Sorry, My apologies for failing to notice your comment to this blog post and the long delay in getting back to you.
    Please have a look at the DWG Properties ActiveX control from ADN Utilities. This should provide read-only access to some of the drawing properties even without AutoCAD installed in the system.
    This ActiveX can be downloaded as part of ADN Utilites from here :
    http://adndevblog.typepad.com/autocad/2012/08/adn-autocad-utilities.html/
    Regards,
    Balaji

  3. Excellent ! it is very useful post. Keep it up .

  4. Dear Balaji Sir, I am able to add Custom Properties to a Autocad file , but the metadata is not displaying in the field list view on the document explorer page . Can you kindly help.

  5. Dear Balaji Sir, I am able to add Custom Properties to a Autocad file , but the metadata is not displaying in the field list view on the document explorer page . Can you kindly help. Would appreciate if the reply is also marked to My Email id is arunsepl@gmail.com as i am not a regular visitor to this page , Thanks in advance. With Regards Aarun Poojary , Mumbai India
    Reply 12

Leave a Reply to Aarun PoojaryCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading