同名的CAD文件合并,
A文件夹(图名为1、2、3、4、5。。。)
B文件夹(图名为1、2、3、4、5。。。);
就是将A文件夹与B文件夹中的同名图层原坐标合并,合并后的文件放在C文件夹(图名为1、2、3、4、5。。。)
现有代码合并时,两个文件的同名块会被替换
请求修改
 - ;;;自定义函数,打开文件名
- (defun try-getFolder (msg / WinShell shFolder path catchit)
- (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
- )
- )
- ;;;;;合并
- (defun c:hhh (/ BANBEN DBX pathXZ pathgh pathgh FILESxz filesgh I j DWGNAMExz dwgnamegh)
- (vl-load-com)
- ;;; (setq banben (substr (getvar "acadver") 1 2))
- ;;; ;版本2004-2006返回16,2007-2009返回17,2010-2012返回18,2013返回19
- ;;; (setq dbx (Vlax-Get-Or-Create-Object (strcat "ObjectDBX.AxDbDocument." banben)))
- (setq pathXZ (strcat (try-getFolder "\n 选择现状图所在文件夹名称:") "\\"));文件夹路径
- (setq filesxz (vl-directory-files pathXZ "*.dwg" 1)) ;获取所有文件名
- (setq pathGH (strcat (try-getFolder "\n 选择规划图所在文件夹名称:") "\\"));文件夹路径
- (setq filesgh (vl-directory-files pathGH "*.dwg" 1)) ;获取所有文件名
- (setq pathHB (strcat (try-getFolder "\n 选择合并后所在文件夹名称:") "\\"));文件夹路径
- (setq i -1)
- (setq j -1)
- (setvar "cmdecho" 0)
- (while (setq dwgnamexz (nth (setq i (1+ i)) filesxz))
- (command "-insert" (strcat pathgh dwgnamexz) "0,0" "1" "1" "0")
- (command "_explode" "all" "");分解了,以免不懂的人不会修改表头
- (command "-purge" "a" "" "n")
- (command "-insert" (strcat pathxz dwgnamexz) "0,0" "1" "1" "0")
- (command "_explode" "all" "");分解了,以免不懂的人不会修改表头
- (command "-purge" "a" "" "n")
- (command "_saveas" "" (strcat pathHB dwgnamexz))
- (command "_erase" "all" "");全部删除图中内容
- )
- )
|