Results 1 to 8 of 8

Thread: cancel a command from lisp

  1. #1
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default cancel a command from lisp

    I am trying to cancel a command from lisp, I tried using cancel with no arguments but I get this error:

    Error: invalid AutoCAD command: nil

    any suggestions would be apreciated

  2. #2
    100 Club CADmium's Avatar
    Join Date
    2004-08
    Location
    Eberswalde, Germany, Europe
    Posts
    128
    Login to Give a bone
    0

    Default Re: cancel a command from lisp

    Code:
    (defun DT:SendKeys (keys / ws) 
      (setq ws (vlax-create-object "WScript.Shell")) 
      (vlax-invoke-method ws 'sendkeys keys) 
      (vlax-release-object ws) 
      (princ) 
    )
    
    (DT:SendKeys "{ESC}")

  3. #3
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: cancel a command from lisp

    I hate when I do that, this is being run from a reactor, so of course command wont work.

    Thomas, that partially works for what I need, it is better than what I had before, let me explain my final objective.

    we cannot figure out how to get fields that reference sheet set custom properites to update in our title block unless they are placed in attributes. we dont want the title block fields to be manually overridden, so we have decided to make the eattedit and ddedit commands not recognize the title block as a valid entitiy, but I cant get the command to cancel out when the title block is selected, currently with your program running, you have to hit enter once to compeletly cancel the command.

    thanks,

  4. #4
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,658
    Login to Give a bone
    0

    Default Re: cancel a command from lisp

    Quote Originally Posted by ccowgill
    I am trying to cancel a command from lisp, I tried using cancel with no arguments but I get this error:

    Error: invalid AutoCAD command: nil

    any suggestions would be apreciated
    Try: (command)
    Posting the section of code will get the most appropriate answer.

  5. #5
    I could stop if I wanted to
    Join Date
    2006-04
    Posts
    466
    Login to Give a bone
    0

    Default Re: cancel a command from lisp

    Use (EXIT)

  6. #6
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: cancel a command from lisp

    (command) wont work


    Code:
    ;; Check if SheetDescript_Reactor is loaded in the task otherwise load it ( Do NOT load a reactor more than once )
    (if (not tblk_Reactor)
      (setq tblk_Reactor
      (vlr-command-reactor
    	nil
    	'((:vlr-commandWillStart . My_tblk_Command))
      ) ;_ end of vlr-command-reactor
      ) ;_ end of setq
      ()
      ;; The reactor is already loaded
    ) ;_ end of if
    ;;; Function used as Callbacks when the event fires / reactor triggers
    (defun My_tblk_Command (In_ReactorName In_Command /)
    	 ;(PRIN1 (car In_Command )) ;; <-- Remove this line, it shows all incomming command
      ;; Check if incomming command is Insert, Pasteclip or Dropgeom
      (if
    	(or
    	  (= (car In_Command) "EATTEDIT")
    	  (= (car In_Command) "DDEDIT")
    	)	 ;END OR
    	 
    	 (if
    	   (wcmatch (strcase (cdr (assoc 2 (entget (ssname (ssget) 0)))))
      "TTLB-A"
    	   ) ;_ end of wcmatch
     (tblk)
     ()
    	 ) ;_ end of if
    	 ;; Run the already loaded function sdc
    		  ()
    	 ;; The last command was not EATTEDIT, DDEDIT
      )	 ;END IF
      (princ)
    )	 ;END DEFUN
    ;|;; How to remove the Reactor :
    (vlr-remove SheetDescript_Reactor )
    ;;; How to clear the place holder :
    (setq My_SheetDescript_Command nil )
    |;
    (defun tblk ()
      (defun *error* (msg)
    	(if (not (member msg
    	   '("console break"
    		 "Function cancelled"
    		 "quit / exit abort"
    		 ""
    		 )   ;end list
    	  )	;end member
     )	;end not
    	  (princ (strcat "\nError: " msg))
    	)	 ; endif
      )	 ;end defun
      (princ "Not allowed")
      (DT:SendKeys "{ESC}")
    ) ;_ end of defun
    
    (defun DT:SendKeys (keys / ws) 
      (setq ws (vlax-create-object "WScript.Shell")) 
      (vlax-invoke-method ws 'sendkeys keys) 
      (vlax-release-object ws) 
      (princ) 
    )

  7. #7
    Certifiable AUGI Addict ccowgill's Avatar
    Join Date
    2004-08
    Location
    Iron Station, NC
    Posts
    3,198
    Login to Give a bone
    0

    Default Re: cancel a command from lisp

    Quote Originally Posted by aaronic_abacus
    Use (EXIT)
    nope, doesnt work either

  8. #8
    Member
    Join Date
    2016-08
    Posts
    2
    Login to Give a bone
    0

    Default Re: cancel a command from lisp

    My code is much simpler, but (command) was what ended up working for me.

    I have a lisp that uses the -Layer command, which is a command that repeats itself and only allows you to exit upon hitting ESC, ENTER, or SPACE. Within my lisp, I wasn't sure how to get out of the -Layer command and move on to doing other things.

    Original Code:
    (defun c:layercleanup()
    (command "-layer" "f" "*sur-topo*") ; after this point, I wanted to be done with the -layer command.
    (command "...) ; at this point, nothing would work because I never exited the -layer command.


    Updated Code:
    (defun c:layercleanup()
    (command "-layer" "f" "*sur-topo*" (command)) ; by entering (command), the ESC key was simulated and the -layer function was exited out of.
    (command "...) ; other commands now work correctly
    Last edited by jeddordal; 2017-02-14 at 09:12 PM.

Similar Threads

  1. ESC - Cancel a Command
    By inventor.wishlist1738 in forum Inventor Wish List
    Replies: 1
    Last Post: 2014-11-13, 08:01 PM
  2. Cancel command with Visual Lisp reactor
    By vasco_rou in forum AutoLISP
    Replies: 1
    Last Post: 2011-11-24, 01:20 PM
  3. cancel or escape command in a script or menu command?!
    By jcooke96119 in forum AutoCAD Customization
    Replies: 7
    Last Post: 2007-10-31, 01:28 PM
  4. Cancel a Command
    By Juergen Becker in forum Dot Net API
    Replies: 0
    Last Post: 2007-09-05, 09:05 AM
  5. Be able to use ESC Key To Cancel any Command
    By inventor.wishlist1738 in forum Inventor Wish List
    Replies: 0
    Last Post: 2007-07-16, 04:02 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
  •