Jump to content

Recommended Posts

Posted

I found a couple of other LISP toggles on this website but am unsure how to edit them to create a lisp routine for a LWT toggle.

 

Any help will be appreciated.

Posted

(defun c:lwt ()
 (if
   (= (getvar "lwdisplay") 1)
   (setvar "lwdisplay" 0)
   (setvar "lwdisplay" 1)
      )
 )

or you could just click on the LWT button on the status bar

Posted

Thanks lpseifert, i needed this rountine to run as part of another lisp routine.

 

Clicking the LWT button is the easy way to do this but doesnt suit my app.

 

Cheers

Posted

And to save a tiny bit of storage space :)

 

(defun c:lwt ()
  (setvar "lwdisplay" (- 1 (getvar "lwdisplay"))
)

Posted

cool trick Carl, I'd have thunk there should be an (abs in there... you learn something new every day.

Posted

Good point lpseifert - Obviously Carl's code needs an extra right parenthesis, but this aside, why does it not require an (abs)?

 

If you type:

 

(setvar "lwdisplay" -1)

 

in the command line, ACAD rejects the variable setting.

 

So how can this code work without the (abs)? :glare:

Posted

There would be no negative result, try it:

It's either :

1-1=0

or

1-0=1

 

Yup, I missed a dang paren :)

Posted

Upon further review...

I mistakenly read (- 1 as 'subtract 1 from' even though I know better. Gotta start to thinking in 'lisp'.

Posted
And to save a tiny bit of storage space :)

 

(defun c:lwt ()
  (setvar "lwdisplay" (- 1 (getvar "lwdisplay"))
)

 

 

 

a nice one carlb, you need to put your name there, let's call it carlbtoggler....:)

Posted

Of course.... I read it the same as lpseifert - subtracting 1 from whichever value the variable is set at.

 

But I take my hat off to you (if I had one), a simple and clever bit of coding indeed. :D

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