法国麻雀 发表于 2015-11-3 16:55:17

CAD利用.scr文件,批量插入.dwg文件

求教,在目前一个文件夹内有很多不同图幅的dwg文件,现在要将这些dwg拼合起来,怎么编写scr文件,请大神指导噻!

VBALISPER 发表于 2015-11-4 09:11:36

open "D:\PROGRAM FILES\KONGLONGTOOLS\DZFH\1000.dwg" -purge a * no qsave close
open "D:\PROGRAM FILES\KONGLONGTOOLS\DZFH\1001岩层产状.dwg" -purge a * no qsave close
open "D:\PROGRAM FILES\KONGLONGTOOLS\DZFH\1002岩层水平产状.dwg" -purge a * no qsave close
open "D:\PROGRAM FILES\KONGLONGTOOLS\DZFH\1003岩层垂直产状.dwg" -purge a * no qsave close
open "D:\PROGRAM FILES\KONGLONGTOOLS\DZFH\1004倒转岩层产状.dwg" -purge a * no qsave close
open "D:\PROGRAM FILES\KONGLONGTOOLS\DZFH\1005片理产状.dwg" -purge a * no qsave close
这是批量打开指定路径下DWG文件,执行purge命令,并输入A参数 * 参数 NO 参数 最后快速保存并关闭的例子,你根据你的需要来改写.

yaokui25 发表于 2015-11-4 10:33:51

(defun C:SCR_J_LYseirir (/ FILE_LIST FOLD SF SFF RunNow QF_GETFOLDER GETFILELIST PATH-ADDBACKSLASH)
(vl-load-com)
;_Thanks caoyin
(defun GetFileList (dirName / files lst)
(defun path-addBackSlash (path)
(if (not (member (substr path (strlen path)) '("\\" "/")))
(strcat path "\\")
path
)
)
(setq dirName (path-addBackSlash dirName)
files (mapcar '(lambda (x) (strcat dirName x))
(vl-directory-files dirName "*.dwg" 1)
)
)
(mapcar '(lambda (x)
(setq lst (append lst (GetFileList (strcat dirName x))))
)
(vl-remove-if
'(lambda (x) (member x '("." "..")))
(vl-directory-files dirName nil -1)
)
)
(append files lst)
)

(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
)
)
(setq fold (qf_getFolder "选择文件夹"))
(if fold
(progn
(setq file_list (GetFileList fold))
(if file_list
(progn
(setq sf (strcat (getvar "TEMPPREFIX") "☆执行.SCR"))
(setq sff (open sf "w"))
(mapcar '(lambda (x)


;;;;下面这一段改成自己需要的
(princ (strcat
"open \"" x "\"\n"
; "(load \"" "You_Jupiter.lsp" "\")\n"
"(load \"" "You_Jupiter" "\")\n"
"(C:J_Lyseirir)\n"
"qsave\n"
"close\n"
)
sff
)
;;;;上面这一段改成自己需要的


)
file_list
)

(close sff)
(princ (strcat "\n◎文件夹中 " fold "\n dwgの个数:" (itoa (length file_list))))
(initget "Y N")
(setq RunNow (getkword "\n〓是否马上执行?:<No>"))
(if (= RunNow "Y")
(progn
(command "._script" sf)
(princ "\n**** 处理完成 *****")
)
(princ "\n***** 执行中了 *****")
)
)
(princ "\n***** 文件夹中不存在DWG文件 *****")
)
)
(princ "\n◎选择文件夹")
)
(princ)
)

yaokui25 发表于 2015-11-4 10:34:30

上面这段也是拿过来自己改的,你可以参考一下
页: [1]
查看完整版本: CAD利用.scr文件,批量插入.dwg文件