Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

autolisp to flip variable

2 REPLIES 2
Reply
Message 1 of 3
TexShalter
318 Views, 2 Replies

autolisp to flip variable

I'm trying to make an autolisp that "flips" a third party variable. No luck, command line won't recognize after it loads. I've made similar variable flips that work ??

thanks anyone

 

(defun c:wp (/ wp)
  (setq wp (getvar "kti_archt_wallpoche"))
  (if (= kti_archt_wallpoche 0)(setvar "kti_archt_wallpoche" 1)
  (if (= kti_archt_wallpoche 1)(setvar "kti_archt_wallpoche" 0)

 

2 REPLIES 2
Message 2 of 3
bgingerich
in reply to: TexShalter

Instead of:

(if (= kti_archt_wallpoche 0)(setvar "kti_archt_wallpoche" 1)
(if (= kti_archt_wallpoche 1)(setvar "kti_archt_wallpoche" 0)

 try:

(setvar "kti_archt_wallpoche" (- 1 (getvar "kti_archt_wallpoche"))

 (if ("mysolution"=answer) then (click "Accept As Solution"))
------------------------------------------------------------------------------------

 

─────────────────────────────────────────────────────────────────────────────────────────────
Brandon Gingerich
Message 3 of 3
Kent1Cooper
in reply to: TexShalter


@TexShalter wrote:

I'm trying to make an autolisp that "flips" a third party variable. No luck, command line won't recognize after it loads. I've made similar variable flips that work ??

thanks anyone

 

(defun c:wp (/ wp)
  (setq wp (getvar "kti_archt_wallpoche"))
  (if (= kti_archt_wallpoche 0)(setvar "kti_archt_wallpoche" 1)
  (if (= kti_archt_wallpoche 1)(setvar "kti_archt_wallpoche" 0)

 


I would agree with the other suggestion to just subtract the current value from 1, which spares you the need for the wp variable.  But if you want the double (if) approach, they would need to be:

 

  (if (= wp 0)(setvar "kti_archt_wallpoche" 1)
  (if (= wp 1)(setvar "kti_archt_wallpoche" 0)

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost