Results 1 to 2 of 2

Thread: PDF to DWG batch

  1. #1
    The Silent Type
    Join Date
    2019-02
    Posts
    1
    Login to Give a bone
    0

    Default PDF to DWG batch

    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}

  2. #2
    I could stop if I wanted to
    Join Date
    2003-07
    Posts
    311
    Login to Give a bone
    0

    Default Re: PDF to DWG batch

    See the answer over at Autodesk forums Lisp

Similar Threads

  1. Batch Converting CTB to STB
    By brendan.j.mallon in forum Dot Net API
    Replies: 8
    Last Post: 2016-04-15, 02:25 PM
  2. DWG to PDF Batch
    By RockDog in forum AutoCAD General
    Replies: 10
    Last Post: 2009-10-26, 02:08 PM
  3. Batch changes
    By jkg in forum AutoLISP
    Replies: 3
    Last Post: 2009-05-15, 03:16 PM
  4. Batch Converter
    By rjairath in forum AutoCAD Civil 3D - General
    Replies: 0
    Last Post: 2006-11-27, 05:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •