Jump to content

Recommended Posts

Posted

I was looking around the web and found this code that takes PDFs and deletes them from the drawing. The code seemed like it would be easy to change the function from delete to possible change the external reference path to none. Just not having any luck figuring it out. I did not know if there might be a way it could adapt to it or not.

(vl-load-com)

; detach pdf underlay
;;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-detach-all-pdfs/td-p/8852704
(defun c:delpdf (/ ss tbl dict)
 (if (setq ss (ssget "_X" '((0 . "PDFUNDERLAY"))))
  (progn
   (foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
    (setq tbl (tblsearch "layer" (cdr (assoc '8 (entget ename)))))

    (if (not (= (logand (cdr (assoc '70 tbl)) 4) 4)) ; skip locked layers
     (entdel ename)
    )
   ); foreach
   
   (setq dict (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))))

;;   (vlax-map-collection (vla-item dict "ACAD_PDFDEFINITIONS") 'vla-delete)

   (vlax-map-collection (vla-item dict "ACAD_PDFDEFINITIONS") 'vla-remove)

   (vlax-release-object dict)
  ); progn
 ); if

 (princ)) 

Thanks for any pointers!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...