Jump to content

Question about Default values.


BLOACH85

Recommended Posts

This is what i have but when the routine runs everything works except my default value for my distance why is this?

(setq dist (getreal "\nWhat is the Offset Distance? [.083/0.95] <0.83> :"))

I just wat 0.83 as defualt so it will eliminate keystrokes until i have to use a different number.

Link to comment
Share on other sites

You may also want to look into calling (initget) prior to calling (getdist). It can force a positive non zero value ( which you would need for an offset ). -David

Link to comment
Share on other sites

initget is allready there and set to 1 2 4 64 and i tried the (if (not dist) (setq dist 0.83))

and still returning requires a numeric value error

Link to comment
Share on other sites

sorry i posted to quick your initget should not have 1 because it

Prevents the user from responding to the request by entering only ENTER. therefor it loops until it gets a responce or escape is pushed.

Link to comment
Share on other sites

See thinking always gets myself introuble. thanks guys! But since your here and know more than me, How do you get it to hold its previous value for the next time you envoke the command?

Link to comment
Share on other sites

Retain values can be achieved one of two ways

  • Make the variable a global variable so it stays active while the AutoCAD session is still open but will loose its value when AutoCAD is closed.

Write the value to a file and have the program access it (this is preferred)

Link to comment
Share on other sites

See thinking always gets myself introuble. thanks guys! But since your here and know more than me, How do you get it to hold its previous value for the next time you envoke the command?

here's one way

(defun test (/ dist)
(if (null *dist*)
(setq *dist* 0.83)
)
(setq dist (getreal (strcat "\n What is the offset distance?: <" (rtos *dist* 2 2) ">: "))
)
(if (not dist)
(setq dist *dist*)
(setq *dist* dist)
 )
 (alert (strcat "\nThe value of *dist* is " (rtos *dist* 2 2)
        "\nThe value or dist is " (rtos dist 2 2)))
 )

Link to comment
Share on other sites

(defun test  (/ dist)
 (or *dist* (setq *dist* 0.83))
 (setq dist (getreal (strcat "\n What is the offset distance?: <" (rtos *dist* 2 2) ">: ")))
 (or (and (not dist) (setq dist *dist*)) (setq *dist* dist))
 (alert (strcat "\nThe value of *dist* is " (rtos *dist* 2 2)
	 "\nThe value or dist is "   (rtos dist 2 2))))


 

A minor simplification :P

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