I have a directory with hundreds of TIF and PDF files - all need some AutoCad work done and it would take very long to create a dwg for each of them manually.
I have found a lisp routine to attach all .tif files from a folder, but I'm not sure how to make it work for pdfs.
Code:
{code}
(defun c:MakeDrawingsFromImages (/ FullPath DirPath ImList dbxApp oVer dbxMs dbxDictCol dbxIm dbxImDict *error*)
(vl-load-com)
(defun *error* (msg) (vl-bt))
(if
(and
(setq FullPath (getfiled "Select image file in directory to use." "" "tif" 4))
(setq DirPath (vl-filename-directory FullPath))
(setq ImList (vl-directory-files DirPath "*.tif" 1))
(setq dbxApp
(if (< (atoi (setq oVer (substr (getvar "acadver") 1 2))) 16)
(vla-GetInterfaceObject (vlax-get-acad-object) "ObjectDBX.AxDbDocument")
(vla-GetInterfaceObject (vlax-get-acad-object) (strcat "ObjectDBX.AxDbDocument." oVer))
)
)
(setq dbxMs (vla-get-ModelSpace dbxApp))
(setq dbxDictCol (vla-get-Dictionaries dbxApp))
)
(foreach name ImList
(setq dbxIm (vlax-invoke dbxMs 'AddRaster (strcat DirPath "\\" name) '(0.0 0.0 0.0) 1.0 0.0))
(vla-put-Name dbxIm (vl-filename-base name))
(vla-put-ScaleFactor dbxIm 1.0)
(vla-SaveAs dbxApp (strcat DirPath "\\" (vl-filename-base name) ".dwg"))
(setq dbxImDict (vla-Item dbxDictCol "ACAD_IMAGE_DICT"))
(vla-Delete dbxIm)
(vla-Delete (vla-Item dbxImDict 0))
(vla-Delete dbxImDict)
)
)
(mapcar
'(lambda (x)
(vl-catch-all-apply 'vlax-release-object x)
)
'(dbxImDict dbxIm dbxDictCol dbxMs dbxApp)
)
(princ)
)
{code}