Jump to content

Lisp to show/hide all images - change in DXF codes


Radu Iordache

Recommended Posts

Hi everybody, I need a lisp that will show/hide all images in a drawing by the push of a button. From my search this is possible by change in dxf codes.

By command (ENTGET (CAR (ENTSEL))) I got the DXF codes for an image when "Show image" property is "YES" and then "NO". It appears that the only difference is (70 . 7) when "YES" versus (70 . 6) when "NO".

I am wondering if there is a way by lisp to select all images and change (70 . 7) to (70 . 6) for all of them (and back). Of course I could do it by just selecting all images and change the property in properties window but it seems to be more elegant with a button that I would assign to the lisp command :)

If you know of any lisp that does this maybe for another property of another type of object, would be good anyway to adapt.

Thank you!

 

 

Link to comment
Share on other sites

Solved by ChatGPT :)

;IMGOFF

(defun c:IMGOFF (/ ss)
  (setq ss (ssget "_X" '((0 . "IMAGE"))))
  (if ss
      (progn
        (setq i 0)
        (while (< i (sslength ss))
          (entmod (subst (cons 70 6) (assoc 70 (entget (ssname ss i))) (entget (ssname ss i))))
          (setq i (1+ i))
        )
        (princ (strcat "\nChanged DXF code for " (itoa (sslength ss)) " images."))
      )
      (princ "\nNo images found.")
  )
)

;IMGON

(defun c:IMGON (/ ss)
  (setq ss (ssget "_X" '((0 . "IMAGE"))))
  (if ss
      (progn
        (setq i 0)
        (while (< i (sslength ss))
          (entmod (subst (cons 70 7) (assoc 70 (entget (ssname ss i))) (entget (ssname ss i))))
          (setq i (1+ i))
        )
        (princ (strcat "\nChanged DXF code for " (itoa (sslength ss)) " images."))
      )
      (princ "\nNo images found.")
  )
)

 

Link to comment
Share on other sites

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...