Halsy Posted September 17, 2021 Posted September 17, 2021 (edited) Hi friends I need lisp code for display alert massage one first time use of function. When user use that command then that alert massage don't shown on screen Edited September 17, 2021 by Halsy Quote
tombu Posted September 17, 2021 Posted September 17, 2021 Assuming you're talking about one of your lisp functions have it save a value to a global variable but check that value first and if it's nil display the alert message. Quote
tombu Posted September 17, 2021 Posted September 17, 2021 2 minutes ago, Halsy said: Can you provide code for same Can you provide the code for the function you want modified? Quote
Halsy Posted September 17, 2021 Author Posted September 17, 2021 (defun c:scpanel (/ p1 p2 p3 p4 p5 p6 p7 left right oldsnap) (alert " Please use Maximum number of 400 SC 400") (setq p1 (getpoint "\ pick a corner point: ")) (setq oldsnap (getvar ' osmode)) (setvar ' osmode 0) (setq left (getreal "\ Enter Leftside of panel: ") right (getreal "\ Enter Rightside of panel: ") ) (setq p2 (polar p1 (* pi 1.5) left) p3 (polar p2 0 100) p4 (polar p3 ( / pi 2) (- left 100)) p5 (polar p1 0 right) p6 (polar p4 0 (- right 100)) ) (command "pline" p1 p2 p3 p4 p6 p5 p1 "c")(setq s(entlast)) (command ".text" p4 65 0 (strcat (rtos left 2 0 ) " SC " (rtos right 2 0 ) ))(setq s1(entlast)) (setvar ' osmode oldsnap) (repeat 2 (setq ang (getangle "\nEnter Rotation angle: ")) (setq ang1 (* 180.0 (/ ang pi))) (command "rotate" s s1 "" p1 ang1 "") ) (princ) ) Quote
Halsy Posted September 17, 2021 Author Posted September 17, 2021 Just now, Halsy said: (alert " Please use Maximum number of 400 SC 400") this massage has to display only once when user use scpanel command Quote
tombu Posted September 17, 2021 Posted September 17, 2021 Try (defun c:scpanel (/ p1 p2 p3 p4 p5 p6 p7 left right oldsnap) (if ±×alert×± (alert " Please use Maximum number of 400 SC 400") (setq ±×alert×± 1) ) (setq p1 (getpoint "\ pick a corner point: ")) (setq oldsnap (getvar ' osmode)) (setvar ' osmode 0) (setq left (getreal "\ Enter Leftside of panel: ") right (getreal "\ Enter Rightside of panel: ") ) (setq p2 (polar p1 (* pi 1.5) left) p3 (polar p2 0 100) p4 (polar p3 ( / pi 2) (- left 100)) p5 (polar p1 0 right) p6 (polar p4 0 (- right 100)) ) (command "pline" p1 p2 p3 p4 p6 p5 p1 "c")(setq s(entlast)) (command ".text" p4 65 0 (strcat (rtos left 2 0 ) " SC " (rtos right 2 0 ) ))(setq s1(entlast)) (setvar ' osmode oldsnap) (repeat 2 (setq ang (getangle "\nEnter Rotation angle: ")) (setq ang1 (* 180.0 (/ ang pi))) (command "rotate" s s1 "" p1 ang1 "") ) (princ) ) Quote
Halsy Posted September 17, 2021 Author Posted September 17, 2021 not working every time massage come on the screen Quote
Halsy Posted September 17, 2021 Author Posted September 17, 2021 when i use scpanel command then alert is not come on the screen but 2 time of use it come on the screen i need only one time when command runs for 1st time Quote
Steven P Posted September 17, 2021 Posted September 17, 2021 (edited) Try swapping: (if ±×alert×± (alert " Please use Maximum number of 400 SC 400") (setq ±×alert×± 1) ) to (if (= myalert nil) (progn (setq myalert 1) (alert " Please use Maximum number of 400 SC 400") ) ) Edited September 17, 2021 by Steven P A correction Quote
Steven P Posted September 17, 2021 Posted September 17, 2021 adding to this, the alert will show first time you use the command each session for each drawing, you might also look at saving the values of myalert into a registery key similar to this (if (eq (vl-registry-read "HKEY_CURRENT_USER\\Software\\TOMMY\\TIMMY") "1")(ALERT "THE KEY EXISTS AND IS SET TO 1") (Alert "THE KEY DOES NOT EXIST")) which will show the alert only once until you reset the registry key ( https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/get-registry-key-value-and-process-it/td-p/3733306 ) Quote
ronjonp Posted September 17, 2021 Posted September 17, 2021 2 hours ago, Halsy said: when i use scpanel command then alert is not come on the screen but 2 time of use it come on the screen i need only one time when command runs for 1st time @Halsy Try something like this: (or (getenv "NameYouWantToUse") (progn (alert "Hello World!") (setenv "NameYouWantToUse" "Ran"))) 1 Quote
Halsy Posted September 18, 2021 Author Posted September 18, 2021 And how to store floor height bye selecting floor bottom and floor top Quote
BIGAL Posted September 18, 2021 Posted September 18, 2021 Dont double post it becomes confusing keep the other post. Quote
Grrr Posted September 19, 2021 Posted September 19, 2021 (edited) On 9/17/2021 at 5:48 PM, Halsy said: Hi friends I need lisp code for display alert massage one first time use of function. When user use that command then that alert massage don't shown on screen If you want to display the message for the first time of that certain lisp call and for each ACAD session, then apparently you'll have to use a reactor: (defun c:scpanel (/ p1 p2 p3 p4 p5 p6 p7 left right oldsnap) ; (alert " Please use Maximum number of 400 SC 400") (setq p1 (getpoint "\ pick a corner point: ")) (setq oldsnap (getvar ' osmode)) (setvar ' osmode 0) (setq left (getreal "\ Enter Leftside of panel: ") right (getreal "\ Enter Rightside of panel: ") ) (setq p2 (polar p1 (* pi 1.5) left) p3 (polar p2 0 100) p4 (polar p3 ( / pi 2) (- left 100)) p5 (polar p1 0 right) p6 (polar p4 0 (- right 100)) ) (command "pline" p1 p2 p3 p4 p6 p5 p1 "c")(setq s(entlast)) (command ".text" p4 65 0 (strcat (rtos left 2 0 ) " SC " (rtos right 2 0 ) ))(setq s1(entlast)) (setvar ' osmode oldsnap) (repeat 2 (setq ang (getangle "\nEnter Rotation angle: ")) (setq ang1 (* 180.0 (/ ang pi))) (command "rotate" s s1 "" p1 ang1 "") ) (princ) ) ( (lambda ( rnm cmd msg ) ; Alert once code snippet by Grrr (setq cmd (strcase cmd)) (foreach rtr (cdar (vlr-reactors :vlr-lisp-reactor)) (if (= cmd (vlr-data rtr)) (vlr-remove rtr)) ) (eval (list (quote VLR-Lisp-Reactor) (quote cmd) (list (quote quote) (list (cons :VLR-lispWillStart rnm))))) (eval (list 'defun rnm (list 'rtr 'arg '/ 'rtn) (list 'cond (list (list '= cmd (list 'car 'arg)) (list 'alert msg) (list 'vlr-remove 'rtr) (list 'setq rnm nil) ) ) (list 'princ) ) ); eval ); lambda 'SCpanel:AlertOnce:CB ; Reactor's callback function name "(C:SCPANEL)" ; The lisp command call to trace " Please use Maximum number of 400 SC 400" ; The alert message ) See the lambda code snippet below of your code and adjust the arguments for your needs. Edited September 19, 2021 by Grrr Quote
ronjonp Posted September 20, 2021 Posted September 20, 2021 (edited) On 9/17/2021 at 11:39 AM, Halsy said: when i use scpanel command then alert is not come on the screen but 2 time of use it come on the screen i need only one time when command runs for 1st time @Halsy Food for thought: (defun c:scpanel (/ ang ang1 left oldsnap p1 p2 p3 p4 p5 p6 right s s1) ;; Run once daily ;;; (or (= (rtos (getvar 'cdate) 2 0) (getenv "NameYouWantToUse")) ;;; (progn (alert "Hello World!") (setenv "NameYouWantToUse" (rtos (getvar 'cdate) 2 0))) ;;; ) ;; Check your input rather than alerting once daily your rules (cond ((and (setq p1 (getpoint "\nPick a corner point: ")) (< (setq left (getreal "\nEnter Leftside of panel: ")) 400) (< (setq right (getreal "\nEnter Rightside of panel: ")) 400) ) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setq p2 (polar p1 (* pi 1.5) left) p3 (polar p2 0 100) p4 (polar p3 (/ pi 2) (- left 100)) p5 (polar p1 0 right) p6 (polar p4 0 (- right 100)) ) (command "pline" p1 p2 p3 p4 p6 p5 p1 "c") (setq s (entlast)) (command ".text" p4 65 0 (strcat (rtos left 2 0) " SC " (rtos right 2 0))) (setq s1 (entlast)) (setvar 'osmode oldsnap) (repeat 2 (setq ang (getangle "\nEnter Rotation angle: ")) (setq ang1 (* 180.0 (/ ang pi))) (command "rotate" s s1 "" p1 ang1 "") ) ) ((alert "Please use Maximum number of 400")) ) (princ) ) Edited September 20, 2021 by ronjonp Quote
Recommended Posts
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.