您可以将“我的目录文件”功能与“浏览文件夹”功能和“我的ObjectDBX包装器”功能的示例4结合使用:
- (defun c:test4 ( / _getattributes data [highlight]dir[/highlight] file [highlight]lst[/highlight] name )
- (defun _getattributes ( doc / data item name values )
- (vlax-for layout (vla-get-layouts doc)
- (vlax-for object (vla-get-block layout)
- (if
- (and
- (eq "AcDbBlockReference" (vla-get-objectname object))
- (eq :vlax-true (vla-get-hasattributes object))
- (setq values
- (mapcar
- (function
- (lambda ( att )
- (cons
- (vla-get-tagstring att)
- (vla-get-textstring att)
- )
- )
- )
- (vlax-invoke object 'getattributes)
- )
- )
- )
- (if (setq item (assoc (setq name (vla-get-effectivename object)) data))
- (setq data
- (subst
- (append item (list values))
- item
- data
- )
- )
- (setq data (cons (list name values) data))
- )
- )
- )
- )
- data
- )
- (if
- (and
- [highlight](setq dir (LM:browseforfolder "Select a folder" nil 0))[/highlight]
- [highlight](setq lst (LM:directoryfiles dir "*.dwg" t))[/highlight]
- (setq data (LM:ODBX '_getattributes [highlight]lst[/highlight] nil))
- (setq name (vl-filename-mktemp nil (getvar 'dwgprefix) ".txt"))
- (setq file (open name "w"))
- )
- (progn
- (foreach dwgitem data
- (write-line (car dwgitem) file)
- (princ "\n" file)
- (foreach item (cdr dwgitem)
- (write-line (car item) file)
- (foreach subitem (cdr item)
- (princ subitem file)
- (princ "\n" file)
- )
- (princ "\n" file)
- )
- )
- (close file)
- (startapp "notepad" name)
- )
- )
- (princ)
- )
以上未经测试。 |