Manipulate drawing SummaryInfo using ObjectARX

<?xml encoding=”UTF-8″>By Balaji Ramamoorthy

You may want to update the “Last saved by” and “Revision number” properties and other custom properties associated with the drawing. The AcDbDatabaseSummaryInfo class of the ObjectARX SDK will help do that. The equivalent of this class in the AutoCAD .Net API is the “DatabaseSummaryInfo” structure. But unlike the C++ API, some of the properties such as “LastSavedBy” and “RevisionNumber” are read-only in .Net. You can also use the COM API to retrieve and set the properties. This is especially useful if you are driving AutoCAD from an external application or using VBA.

After the “Last saved by” property is changed, it is important to save the database using a different name. If not, the AutoCAD’s save command will automatically use the system login name and set the “Last saved by” property.

Here is the ObjectARX C++ code snippet to set the “Last saved by” and “Revision number” properties while retrieving the other properties. 

 Acad::ErrorStatus es;    
 AcDbDatabaseSummaryInfo *pInfo;    
 AcDbDatabase *pCurDb = NULL;    
 ACHAR* info;    
 ACHAR* key;    
 ACHAR* value; 
 <span>int</span><span>  customQty; </span>
 <span>int</span><span>  index;  </span>
 pCurDb = acdbHostApplicationServices()->workingDatabase(); 
 
 <span>// Get a pointer to the workingDatabase() </span>
 <span>// summary information  </span>
 es = acdbGetSummaryInfo(pCurDb, pInfo);   
 acutPrintf(L<span>"\nSummary information for this drawing:"</span><span> ); </span>
 es = pInfo->getTitle(info);  
 <span>if</span><span> (info)</span>
 <span>{</span>   
 	acutPrintf(L<span>"\nTitle = %s"</span><span> , info);   </span>
 <span>}</span>    
 
 es = pInfo->getSubject(info);    
 <span>if</span><span> (info)    </span>
 <span>{</span> 
 	acutPrintf(L<span>"\nSubject matter = %s"</span><span> , info);   </span>
 <span>}</span>    
 
 es = pInfo->getAuthor(info);    
 <span>if</span><span> (info)</span>
 <span>{</span>        
 	acutPrintf(L<span>"\nAutor = %s"</span><span> , info);    </span>
 <span>}</span>    
 
 es = pInfo->getKeywords(info);    
 <span>if</span><span> (info)   </span>
 <span>{</span>    
 	acutPrintf(L<span>"\nKeywords = %s"</span><span> , info);   </span>
 <span>}</span>   
 
 es = pInfo->getComments(info);   
 <span>if</span><span> (info)   </span>
 <span>{</span>       
 	acutPrintf(L<span>"\nComments = %s"</span><span> , info);    </span>
 <span>}</span>    
 
 es = pInfo->setLastSavedBy(L<span>"Captain CAD"</span><span> );    </span>
 es = pInfo->getLastSavedBy(info); 
 acutPrintf(L<span>"\nLast saved by = %s"</span><span> , info);   </span>
 
 es = pInfo->getHyperlinkBase(info);  
 <span>if</span><span> (info)   </span>
 <span>{</span>
 acutPrintf(L<span>"\nLink Location = %s"</span><span> , info);    </span>
 <span>}</span>
 
 es = pInfo->setRevisionNumber(L<span>"1"</span><span> ); </span>
 es = pInfo->getRevisionNumber(info);    
 acutPrintf(L<span>"\nRevision number = %s"</span><span> , info);    </span>
 customQty = pInfo->numCustomInfo();    
 <span>if</span><span> (customQty > 0)    </span>
 <span>{</span>        
 	acutPrintf(L<span>"\nCustom Summary Information:\n"</span><span> );        </span>
 	acutPrintf(L<span>"\nKey\t\tValue\n"</span><span> );        </span>
 	<span>for</span><span> (index = 0; index < customQty; index++)        </span>
 	<span>{</span>            
 		pInfo->getCustomSummaryInfo(index, key, value);            
 		<span>if</span><span> (key)            </span>
 		<span>{</span>               
 			acutPrintf(L<span>"\n%s"</span><span> , key);            </span>
 		<span>}</span>            
 		<span>if</span><span> (value)          </span>
 		<span>{</span> 
 			acutPrintf(L<span>"\t\t%s"</span><span> , value);</span>
 		<span>}</span>
 		acdbFree(key); 
 		acdbFree(value);
 	<span>}</span>    
 <span>}</span>
 <span>else</span>
 <span>{</span>
 	acutPrintf(L<span>"\n\nDrawing does not contain</span>
 		any Custom SummaryInformation<span>");   </span>
 <span>}</span> 
 es = acdbPutSummaryInfo(pInfo);    
 acdbFree(info); 
 
 pCurDb->saveAs(ACRX_T(<span>"D:\\Temp\\MyTestArx.dwg"</span><span> ));</span>
 

To set the properties using COM API, here is a code snippet :

 <span'oAcadApp As IAcadApplication ...<span> </span>
 oAcadApp.ActiveDocument.Database.SummaryInfo.LastSavedBy = <span>"Autodesk"</span><span> </span>
 MsgBox(oAcadApp.ActiveDocument.Database.SummaryInfo.LastSavedBy)
 oAcadApp.ActiveDocument.SaveAs(<span>"D:\Temp\MyTest.dwg"</span><span> )</span>
 


Comments

5 responses to “Manipulate drawing SummaryInfo using ObjectARX”

  1. Thanks, Balaji!
    This is just FYI as a related info. – I learned from the customer that there is a command in the express tool to help with this:
    PROPULATE (Express Tool)
    http://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-Core/files/GUID-BD03320F-3430-4C2F-80A3-AAC1167AF019-htm.html

  2. Thanks Mikako

  3. sushil jawale Avatar
    sushil jawale

    hi,
    I want to update the some of the custom properties on the document without opening file in AutoCAD.
    but If I open the file using write and no share using readdwgfile I do not see the properties updated.
    Please suggest how it could be done to update custom properties on same document using arx
    Thanks!
    Sushil

  4. sushil jawale Avatar
    sushil jawale

    hi,
    I want to update the some of the custom properties on the document without opening file in AutoCAD.
    but If I open the file using write and no share using readdwgfile I do not see the properties updated.
    Please suggest how it could be done to update custom properties on same document using arx
    Thanks!
    Sushil

  5. Hi Sushil,
    I’d suggest posting question to AutoCAD Customization forum:
    http://forums.autodesk.com/t5/autocad-customization/ct-p/AutoCADTopic1
    You can point to this post when you are describing the problem if it helps.
    Balaji is no longer with Autodesk. I’m on BIM side now. I don’t have brain to help you on this topic. But we have many other people who knows AutoCAD APIs.

Leave a Reply

Discover more from Autodesk Developer Blog

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

Continue reading