;; (copy-blk "T:\\ACLAND\\2016\\Next_Gen\\APENDIX.dwg" "NORTH");;;;;;
;; return T if successful, nil otherwise;;;;;;;;;;
(vl-load-com)
(defun copy-blk (dwg blk / blkdbx catch odbx)
(if (findfile dwg)
(progn
(if (< (atoi (substr (getvar "ACADVER") 1 2)) 16)
(setq odbx (vlax-create-object "ObjectDBX.AxDbDocument"))
(setq odbx (vlax-create-object
(strcat "ObjectDBX.AxDbDocument." (substr (getvar "ACADVER") 1 2))
)
)
)
(vla-open odbx dwg)
(if (not
(setq
catch (vl-catch-all-error-p
(vl-catch-all-apply
(function (lambda () (setq blkdbx (vla-item (vla-get-blocks odbx) blk))))
)
)
)
)
(vla-copyobjects
odbx
(vlax-safearray-fill
(vlax-make-safearray vlax-vbObject '(0 . 0))
(list blkdbx)
)
(vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
)
)
(vlax-release-object odbx)
(if (and (null catch)
(vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
blk
)
)
T
nil
)
)
nil
)
)
(defun copy-blk (blk / dwg blkdbx catch odbx)
(vl-load-com)
(setq path (getvar 'DWGPREFIX))
(if (setq dwg (getfiled "Select Block:" path "" 33))
(progn
(if (< (atoi (substr (getvar "ACADVER") 1 2)) 16)
(setq odbx (vlax-create-object "ObjectDBX.AxDbDocument"))
(setq odbx (vlax-create-object
(strcat "ObjectDBX.AxDbDocument." (substr (getvar "ACADVER") 1 2))
)
)
)
(vla-open odbx dwg)
(if (not
(setq
catch (vl-catch-all-error-p
(vl-catch-all-apply
(function (lambda () (setq blkdbx (vla-item (vla-get-blocks odbx) blk))))
)
)
)
)
(vla-copyobjects
odbx
(vlax-safearray-fill
(vlax-make-safearray vlax-vbObject '(0 . 0))
(list blkdbx)
)
(vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
)
)
(vlax-release-object odbx)
(if (and (null catch)
(vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
blk
)
)
T
nil
)
)
nil
)
)
(defun copy-blk (dwg blk / blkdbx catch odbx)
(if (findfile dwg)
(defun copy-blk (blk / dwg blkdbx catch odbx)
(vl-load-com)
(setq path (getvar 'DWGPREFIX))
(if (setq dwg (getfiled "Select Block:" path "" 33))
Nailed it! Works.Rather than embedding it in the sub-function, consider:Code: [Select](defun copy-blk (dwg blk / blkdbx catch odbx)
(if (findfile dwg)
to this...Code: [Select](defun copy-blk (blk / dwg blkdbx catch odbx)
(vl-load-com)
(setq path (getvar 'DWGPREFIX))
(if (setq dwg (getfiled "Select Block:" path "" 33))
Thank you for your help. I think i can apply this to some others that are hard coded and use this method!
^C^C^P(progn(startapp "explorer" (strcat "/n,/e," (vl-string-subst (strcat "Map" (chr 92) "Sample" (chr 92) "Symbols") "express" (vl-filename-directory (findfile "acetauto.lsp")))))(princ))
;
should open the folder Map - North Arrows.dwg is saved in.