示例:访问图形特性 (AutoLISP/ActiveX)
该接口可作为 Document 对象的属性访问,以访问图形属性,如标题、主题、作者和关键字。IAcadSummaryInfo 注意:AutoCAD for Mac 不支持 ActiveX。
在以下示例中,该接口用于向当前图形添加标准属性和自定义属性:IAcadSummaryInfo (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 "https://www.autodesk.com") (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) 可以使用接口读取图形属性,如以下示例所示:IAcadSummaryInfo (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) ) 相关概念 |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 13:06
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.