BLOACH85 Posted March 3, 2009 Posted March 3, 2009 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. Quote
CarlB Posted March 3, 2009 Posted March 3, 2009 If user hits "enter", dist will be 'nil. So after that line use: (if (not dist) (setq dist 0.83)) Quote
David Bethel Posted March 3, 2009 Posted March 3, 2009 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 Quote
BLOACH85 Posted March 3, 2009 Author Posted March 3, 2009 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 Quote
JohnM Posted March 3, 2009 Posted March 3, 2009 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. Quote
David Bethel Posted March 3, 2009 Posted March 3, 2009 You need to drop the 1 in (initget). It forces an input. -David Quote
BLOACH85 Posted March 3, 2009 Author Posted March 3, 2009 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? Quote
JohnM Posted March 3, 2009 Posted March 3, 2009 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) Quote
lpseifert Posted March 3, 2009 Posted March 3, 2009 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))) ) Quote
Lee Mac Posted March 4, 2009 Posted March 4, 2009 (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 Quote
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.