TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: mohan on June 22, 2021, 09:40:56 AM

Title: Alarm between route
Post by: mohan on June 22, 2021, 09:40:56 AM
I want a sound between each route !      :sick:

Code: [Select]
(defun c: run ( / )
  (c:work1)
make sound . . .
  (c:work2)
make sound . . .
  (c:work3)
make sound . . .
(princ))
Title: Re: Alarm between route
Post by: CodeDing on June 22, 2021, 09:54:42 AM
Mohan,

Do you have Express Tools installed?
If so, you can use:
Code: [Select]
(acet-sys-beep 16)

https://www.cadsta.com/CADSTA-Tools-(acet-sys-beep).html (https://www.cadsta.com/CADSTA-Tools-(acet-sys-beep).html)

Best,
~DD
Title: Re: Alarm between route
Post by: CodeDing on June 22, 2021, 09:58:55 AM
...or if you want to get real fancy, I use this one for jokes sometimes:

Code: [Select]
(defun Speak (txt / sapi)
  ;from user sea.haven @ https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/usb-flash-drive-serial-number/m-p/9631481#M402295
  ;txt - string, of text to have computer speak
  (if (eq (type txt) 'STR)
    (progn
      (setq sapi (vlax-create-object "Sapi.SpVoice"))
      (vlax-put sapi 'SynchronousSpeakTimeout 1)
      (vlax-invoke-method sapi 'WaitUntilDone 0)
      (vlax-invoke sapi "Speak" txt 0)
      (vlax-release-object sapi)
    );progn
  );if
  (princ)
);defun

Use like so:

Code: [Select]
(Speak "Program Complete.")
Title: Re: Alarm between route
Post by: Lonnie on June 22, 2021, 12:06:50 PM
Neat.

I am replacing some of my alerts with speak.  :whistling:

(speak "You have been changed to DCE Standards.\n \nPlease restart Autocad.")
Title: Re: Alarm between route
Post by: BIGAL on June 22, 2021, 09:19:31 PM
You may need 2 lines  or remove the \n's, 2 lines or more will do a pause between lines.

Code: [Select]
(speak "You have been changed to DCE Standards please restart Autocad")
or
(speak "You have been changed to DCE Standards")
(speak "please restart Autocad")


If you dont want the text to voice lisp in your code save to a support path then only need.
Code: [Select]
(if (not speak)(Load "text to voice"))

PS from sea.haven
Title: Re: Alarm between route
Post by: mohan on June 23, 2021, 04:28:30 AM
Mohan,

Do you have Express Tools installed?
If so, you can use:
Code: [Select]
(acet-sys-beep 16)

https://www.cadsta.com/CADSTA-Tools-(acet-sys-beep).html (https://www.cadsta.com/CADSTA-Tools-(acet-sys-beep).html)

Best,
~DD
Yes, Express Tools is installed, thank you guys
Still speaking sound learning . . .
Title: Re: Alarm between route
Post by: Lonnie on June 23, 2021, 12:17:42 PM
That line was directly from my alert. Work well just like that only I had to change AutoCAD to Autocad. It spelled out the cad. In addition the "." caused a pause anyway so the sentences were about perfect anyway. Pure play but I am thinking about adding a LOGINNAME to the sentence so it addresses the person by their last name.
Somthing like
(
(setq lg (getvar 'LOGINNAME))
(speak (strcat "hello mister" lg "You have been upgraded to the DCE Standards. Please restart Autocad. Thank you."))
)

You may need 2 lines  or remove the \n's, 2 lines or more will do a pause between lines.

Code: [Select]
(speak "You have been changed to DCE Standards please restart Autocad")
or
(speak "You have been changed to DCE Standards")
(speak "please restart Autocad")


If you dont want the text to voice lisp in your code save to a support path then only need.
Code: [Select]
(if (not speak)(Load "text to voice"))

PS from sea.haven
Title: Re: Alarm between route
Post by: BIGAL on June 23, 2021, 09:01:29 PM
Use a cond and then full name our (getenv "username") was 2 letters and a number.

Code: [Select]
(cond
((= (getvar 'LOGINNAME) "Lg0123")(setq uname "Lonnie"))
((= (getvar 'LOGINNAME) "BR0123")(setq uname "Barney Rubble"))
((= (getvar 'LOGINNAME) "FF0123")(setq uname "Fred Flinstone"))
)
(speak (strcat "hello " uname "You have been upgraded to the DCE Standards. Please restart Autocad. Thank you."))

Good to know about "." = pause.
Title: Re: Alarm between route
Post by: ronjonp on June 24, 2021, 12:15:49 PM
Use a cond and then full name our (getenv "username") was 2 letters and a number.

Code: [Select]
(cond
((= (getvar 'LOGINNAME) "Lg0123")(setq uname "Lonnie"))
((= (getvar 'LOGINNAME) "BR0123")(setq uname "Barney Rubble"))
((= (getvar 'LOGINNAME) "FF0123")(setq uname "Fred Flinstone"))
)
(speak (strcat "hello " uname "You have been upgraded to the DCE Standards. Please restart Autocad. Thank you."))

Good to know about "." = pause.
@Bigal ... no need to set 'uname' for each entry:
Code - Auto/Visual Lisp: [Select]
  1. (setq uname (cond ((= (getvar 'loginname) "Lg0123") "Lonnie")
  2.                   ((= (getvar 'loginname) "BR0123") "Barney Rubble")
  3.                   ((= (getvar 'loginname) "FF0123") "Fred Flinstone")
  4.                   ("unknown user!")
  5.             )
  6. )
Title: Re: Alarm between route
Post by: Lee Mac on June 24, 2021, 12:58:50 PM
I'd probably opt for an association list for ease of maintenance e.g.:
Code - Auto/Visual Lisp: [Select]
  1. (setq lst
  2.    '(
  3.         ("Lg0123" . "Lonnie")
  4.         ("BR0123" . "Barney Rubble")
  5.         ("FF0123" . "Fred Flinstone")
  6.     )
  7. )
  8. (speak
  9.     (strcat
  10.         "hello "
  11.         (cond ((cdr (assoc (getvar 'loginname) lst)))("unknown user!"))
  12.         "You have been upgraded to the DCE Standards. Please restart Autocad. Thank you."
  13.     )
  14. )
  15.  
Title: Re: Alarm between route
Post by: BIGAL on June 24, 2021, 07:45:27 PM
Lee good idea

The username was used in plot routines we had 4 floors in a building and it would auto send to correct plotter based on name. No up down stairs.

The only question is now do you know who Fred Flinstone is ? Yes or No please, gives away age.