Lee Mac Posted August 11, 2009 Share Posted August 11, 2009 Maybe a bit of fun for a co-worker... Will beep upon invoking the Explode command (defun c:ExOn () (vl-load-com) (if (not *exR) (setq *exR (vlr-command-reactor nil (list (cons :vlr-commandWillStart 'Beep!))))) (princ)) (defun Beep! (Reac Args) (if (eq "EXPLODE" (strcase (car Args))) (vlr-beep-reaction nil)) (princ)) (defun c:ExOff () (if (and *exR (vlr-added-p *exR)) (progn (vlr-remove *exR) (setq *exR nil))) (princ)) Quote Link to comment Share on other sites More sharing options...
ollie Posted August 11, 2009 Share Posted August 11, 2009 Hehe I wrote a similar script recently but with a group of light hearted (alert insults) Quote Link to comment Share on other sites More sharing options...
ReMark Posted August 11, 2009 Share Posted August 11, 2009 Lee: Run out of challenges or just feeling a little bored? Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted August 12, 2009 Share Posted August 12, 2009 Mmmm makes me want to place not in that eq function, and load it on people's computers Quote Link to comment Share on other sites More sharing options...
fuccaro Posted August 12, 2009 Share Posted August 12, 2009 Once I redefined the Explode command on my colleague's computer. When he tried to explode dimensions or hatches, an allert box announced him that it is not a good drawing practice. The funny side: even today, he thinks that it is an AutoCAD built-in message Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 12, 2009 Author Share Posted August 12, 2009 Lee: Run out of challenges or just feeling a little bored? Bit of both really Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 12, 2009 Author Share Posted August 12, 2009 Once I redefined the Explode command on my colleague's computer. When he tried to explode dimensions or hatches, an allert box announced him that it is not a good drawing practice. The funny side: even today, he thinks that it is an AutoCAD built-in message Haha, nice one! Quote Link to comment Share on other sites More sharing options...
flowerrobot Posted August 12, 2009 Share Posted August 12, 2009 Once I redefined the Explode command on my colleague's computer. When he tried to explode dimensions or hatches, an allert box announced him that it is not a good drawing practice. The funny side: even today, he thinks that it is an AutoCAD built-in message I like this idear! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 12, 2009 Author Share Posted August 12, 2009 Some good ones here: http://www.cadtutor.net/forum/showthread.php?t=33388 Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 12, 2009 Author Share Posted August 12, 2009 Even Better! [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:ExOn [b][color=RED]([/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] *prank[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] *prank [b][color=RED]([/color][/b][b][color=BLUE]vlr-command-reactor[/color][/b] [b][color=BLUE]nil[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]list[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [color=Blue][b]:vlr-commandWillStart[/b][/color] [b][color=DARKRED]'[/color][/b]prank[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=Blue]:vlr-commandEnded [/color][/b] [b][color=DARKRED]'[/color][/b]notAmused[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [color=Blue][b]:vlr-commandCancelled[/b][/color] [b][color=DARKRED]'[/color][/b]notAmused[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] prank [b][color=RED]([/color][/b]Reac Args[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=#ff00ff]"EXPLODE"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Args[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] Obj [b][color=RED]([/color][/b][b][color=BLUE]vla-get-block[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveLayout[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-put-visible[/color][/b] Obj [b][color=Blue]:vlax-false[/color][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] notAmused [b][color=RED]([/color][/b]Reac Args[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=#ff00ff]"EXPLODE"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Args[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] Obj [b][color=RED]([/color][/b][b][color=BLUE]vla-get-block[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveLayout[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-put-visible[/color][/b] Obj [b][color=Blue]:vlax-true[/color][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:ExOff [b][color=RED]([/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] *prank [b][color=RED]([/color][/b][b][color=BLUE]vlr-added-p[/color][/b] *prank[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlr-remove[/color][/b] *prank[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] *prank [b][color=BLUE]nil[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] Quote Link to comment Share on other sites More sharing options...
TimSpangler Posted August 12, 2009 Share Posted August 12, 2009 OK Lee. You need something to do in the form of a prank. Make a reactor to move objects away from the cursor so that they can be selected...So when they invoke explode they can get any objects. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 12, 2009 Author Share Posted August 12, 2009 Haha, nice idea Tim - But the reactor would need some form of GrRead loop to track the mouse movements - which, combined with a reactor, may cause trouble Quote Link to comment Share on other sites More sharing options...
lpseifert Posted August 12, 2009 Share Posted August 12, 2009 I defer to your genius Lee... can you incorporate this? (setq SpV (vlax-create-object "Sapi.SpVoice")) (vlax-invoke SpV "Speak" "Kaboom" 0) (vlax-release-object SpV) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 12, 2009 Author Share Posted August 12, 2009 I'm no genius Larry (defun c:ExOn () (vl-load-com) (if (not *prank) (setq *prank (vlr-command-reactor nil (list (cons :vlr-commandWillStart 'prank))))) (princ)) (defun prank (Reac Args) (if (eq "EXPLODE" (strcase (car Args))) (progn (setq SpV (vlax-create-object "Sapi.SpVoice")) (vlax-invoke SpV "Speak" "Kaboom" 0) (vlax-release-object SpV))) (princ)) (defun c:ExOff () (if (and *prank (vlr-added-p *prank)) (progn (vlr-remove *prank) (setq *prank nil))) (princ)) Quote Link to comment Share on other sites More sharing options...
lpseifert Posted August 12, 2009 Share Posted August 12, 2009 Ha! now it's truly pointless Not really... reminded me how reactors work- Thx Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 12, 2009 Author Share Posted August 12, 2009 No probs - Its a fun program Quote Link to comment Share on other sites More sharing options...
fuccaro Posted August 12, 2009 Share Posted August 12, 2009 OK Lee. You need something to do in the form of a prank. Make a reactor to move objects away from the cursor so that they can be selected...So when they invoke explode they can get any objects.And what if the user selects the objects *before* it starts the Explode command? Quote Link to comment Share on other sites More sharing options...
lpseifert Posted August 12, 2009 Share Posted August 12, 2009 Lee Since you once offered to explain your stuff... how about this? (defun c:ExOff () (if (and *exR (vlr-added-p *exR)) (progn (vlr-remove *exR) (setq *exR nil))) I've read Help about vlr-added-p, but how is *exR 'made' a VLR object representing the reactor? Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 12, 2009 Author Share Posted August 12, 2009 I use the variable *exR as a global variable (not localised in any function), and bound the reactor object to it, when the user invokes the top program (ExON). EDIT! OOPs! Forgot to change it from the last program! **program updated above... nice spot Larry! Quote Link to comment Share on other sites More sharing options...
lpseifert Posted August 12, 2009 Share Posted August 12, 2009 Oh, OK... Thx Quote Link to comment Share on other sites More sharing options...
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.