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
|
|
|
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
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}")
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,
Try: (command)Originally Posted by ccowgill
Posting the section of code will get the most appropriate answer.
(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) )
nope, doesnt work eitherOriginally Posted by aaronic_abacus
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.