Accessing Drawing Properties
 
 
 

To access drawing properties such as Title, Subject, Author, and Keywords, use the IAcadSummaryInfo interface. This interface is accessible as a property of the Document object in the AutoCAD object model.

In the following example, the IAcadSummaryInfo interface is used to add standard and custom properties to a drawing named MyDrawing.dwg:

(vl-load-com)


(defun c:ADD_PROPS (/ doc db si author nc nc2 nc3 value3 value4)
  (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
  (setq db (vla-get-Database doc))
  (setq si (vla-get-SummaryInfo db))
  (vla-put-author si "John")
  (vla-put-comments si "New comments")
  (vla-put-hyperlinkbase si "http://AddURL")
  (vla-put-keywords si "New keywords")
  (vla-AddCustomInfo si "siPutKey" "siPutValue")
  (setq nc (vla-numcustominfo si))
  (vla-SetCustomByKey si "siPutKey" "siPutValueByKey")
  (vla-GetCustomByKey si "siPutKey" 'value3)
  (if (/= "siPutValueByKey" value3)
	(princ "*** Error SetCustomByKey\n")
  )
  (vla-SetCustomByIndex si (1- nc) "siPutCustomByIndexKey"
	"siPutCustomByIndexValue")
  (vla-GetCustomByKey si "siPutCustomByIndexKey" 'value4)
  (if (/= "siPutCustomByIndexValue" value4)
	(princ "*** Error SetCustomByIndex\n")
  )
  (vla-RemoveCustomByIndex si (1- nc))
  (setq nc2 (vla-numcustominfo si))
  (if (/= nc2 (1- nc))
	(princ "*** Error RemoveCustomByIndex")
  )
  (vla-AddCustomInfo si "siPutKey" "siPutValue")
  ; Remove property
  (vla-RemoveCustomByKey si "siPutKey")
  (setq nc3 (vla-numcustominfo si))
  (if (/= nc2 (1- nc))
	(princ "*** Error RemoveCustomByKey")
  )
  (vla-AddCustomInfo si "siPutKey" "siPutValue")
  (vlax-release-object si)
  (vlax-release-object db)
  (vlax-release-object doc)
  (princ)
)
(princ)

Drawing properties can be read using the same inteface, the IAcadSummaryInfo interface, as in the following example:

(vl-load-com)


(defun c:GET_PROPS (/ doc db si author )
  (if (/= "MyDrawing.dwg" (getvar "DWGNAME"))
	(princ "Open MyDrawing.dwg")
	(progn
	(setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
	(setq db (vla-get-Database doc))
	(setq si (vla-get-SummaryInfo db))
	(princ "\nAuthor: \n")
	(if (/= "John" (setq author (vla-get-author si)))
		(princ "*** vla-get-author error")
		(princ author)
	)
	(princ "\n")
	(princ "\nComments:\n ")
	(princ (vla-get-comments si))
	(princ "\n")
	(princ "\nHyperlink-base: \n")
	(princ (vla-get-HyperlinkBase si))
	(princ "\n")	 
	(princ "\nNumber of custom properties: ")
	(princ (setq nc (vla-numcustominfo si)))
	(princ "\n")	 
	(while (> nc 0) 
	(princ "Custom property ")
	(princ nc)
	(vla-GetCustomByIndex si (- nc 1) 'key 'value)
	(princ ": key(")
	(princ key)
	(princ ")")
	(princ " value(")
	(princ value)
	(princ ")\n")
	(vla-GetCustomByKey si key 'value2)
	(if (/= value value2)
		(princ "\n*** Error GetCustomByKey returned unexpected
		 result.\n")
	)
	(setq nc (1- nc))
	)
	(vlax-release-object si)
	(vlax-release-object db)
	(vlax-release-object doc)
	)
  )
  (princ)
)

For more information on the properties and methods used to access drawing properties, see the ActiveX and VBA Reference.