Lisp Learning

Lisp Learning

GeryKnee
Advocate Advocate
692 Views
7 Replies
Message 1 of 8

Lisp Learning

GeryKnee
Advocate
Advocate

trying the following 


(defun c:ZoomW( / )
(command "_.zoom" "w" " " " ")
)

 

i get 

Command: zoomw
zoom
Specify corner of window, enter a scale factor (nX or nXP), or
[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: w
Specify first corner:
Invalid window specification.
; error: Function cancelled
Specify first corner: Specify opposite corner:

 

All that works

But why is answering "Invalid window specification" before asking "Specify first corner"," Specify opposite corner"

I believe something is missing, allthow work is done

Respects

Gery

 

 

0 Likes
Accepted solutions (2)
693 Views
7 Replies
Replies (7)
Message 2 of 8

vporrash141089
Advocate
Advocate
Accepted solution
Maybe try this?

(command "_.zoom" "w" " ") I think you may have some extra enters
Message 3 of 8

GeryKnee
Advocate
Advocate
Thank you very much
0 Likes
Message 4 of 8

vporrash141089
Advocate
Advocate
Sorry my bad I'm also a beginner lol

Try this?

(defun c:ZoomW (/)

(command "_.zoom" "w")

(princ)

)
0 Likes
Message 5 of 8

ВeekeeCZ
Consultant
Consultant
Accepted solution

You need to have 2 user inputs.

(defun c:zoomw () (command "_.zoom" "_w" pause pause) (princ))

 

Version (defun c:zoomw () (command "_.zoom" "_w") (princ)) also works, but it's kinda dirty. The routine will start command, select w option, then ends with the command kept open. 

Message 6 of 8

ВeekeeCZ
Consultant
Consultant

@GeryKnee wrote:

trying the following 


(defun c:ZoomW( / )
(command "_.zoom" "w" " " " ")
)

...


 

" " means a SPACE. In LISP, space does not work as ENTER. Use "" if you need the ENTER functionality. For example

(command "line" "1,1" "5,5" "")

 

if you need user interaction, use PAUSE. One PAUSE, one user interaction. For a line, you need to have at least 2 points. Therefore (command "line" PAUSE PAUSE "")

 

If you need many user interactions, and you don't know how many, you need to fill the command function for the entire time the command is active. The CMDACTIVE sysvar will help you, HERE 

 

(command "_.line")
(while (> (getvar 'cmdactive) 0)
  (command PAUSE))

  

0 Likes
Message 7 of 8

Kent1Cooper
Consultant
Consultant

Not to throw dirt on the discussion, but you really don't need to make a command like that.  The Window option is the default [note the first prompt after starting the command] -- you do not need to call for it overtly.

Kent Cooper, AIA
Message 8 of 8

Sea-Haven
Mentor
Mentor

Yeah by the time you type "ZoomW" you could do "zoom w" microseconds difference, or "Z" only, like Kent window is default next choice. Check Acad.PGP for the command shortcuts.

0 Likes