王伟让我写的简单打印
(defun qf_getFolder (msg / WinShell shFolder path catchit)
(vl-load-com)
(setq winshell (vlax-create-object "Shell.Application"))
(setq shFolder (vlax-invoke-method WinShell 'BrowseForFolder 0 msg 1))
(setq
catchit (vl-catch-all-apply
'(lambda ()
(setq shFolder (vlax-get-property shFolder 'self))
(setq path (vlax-get-property shFolder 'path))
)
)
)
(if (vl-catch-all-error-p catchit)
nil
path
)
)
;|函数功能: 获取目录下(包含子目录)里的某类型文件
;使用格式: a为路径名或多个路劲名表,b为扩展名
;范 例: (n5-get-files "D:" "lsp"),搜索d盘中所有lsp文件|;
;(setq c(n5-get-files b "dat"))
;(vl-file-directory-p b)返回T
;2016-6-11
;095
(defun n5-get-files(a b / lst mulu wj x )
(setq lst '())
(cond
((= (type a)'STR)
(if (setq wj (mapcar '(lambda(x)(strcat a "\\" x))(vl-directory-files a (strcat"*." b))))
(setq lst (cons wj lst)))
(if (setq mulu (mapcar '(lambda(x)(strcat a "\\" x))(cddr(vl-directory-files a nil -1))))
(foreach x mulu(setq lst(cons(n5-get-files x b) lst)))
)
)
((= (type a) 'list) (foreach x a (setq lst (cons(n5-get-files x b)lst))))
)
(reverse(apply 'append lst)))
;
(defun c:tt(/ FILES PATH)
(setq path(QF_GETFOLDER"选择要打印的文件夹:"))
(setq files(N5-GET-FILES path"dwg"))
(foreach file files
(write-line (strcat"正在打印文件的名为:"file))
(vla-InsertBlock
(vla-get-modelspace(vla-get-ActiveDocument(vlax-get-acad-object)))
(vlax-3d-point '(0 0 0))
file
1
1
1
0
)
(command"zoom" "e")
(COMMAND"_plot"
"N" ""
"jiangcan" ""
"N" "N" "Y")
(entdel (entlast)))
(prompt"打印结束")
(PRINC)
)
批量打印程序使用说明
1. 打开AuToCAD软件,cass也是一样的。
2. 确保CAD中没有任何图元
3. 输入命令plot,在打印界面设置各项打印属性,
4. 设置好各属性之后,点击添加,新面设置名为”jiangcan”,必须。然后点确定。
5. 出现这个界面,页面设置名称为”jiangcan”,各项属性都正确,可以返回主界面了
6. Appload加载此插件,输入命令tt,选择要打印的DWG文件所在的文件夹,程序自动打印
页:
[1]