See the top rated post in this thread. Click here

Results 1 to 7 of 7

Thread: Reactor help - run LISP routine if a Block is double-clicked

  1. #1
    I could stop if I wanted to Ogre's Avatar
    Join Date
    2005-06
    Location
    In the end, Cauliflower is just albino Broccoli
    Posts
    288
    Login to Give a bone
    0

    Default Reactor help - run LISP routine if a Block is double-clicked

    I need a LISP routine that will run another LISP routine if a block by the name of "CabinetSchedule" is double clicked...Is this even possible??? It seems possible, but I have no experience with reactors...Thanks in advance for the help...

  2. #2
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    1

    Default Re: Reactor help - run LISP routine if a Block is double-clicked

    You can start to play with this. . .
    Code:
    ;;---  The Reactor
    (vl-load-com)
    (setq Check_Mouse_DoubbleClick_Reactor (vlr-mouse-reactor nil '((:vlr-beginDoubleClick . Check_Mouse_DoubbleClick_Function ))) )
    ;;--- The function that the reactor trigger
    (defun Check_Mouse_DoubbleClick_Function ( ObjReactor_In 3Dpoint_In / 3Dpoint )
      (setq 3Dpoint (car 3Dpoint_In ) )
      (if (= (cdr (assoc 2 (entget (caar (reverse (nentselp 3Dpoint )))))) "CabinetSchedule" )
        (MyLisp)
        ( )
      )
      (princ)
    )
    ;;--- The lisp that the function call
    (defun MyLisp ( / )
      (alert "MyLisp is running" )
    )
    ;;--- Cleaning
    (vlr-remove Check_Mouse_DoubbleClick_Reactor ) ; Remove the reactor
    (setq Check_Mouse_DoubbleClick_Reactor nil )   ; Clear / assign nil to the reactor
    (setq Check_Mouse_DoubbleClick_Function nil )  ; Clear / assign nil to the function
    : ) Happy Computing !

    kennet

    BTW
    it will interfere with AutoCADs default reactor "Referense Edit"
    Last edited by kennet.sjoberg; 2007-01-17 at 11:29 PM. Reason: BTW

  3. #3
    I could stop if I wanted to Ogre's Avatar
    Join Date
    2005-06
    Location
    In the end, Cauliflower is just albino Broccoli
    Posts
    288
    Login to Give a bone
    0

    Default Re: Reactor help - run LISP routine if a Block is double-clicked

    Thanks for the code...It works great except a few things...

    For some reason it runs "MyLisp" twice...Also, is there any way to disable it going to the blockeditor or the ref editor??? Basically I only want one thing to run if this block is picked...

    Thanks again for the help...

  4. #4
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Reactor help - run LISP routine if a Block is double-clicked

    Quote Originally Posted by Ogre
    Thanks for the code...It works great except a few things...

    For some reason it runs "MyLisp" twice...Also, is there any way to disable it going to the blockeditor or the ref editor??? Basically I only want one thing to run if this block is picked...

    Thanks again for the help...
    It runs "MyLisp" as many times that you load the reactor . . . clean up and try again.

    to disable the blockeditor you can set pickfirst to 0, and then reset pickfirst.

    : ) Happy Computing !

    kennet

  5. #5
    I could stop if I wanted to Ogre's Avatar
    Join Date
    2005-06
    Location
    In the end, Cauliflower is just albino Broccoli
    Posts
    288
    Login to Give a bone
    0

    Default Re: Reactor help - run LISP routine if a Block is double-clicked

    Quote Originally Posted by kennet.sjoberg
    It runs "MyLisp" as many times that you load the reactor . . . clean up and try again.

    to disable the blockeditor you can set pickfirst to 0, and then reset pickfirst.

    : ) Happy Computing !

    kennet
    It does not seem to work...I added a few thing that I thought may have helped...

    Code:
    (vl-load-com)
    (setq Check_Mouse_DoubbleClick_Reactor (vlr-mouse-reactor nil '((:vlr-beginDoubleClick . Check_Mouse_DoubbleClick_Function )
    																															 );'
    																			 );vlr-mouse-reactor
    );setq
    ;(setq Check_LISP_Ended_Reactor (vlr-lisp-reactor nil '((:vlr-lispended . Reset_Pickfirst))))
    ;;--- The function that the reactor trigger
    (defun Check_Mouse_DoubbleClick_Function ( ObjReactor_In 3Dpoint_In / 3Dpoint )
      (setq 3Dpoint (car 3Dpoint_In ) )
    	(if (caar (reverse (nentselp 3Dpoint )))
    	  (cond
    			( (= (cdr (assoc 2 (entget (caar (reverse (nentselp 3Dpoint )))))) "CABINETSCHEDULE" )
    				(MyLisp)
    			);case
    	  )
    		(Reset_Pickfirst)
    	);if
      (princ)
    )
    
    (defun Reset_Pickfirst ( / )
    	(setvar "pickfirst" 1)
    );defun
    
    (defun Set_Pickfirst ( ObjReactor_In 3Dpoint_In / )
    	(setq 3Dpoint (car 3Dpoint_In ) )
    	(if (= (cdr (assoc 0 (entget (car (nentselp 3Dpoint))))) "LINE")
    	  (if (= (cdr (assoc 2 (entget (caar (reverse (nentselp 3Dpoint )))))) "CABINETSCHEDULE" )
    			(setvar "pickfirst" 0)
    	  );if
    		(setvar "pickfirst" 1)
    	);if
      (princ)
    );defun
    
    ;;--- The lisp that the function call
    (defun MyLisp ( / )
    		(progn
    			(alert "MyLisp is running" )
    		);progn
    ;;;	);if
    Thanks again for the help...

  6. #6
    AUGI Addict kennet.sjoberg's Avatar
    Join Date
    2002-05
    Posts
    1,707
    Login to Give a bone
    0

    Default Re: Reactor help - run LISP routine if a Block is double-clicked

    Hmm.. it seems to be a "who comes first problem", the hen or the egg ?
    If you set pickfirst to 0 before you run the reactor it works. . . but then you miss the pickfirst advantage.
    I do not know the way out. . . sorry.

    : ) Happy Computing !

    kennet

  7. #7
    I could stop if I wanted to Ogre's Avatar
    Join Date
    2005-06
    Location
    In the end, Cauliflower is just albino Broccoli
    Posts
    288
    Login to Give a bone
    0

    Default Re: Reactor help - run LISP routine if a Block is double-clicked

    Quote Originally Posted by kennet.sjoberg
    Hmm.. it seems to be a "who comes first problem", the hen or the egg ?
    If you set pickfirst to 0 before you run the reactor it works. . . but then you miss the pickfirst advantage.
    I do not know the way out. . . sorry.

    : ) Happy Computing !

    kennet
    No problem...Thanks again for the help...

Similar Threads

  1. Set file name from block attribute with lisp routine
    By email.dnewton396831 in forum AutoLISP
    Replies: 0
    Last Post: 2013-07-03, 08:51 PM
  2. Replies: 1
    Last Post: 2012-10-15, 09:56 PM
  3. Get AutoCAD Map to open a file when double-clicked in explorer
    By kskov in forum AutoCAD Map 3D - General
    Replies: 4
    Last Post: 2007-07-31, 02:10 PM
  4. Replies: 0
    Last Post: 2006-12-19, 03:38 PM
  5. Incorporating a dynamic block into a lisp routine
    By charlie.bauer341340 in forum AutoLISP
    Replies: 7
    Last Post: 2006-01-11, 01:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •