尽管代码运行时没有错误处理程序,但请尝试此mods,并根据您的风险进行测试。
[未经测试]
- (defun c:findf (/ sw odb)
- (setq sw (strcase (getstring "\nEnter search word: "))
- odb (vla-getinterfaceobject
- (vlax-get-acad-object)
- "ObjectDBX.AxDbDocument.18"
- )
- )
- (foreach file (vl-directory-files "c:\\mydrawings" "*.dwg")
- (vla-open odb (strcat "c:\\mydrawings\" file))
- (vlax-for obj (vla-get-modelspace odb)
- (if (and (eq (vla-get-objectname obj) "AcDbBlockReference")
- (eq (vla-get-effectivename obj) "TITLEBLOCK")
- )
- (foreach att (vlax-invoke obj 'getattributes)
- (if (wcmatch (strcase (vla-get-textstring att)) (strcat "*" sw "*")
- )
- (princ (strcat "\n" file))
- )
- )
- )
- )
- )
- (princ "\nSearch completed...")
- (textpage)
- (princ)
- )(vl-load-com)
|