AutoLISP: XREFs: Remove All Pics

As seen in a previous post [found here] which removes all XREFs in a drawing, the featured routine today only removes any pictures that are in the drawing. As seen in the animated picture below, there are .bmp and .jpg formated pictures in the drawing.

Here’s how:

REMOVEALLPICS <enter> to start

That’s it…

(defun RemoveAllRaster ( doc / _catchapply dict lockd )

(vl-load-com)

(defun _catchapply ( method params / result )

(if

(not

(vl-catch-all-error-p

(setq result (vl-catch-all-apply method params))

)

)

result

)

)

(vlax-for layer (vla-get-layers doc)

(if (eq :vlax-true (vla-get-lock layer))

(vla-put-lock (car (setq lockd (cons layer lockd))) :vlax-false)

)

)

(vlax-for block (vla-get-blocks doc)

(vlax-for object block

(if (member (vla-get-objectname object) '("AcDbOle2Frame" "AcDbRasterImage"))

(_catchapply 'vla-delete (list object))

)

)

)

(if (setq dict (_catchapply 'vla-item (list (vla-get-dictionaries doc) "ACAD_IMAGE_DICT")))

(progn

(vlax-for object dict

(_catchapply 'vla-delete (list object))

)

(_catchapply 'vla-delete (list dict))

)

)

(if (setq dict (_catchapply 'vla-item (list (vla-get-dictionaries doc) "ACAD_IMAGE_VARS")))

(_catchapply 'vla-delete (list dict))

)

(foreach layer lockd (vla-put-lock layer :vlax-true))

(vla-regen doc acallviewports)

(princ)

)

(defun c:RemoveAllPics nil

(RemoveAllRaster (vla-get-activedocument (vlax-get-acad-object)))

(princ)

)

(vl-load-com)
Advertisements

About AutoCAD Tips

This blog serves as a knowledge base for myself (and anyone else) so that I can reference tips & tricks that I have learned and also refer others to it as well. I hope that this blog helps you learn at least one tip to make your drafting/design experience better.
This entry was posted in AutoLISP, Modifying, XREFs. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s