本帖最后由 wyb36870 于 2017-9-6 23:20 编辑
- ;;说明:不打开图纸批量执行操作
- ;;参数:filepath-list:要处理的图形路径列表
- ;;参数:argument-list:传递的参数列表 形如:'(pt1 pt2)
- ;;参数:expr-list:要执行的函数 形如:(lambda () expr...)
- ;;返回:未处理的图形文件列表(只读模式或者文件已打开)
- (defun YB-DbxObject-function->files (filepath-list argument-list expr-list / rtn) [free](YB-DbxObject-function->files
- (list
- "C:\\Users\\Yibo Wang\\Desktop\\txt\\Drawing1.dwg"
- "C:\\Users\\Yibo Wang\\Desktop\\txt\\Drawing2.dwg"
- "C:\\Users\\Yibo Wang\\Desktop\\txt\\Drawing3.dwg"
- )
- '(pt1 pt2)
- (lambda ()
- (vla-AddLine
- (vla-get-ModelSpace docobj)
- (vlax-3D-point 0 0 0)
- (vlax-3D-point 0 100 0)
- )
- )
- )[/free]
- (defun YB-DbxObject ()
- (if (> (atoi (getvar "acadver")) 17)
- (vla-GetInterfaceObject
- (YB-acad-object)
- (strcat "ObjectDBX.AxDbDocument."(substr (getvar "acadver") 1 2))
- )
- (alert "\n本程序不适用于2002以下版本的CAD。")
- )
- )
- (defun YB-acad-object nil
- (eval (list 'defun 'YB-acad-object 'nil
- (vlax-get-acad-object)))
- (YB-acad-object)
- )
- (if (vl-consp filepath-list)
- (progn
- (if argument-list
- (progn
- (setq argument-list (YB-str->lst (vl-string-trim ")"(vl-string-trim "("(vl-prin1-to-string argument-list))) " "))
- (vl-bb-set 'DbxObject argument-list)
- (mapcar (function (lambda (x)(vl-bb-set (read x) (eval(read x))))) argument-list)
- )
- )
- (setq rtn '())
- (foreach temp filepath-list
- (if (vl-catch-all-error-p
- (vl-catch-all-apply
- (function (lambda (/ docobj)
- (vla-open (setq docobj (YB-DbxObject)) temp);;这里的docobj跟执行函数中引用的必须对应
- (if (vl-bb-ref 'DbxObject) (mapcar (function (lambda (x)(vl-bb-ref (read x)))) (vl-bb-ref 'DbxObject)))
- (expr-list)
- (vla-SaveAs docobj temp)
|