;; IMG-ON / IMG-OFF --> I0 / I1
;; Toggle All Images

(defun c:i1 ()
(img-toggle 1)
(princ)
)

(defun c:i0 ()
(img-toggle 0)
(princ)
)

(defun img-toggle (flag / elst pair)
(vl-load-com)
(foreach img (vl-remove-if-not
(function (lambda (p) (= (car p) 350)))
(dictsearch (namedobjdict) "ACAD_IMAGE_DICT")
)
(setq elst (entget (cdr img))
pair (assoc 280 elst)
)
(entmod (subst (cons 280 flag) pair elst))
)
)

;; XREF-ON / XREF-OFF --> X0 / X1
;; Toggle All Xrefs

(defun c:x1 ()
(xref-toggle 'vla-ReLoad)
(princ)
)

(defun c:x0 ()
(xref-toggle 'vla-UnLoad)
(princ)
)

(defun xref-toggle (fun)
(vl-load-com)
(setq fun (eval fun))
(vlax-for x (vla-get-Blocks
(vla-get-ActiveDocument (vlax-get-acad-object))
)
(if (= (vla-get-IsXref x) :vlax-true)
(fun x)
)
)
(princ)
)

Advertisements