A different approach that is more a tool for coders than end users --
(defun _CopyTable ( sourceDoc targetDoc table pattern / @GetName collection array result )
[color=green] ;; Source and target docs can be opened in the editor
;; or via ObjectDBX, no matter.
;;
;; Table needs to a symbol corresponding to a valid
;; table that is a direct child of an AutoCAD document,
;; for example, 'Block, 'Dictionaries, 'Dimstyles etc.
;;
;; Pattern is used to limit the copy to specific item
;; names (if so desired). If not a strng, ie null it's
;; coerced to "*"; everything.
;;
;; eg: (_CopyTable doc1 doc2 'UserCoordinateSystems "*")[/color]
(defun @GetName ( item / result )
[color=green] ;; some collection items don't have names,
;; for example some dictionary entries, so
;; let's trap that potential error[/color]
(if
(vl-catch-all-error-p
(vl-catch-all-apply
'(lambda ( )
(setq result (vla-get-name item))
)
)
)
""
result
)
)
[color=green] ;; ok, let's roll ... [/color]
(setq
collection (vlax-get-property targetDoc table)
pattern (if (eq 'str (type pattern)) (strcase pattern) "*")
array (vlax-make-safearray vlax-vbObject '(0 . 0))
)
[color=green] ;; The following looks inefficient but it thwarts a
;; complete copy failure if one item makes chucks a
;; wobbly, which is what would happen if you put all
;; the candidate objects in one safe array and then
;; invoked the CopyObjects method on the entire lot.
;; The preceding theory is actually a guess and not
;; proven as of yet, but that's the rationale for
;; coding it this way. When I've some time I'll
;; determine if any collections make the CopyObjects
;; function toss its cookies if copied en masse. If
;; not I'll revise to reflect.[/color]
(vlax-for item (vlax-get sourceDoc table)
(if (wcmatch (strcase (@GetName item)) pattern)
(vl-catch-all-apply
'(lambda ( )
(vlax-invoke-method
sourceDoc
'CopyObjects
(progn
[color=green] ;; slightly faster than vlax-safearray-fill[/color]
(vlax-safearray-put-element array 0 item)
array
)
collection
)
(setq result (cons item result))
)
)
)
)
[color=green] ;; let the caller know what we successfully copied[/color]
(reverse result)
)
Example:
[color=green];; assumes dbx1 and dbx2 are valid document objects[/color]
(if (setq copied (_CopyTable dbx1 dbx2 'UserCoordinateSystems "test*"))
(progn
(princ "Copied these UCSs:\n")
(mapcar
'(lambda (item) (print (vla-get-name item)))
copied
)
(princ)
)
)
Might spit this back:
Copied these UCSs:
"Test1"
"Test2"
"Test3"
For what it's worth ... Michael.