Jump to content

On Off toggle with an Icon


JoeyG_77

Recommended Posts

Hey everyone .... I have a lisp that turns off a set of layers, but I want to click the icon again and have them turn on 

 

(defun c:XLAYERS (/ l n v e)
 (while (setq l (tblnext "LAYER" (not l)))
   (and (wcmatch (setq n (cdr (assoc 2 l))) "*XLINE*")
        (or (minusp (setq v (cdr (assoc 62 (setq e (entget (tblobjname "LAYER" n)))))))
            (entmod (append e (list (cons 62 (- v)))))
            )
        )
   )
 (princ)
)

This is the code I found from Twarwat ... Thanks Man

 

any help would be appreciated 

Thanks Joey G

Link to comment
Share on other sites

40 minutes ago, JoeyG_77 said:

Hey everyone .... I have a lisp that turns off a set of layers, but I want to click the icon again and have them turn on 

 


(defun c:XLAYERS (/ l n v e)
 (while (setq l (tblnext "LAYER" (not l)))
   (and (wcmatch (setq n (cdr (assoc 2 l))) "*XLINE*")
        (or (minusp (setq v (cdr (assoc 62 (setq e (entget (tblobjname "LAYER" n)))))))
            (entmod (append e (list (cons 62 (- v)))))
            )
        )
   )
 (princ)
)

This is the code I found from Twarwat ... Thanks Man

 

any help would be appreciated 

Thanks Joey G

 

Try this modification. It is case agnostic.

 

(defun c:XLAYERS (/ l n v e)
  (while (setq l (tblnext "LAYER" (not l)))
    (cond ( (wcmatch (strcase (setq n (cdr (assoc 2 l)))) "*XLINE*")
            (setq v (cdr (assoc 62 (setq e (entget (tblobjname "LAYER" n))))))
            (cond ( (not v) (entmod (append e (list (cons 62 (* v -1))))))
                  (t (entmod (subst (cons 62 (* v -1)) (assoc 62 e) e)))
            )
          )
    )
  )
 (princ)
)

 

Link to comment
Share on other sites

Hi,

I guess this is enough.

(defun c:foo (/ l n e)
 (while (setq l (tblnext "LAYER" (not l)))
   (and (wcmatch (setq n (cdr (assoc 2 l))) "*XLINE*")
        (entmod (append (setq e (entget (tblobjname "LAYER" n))) (list (cons 62 (- (cdr (assoc 62 e)))))))
        )
   )
 (princ)
)

 

  • Like 1
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...