Autodesk Technology Managers Forum
Share your knowledge, ask questions, and engage with fellow CAD/BIM Managers.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Printing confirmation to command line after "if" function in lisp

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
hammonj7
865 Views, 4 Replies

Printing confirmation to command line after "if" function in lisp

I am using a lisp routine to toggle some system variables that I change fairly often.  My lisp works just fine...for me.  However, my general users are interested in seeing an acknowledgment of the switch printed to the command line after the command has been executed.  Here is the code I am using: 

 

(defun c:rnm ()
  (if (= (getvar "osmode") 1791)
  (setvar "osmode" 1088) ;
Sets object snap mode to insertion point only
  (setvar "osmode" 1791) ;
Sets object snap mode to "normal" osmode
    )
  (princ)
    )

 

Basically, I would like to use (princ "\nOsmode Insertion point set.") or whatever when my little routine runs.  So when it sees 1791 is active it changes it to 1088, then prints a confirmation to the command line, and vice versa. 

 

I have a feeling this is simple, but for some reason the solution elludes me. 

 

Thanks for your help!

 

4 REPLIES 4
Message 2 of 5
Randy_Culp
in reply to: hammonj7

Try this:

 

(defun c:rnm ()
(if (= (getvar "osmode") 1791)
;;;;;;;;;
(progn
(setvar "osmode" 1088) ;Sets object snap mode to insertion point only
(princ "\nOSNAP set to Insertion Point")
) ;; end progn
;;;;;;;;;
(progn
(setvar "osmode" 1791) ;Sets object snap mode to "normal" osmode
(princ "\nOSNAP set to NORMAL")
) ;; end progn
;;;;;;;;;
) ;; end if
(princ)
)

Message 3 of 5
hammonj7
in reply to: Randy_Culp

Hi Randy,

 

Thanks for the code, it does exactly what I was looking to do!

 

Would you happen to know what to use if I wanted to add a third variable?

 

Thanks!

Message 4 of 5
Randy_Culp
in reply to: hammonj7

Instead if using IF use COND. Look it up in developer help. The guys over in the customization forum will be glad to get specific.

 

or

 

If you really want to get into lisp and custom programming check out:

http://www.theswamp.org/

Message 5 of 5
hammonj7
in reply to: Randy_Culp

Thanks, you are right, I should continue this over in customization (if I need to that is).

 

I have been on the swamp since your last reply, and it is a fantastic resource!  Thanks for your help.Smiley Happy

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

Post to forums  

Administrator Productivity


Autodesk Design & Make Report