Jump to content

Combining 2 commands and creating a pause to ask for a result from the first command


MikeP

Recommended Posts

Im combining "-view" "w" with "ucs" "world"

 

Here is my lisp. Very simple

 

(defun c:sv (/ -view ucs)
(command "-view" "w")
(princ)
)

 

Yet. when I finish this on certain objects it rotates the UCS for some reason. So just as a fix. Im adding "(command "ucs" world")" to the code. Yet I need to finish the first "-view" command first. because it need to know a view name and window first.

Link to comment
Share on other sites

You shouldn't need to localise "-view" and "ucs" as these are not variables, just strings. :thumbsup:

 

 

Dunno, Dont work with out it.

 

here is what I have. Is there an easier way?

 

(defun c:sv (/ -view ucs)
(command "-view" "w")
(while (eq (logand (getvar 'CMDACTIVE)) 1)
          (command PAUSE))
(command "ucs" "world")
(princ)
)

Link to comment
Share on other sites

Dunno, Dont work with out it.

 

I don't see why it shouldn't.

 

(defun c:sv ( )
  (command "-view" "w")
  (while (eq (logand (getvar 'CMDACTIVE)) 1)
    (command pause))
  (command "ucs" "world")
 (princ))

Link to comment
Share on other sites

(defun c:sv (/ vname)
  (setq vname (getstring "\nSave view as: "))
  (command "view" "W" vname pause pause)
  (command "ucs" "")
 (princ))
 

Link to comment
Share on other sites

or this to make it even shorter.:D

(defun c:sv ( / )
  (command "view" "W" (getstring "\nEnter view name to save:") pause pause)
  (command "ucs" "w")
 (princ))

Link to comment
Share on other sites

I would use:

 

(defun c:sv ( / )
  (command "_.-view" "_W" (getstring [color=Red][b]t[/b][/color] "\nSave view as:") pause pause)
  (command "_.ucs" "_W")
 (princ))

Link to comment
Share on other sites

Unless it has changed over the years, a ( getxxx ) call cannot be used inside of a ( command ). -David

Link to comment
Share on other sites

Unless it has changed over the years, a ( getxxx ) call cannot be used inside of a ( command ). -David

Then it must have changed because it works fine for me. Plus I've seen it done many times before.:wink:

Link to comment
Share on other sites

That is a change. From the R14 Help files:

 

The getxxx user-input functions (getangle, getstring, getint, getpoint, and so on) cannot be used inside the command function. An attempt to do so results in the following message and terminates the function in progress.

 

error: AutoCAD rejected function

 

If user input is needed, issue the getxxx functions beforehand, or place them between successive command function calls.

 

I don't think I would recommend it just because of error trapping and parameter checking. -David

Link to comment
Share on other sites

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