感谢回复~
我也测试了一下,只能用vla-wblock来处理了
- (setq path (strcat (getFolder "请选取要批处理的dwg文件所在目录") "\\"))
- (setq cadobj (vlax-create-object "AUTOCAD.Application"))
- (setq i 0)
- (foreach file (vl-directory-files path "*.dwg" 1)
- (setq docobj (vla-open (vla-get-documents cadobj) (strcat path file)))
-
- (setq ssetObj (vla-Add (vla-get-SelectionSets docobj) "WBLOCKSET"))
- (setq objsInModelSpace (vlax-make-safearray vlax-vbObject (cons 0 (1- (vla-get-Count (vla-get-ModelSpace docobj)))))
- cnt 0)
- (vlax-for entry (vla-get-ModelSpace docobj)
- (vlax-safearray-put-element objsInModelSpace cnt entry)
- (setq cnt (1+ cnt))
- )
- (vla-AddItems ssetObj objsInModelSpace)
- (setq filename (strcat path (substr file 1 (- (strlen file) 4)) "_Purged.dwg"))
- (vla-Wblock docobj filename ssetObj)
- (vla-Delete ssetObj)
- (setq i (1+ i))
- )
-
- (Vlax-Invoke-Method cadobj 'Quit)
|