> uswer
Могу предложить решение только на Лиспе,
переписывать на VBA времени
После загрузки файла, набрать в командной
строке CBR + Enter.
Выбрать в папке, откуда копировать, любой
чертеж.
Не обрабатывает вложенные папки, их нужно
окучивать отдельно.
Естественно, запускать программу из чертежа,
в который копируешь.
~'J'~
;; written by Fatty T.O.H (c) 2004
;; all rights removed
;; get ObjectDBX document
;; edited 4/20/06
;; edited 5/28/06 by Jeff M (see commented lines)
;; edited 10/5/06
;; edited 3/19/07
;; edited 3/20/07
(defun odbx-test (/ dbx_doc)
;; edited 5/28/06 by Jeff M
;; modified slightly to work with more versions
(or (vl-load-com))
(if (< (setq dbxver (atoi (getvar "ACADVER"))) 15)
(progn (alert
"ObjectDBX method not applicable\nin this AutoCAD version"
)
(exit)
(princ)
(gc)
)
(progn
(if (= (atoi (getvar "ACADVER")) 15)
(progn
(if (not (vl-registry-read
"HKEY_CLASSES_ROOT\\ObjectDBX.AxDbDocument\\CLSID"
)
)
(startapp "regsvr32.exe"
(strcat "/s \"" (findfile "axdb15.dll") "\"")
)
)
(setq dbx_doc (vla-getinterfaceobject
(vlax-get-acad-object)
"ObjectDBX.AxDbDocument"
)
)
)
(setq dbx_doc (vla-getinterfaceobject
(vlax-get-acad-object)
(strcat "ObjectDBX.AxDbDocument." (itoa (fix dbxver)))
)
)
)
)
)
)
;; main programm :
;; edited 7/10/07
(defun C:CBR (/ acapp acsp adoc blk fn fname fold
full_name_list odbx other_doc)
(vl-load-com)
(or acapp
(setq acapp (vlax-get-acad-object))
)
(or adoc
(setq adoc (vla-get-activedocument acapp))
)
(or acsp
(setq acsp (if (= (getvar "CVPORT") 1)
(vla-get-paperspace
adoc)
(vla-get-modelspace
adoc)
)
)
)
(vla-startundomark adoc)
(setq odbx (odbx-test))
(setq fn (getfiled "Select *ANY .DWG FILE* in a desired folder : "
""
"dwg"
4
)
fold (vl-filename-directory fn)
full_name_list (vl-directory-files fold "*.dwg" 1)
full_name_list (mapcar (function (lambda (x)
(strcat fold "\\" x)
)
)
full_name_list
)
)
(if (setq other_doc (odbx-test))
;;moved out of foreach
(progn
(foreach other full_name_list
(if (setq fname (findfile other))
(progn
(vla-open other_doc fname)
(vlax-for blk (vla-get-blocks other_doc)
(vl-catch-all-apply
(function
(lambda ()
(vla-copyobjects
other_doc
(vlax-safearray-fill
(vlax-make-safearray vlax-vbobject '(0 . 0))
(list blk)
)
(vla-get-blocks adoc)
)
)
)
)
)
;;; (vlax-invoke other_doc 'SaveAs fname)
;the next line does nothing for a ODBX doc
;;;(vl-catch-all-apply (function (lambda ()
;;;(vla-update acapp))))
)
(princ "\File Not Found")
)
)
)
)
;;moved following 2 lines out of foreach
(vl-catch-all-apply
(function (lambda ()
(vlax-release-object other_doc)
)
)
)
(setq other_doc nil)
;no need for these next 2 lines
;(vla-setvariable adoc "SDI" mdmod)
; (vla-endundomark adoc)
(gc)
(princ)
)
(princ "\n Type CBR to run programm...")
(princ)