samifox Posted April 1 Share Posted April 1 hi im trying to assemble a function that : - turn hatches off - Execute "stretch" "cp" "" "" "" - turn hatches on i want the lisp to pause in the command "Stretch" "cp" , press enter 3 times , and continue lisp evaluation any idea whats wrong? (defun c:hhh () (setq original_fillmode (getvar "fillmode")) ; Store the original FILLMODE value (if (= original_fillmode 1) ; Check if FILLMODE is currently set to 1 (progn ; If it is... (setvar "fillmode" 0) ; Set FILLMODE to 0 (off) (command "regen") ; Refresh the drawing ) ;; If FILLMODE is not 1, handle that case here (setvar "fillmode" 1) ; Set FILLMODE to 1 (on) or whatever default you want (command "regen") ; Refresh the drawing ) (command "_stretch" "cp" "") ; Initiates the Stretch command with "cp" option and sends an empty string for the remaining prompts (setvar "fillmode" 0) ; Set FILLMODE to 0 (off) (command "regen") ; Refresh the drawing ) Quote Link to comment Share on other sites More sharing options...
Tsuky Posted April 1 Share Posted April 1 And with CMDACTIVE is can be good? (defun c:hhh ( / original_fillmode ) (setq original_fillmode (getvar "fillmode")) ; Store the original FILLMODE value (if (= original_fillmode 1) ; Check if FILLMODE is currently set to 1 (progn ; If it is... (setvar "fillmode" 0) ; Set FILLMODE to 0 (off) (command "_.regen") ; Refresh the drawing ) ;; If FILLMODE is not 1, handle that case here (progn (setvar "fillmode" 1) ; Set FILLMODE to 1 (on) or whatever default you want (command "_.regen") ; Refresh the drawing ) ) (command "_.stretch" "_cp") ; Initiates the Stretch command with "cp" option and sends an empty string for the remaining prompts (while (not (zerop (getvar "cmdactive"))) (command pause) ) (setvar "fillmode" 0) ; Set FILLMODE to 0 (off) (command "_.regen") ; Refresh the drawing ) Quote Link to comment Share on other sites More sharing options...
marko_ribar Posted April 1 Share Posted April 1 This is not pause, but rather pressing ENTER till command completes... Here is snippet how to do it : (command "_.stretch" "cp") (while (< 0 (getvar (quote cmdactive))) (command "") ) Quote Link to comment Share on other sites More sharing options...
samifox Posted April 1 Author Share Posted April 1 20 minutes ago, marko_ribar said: This is not pause, but rather pressing ENTER till command completes... Here is snippet how to do it : (command "_.stretch" "cp") (while (< 0 (getvar (quote cmdactive))) (command "") ) thats smart , but in (command "_.stretch" "cp") case it didnt work Quote Link to comment Share on other sites More sharing options...
samifox Posted April 1 Author Share Posted April 1 30 minutes ago, Tsuky said: And with CMDACTIVE is can be good? (defun c:hhh ( / original_fillmode ) (setq original_fillmode (getvar "fillmode")) ; Store the original FILLMODE value (if (= original_fillmode 1) ; Check if FILLMODE is currently set to 1 (progn ; If it is... (setvar "fillmode" 0) ; Set FILLMODE to 0 (off) (command "_.regen") ; Refresh the drawing ) ;; If FILLMODE is not 1, handle that case here (progn (setvar "fillmode" 1) ; Set FILLMODE to 1 (on) or whatever default you want (command "_.regen") ; Refresh the drawing ) ) (command "_.stretch" "_cp") ; Initiates the Stretch command with "cp" option and sends an empty string for the remaining prompts (while (not (zerop (getvar "cmdactive"))) (command pause) ) (setvar "fillmode" 0) ; Set FILLMODE to 0 (off) (command "_.regen") ; Refresh the drawing ) wont work. after "stretch" i want the lisp to enter 3 times, and than continue lisp its not what happening Quote Link to comment Share on other sites More sharing options...
Steven P Posted April 1 Share Posted April 1 Should (command "_stretch" "cp" "") be just (command "_stretch" "cp" pause pause pause) Quote Link to comment Share on other sites More sharing options...
Steven P Posted April 1 Share Posted April 1 Note on setvar, Better to save the existing value of the variable before changing it, then change it back to as it was at the end ... (setq Old_Var (getvar 'fillmode)) (setvar 'fillmode 1) ... do something (setvar 'fillmode Old_Var) ... Quote Link to comment Share on other sites More sharing options...
pkenewell Posted April 1 Share Posted April 1 2 hours ago, samifox said: i want the lisp to pause in the command "Stretch" "cp" , press enter 3 times , and continue lisp evaluation @samifox You need to explain more what you are trying to accomplish with this routine. It would be most helpful to include and example drawing with before and after. It does not make sense to do a STRETCH command with the "CP" option, then just press enter 3 times. All that will do is exit the command and re-enter it. After the "CP" option, you have to supply points of a polygon for the selection. Quote Link to comment Share on other sites More sharing options...
samifox Posted April 1 Author Share Posted April 1 2 hours ago, pkenewell said: @samifox You need to explain more what you are trying to accomplish with this routine. It would be most helpful to include and example drawing with before and after. It does not make sense to do a STRETCH command with the "CP" option, then just press enter 3 times. All that will do is exit the command and re-enter it. After the "CP" option, you have to supply points of a polygon for the selection. https://www.loom.com/share/a4f2854217d145c9bd3bb24e4e1c604f Quote Link to comment Share on other sites More sharing options...
pkenewell Posted April 1 Share Posted April 1 @samifox Now that I can see what your trying to do, Tsuky's approach here works correctly. I tested and it works just like your example - so what else do you want? Quote Link to comment Share on other sites More sharing options...
samifox Posted April 1 Author Share Posted April 1 6 hours ago, Tsuky said: And with CMDACTIVE is can be good? (defun c:hhh ( / original_fillmode ) (setq original_fillmode (getvar "fillmode")) ; Store the original FILLMODE value (if (= original_fillmode 1) ; Check if FILLMODE is currently set to 1 (progn ; If it is... (setvar "fillmode" 0) ; Set FILLMODE to 0 (off) (command "_.regen") ; Refresh the drawing ) ;; If FILLMODE is not 1, handle that case here (progn (setvar "fillmode" 1) ; Set FILLMODE to 1 (on) or whatever default you want (command "_.regen") ; Refresh the drawing ) ) (command "_.stretch" "_cp") ; Initiates the Stretch command with "cp" option and sends an empty string for the remaining prompts (while (not (zerop (getvar "cmdactive"))) (command pause) ) (setvar "fillmode" 0) ; Set FILLMODE to 0 (off) (command "_.regen") ; Refresh the drawing ) thanks man. this is the final version (defun c:strhat (/ original_fillmode) (setq original_fillmode (getvar "fillmode")) ; Store the original FILLMODE value (if (= original_fillmode 1) ; Check if FILLMODE is currently set to 1 (progn ; If it is... (hpe) (setvar "fillmode" 0) ; Set FILLMODE to 0 (off) (command "_.regen") ; Refresh the drawing ) ;; If FILLMODE is not 1, handle that case here (progn (setvar "fillmode" 1) ; Set FILLMODE to 1 (on) or whatever default you want (command "_.regen") ; Refresh the drawing (hpe) (setvar "fillmode" 0) ; Set FILLMODE to 1 (on) or whatever default you want (command "_.regen") ; Refresh the drawing ) ) (command "_.stretch" "_cp") ; Initiates the Stretch command with "cp" option and sends an empty string for the remaining prompts (while (not (zerop (getvar "cmdactive"))) (command pause) ) (setvar "fillmode" 1) ; Set FILLMODE to 0 (off) (command "_.regen") ; Refresh the drawing ) Quote Link to comment Share on other sites More sharing options...
samifox Posted April 1 Author Share Posted April 1 (edited) (command "_.stretch" "_cp") ; Initiates the Stretch command with "cp" option and sends an empty string for the remaining prompts ( while (not (zerop (getvar "cmdactive"))) (command pause) ) wont send enters to the command Edited April 1 by samifox 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.