Add audible feedback “sounds” to brighten your AutoLISP functions
Pretty much the totality of my AutoLISP customization has been mute. Last week I decided that it was time to make a little noise.
For example, if my function failed for some reason (operator input error or premature program exit), I wanted the tool to not just issue a little message to the command window… I wanted it to be accompanied with a clundge sound.
A search turned up a couple methods to embed some simple sounds into an AutoLISP function. The one way that seemed to work for me was using a call to “acet-sys-beep” and this only after I installed the “Express tool” option that comes on the AutoCAD install CD.
But once in place, there were three different sounds I could generate from this call. If you want to experiment, type each of these at the “Command:” prompt (if you don’t hear a thing, you may need to check for existence of the AutoCAD ”EXPRESSTOOLS” on your machine):
- (acet-sys-beep 16) [Enter]
- (acet-sys-beep 48) [Enter]
- (acet-sys-beep 64) [Enter]
Sample Utility that invokes a couple different sounds
Here’s an example function showing how two different sounds can be tied into success and failure of a function. This tool just swaps tag-ID values between two picked AutoCAD Electrical components. If the components are different types, then an error dialog is accompanied by a bad sound. If success, then a more happy sound.
This is not rocket-science. But it makes my mundane utility just a bit more interesting.
The two places where the sound is invoked is highlighted below. Just to be safe, in both places there is a call to confirm that function (acet-sys-beep…) exists… before trying to call it.