Jump to content

Recommended Posts

Posted

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
)

 

Posted

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
)

 

Posted

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 "")
)

 

Posted
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

Posted
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

Posted

Should 

 

(command "_stretch" "cp" "")

 

be just

 

(command "_stretch" "cp" pause pause pause)

 

Posted

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)
...

 

Posted
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.

Posted
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

Posted

@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?

Posted
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
    
  )

 

Posted (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 by samifox

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...