本帖最后由 byghbcx 于 2011-11-19 22:16 编辑
 - (defun c:cn_dx(/ dir dir1 file n file$ newdoc dwgname);批量处理地图
- (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
- )
- )
- (vl-load-com)
- (setvar 'blipmode 0)
- (setvar 'cmdecho 0)
- (setq dir (qf_getFolder "请选择要批量处理文件所在文件夹" ))
- (setq dir1 (qf_getFolder "请选择要插入源图文件的文件夹" ))
- (setq file (vl-directory-files dir "*.dwg" 1) n 0)
- (repeat (length file)
- (setq file$ (nth n file))
- (setq dwgname (strcat dir "\\" file$))
- (setq newdoc (vla-open (vla-get-documents (vlax-get-acad-object)) dwgname));打开并获得档
- (vla-insertblock (vla-get-modelspace newdoc) (vlax-3d-point '(0 0 0)) (strcat dir1 "\\" file$) 1 1 1 0)
- (princ (strcat "\r正在处理地形图" dir "\\" file$))
- (vla-close newdoc :vlax-true);关闭另存档
- (setq n (1+ n))
- )
- (setvar 'cmdecho 1)
- (princ)
- )
|