TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: daron on March 14, 2005, 12:58:04 PM
-
I just can't think of how to do this:
I want to ask a user for an input of a number and allow them to supply inches or feet and have lisp know the difference. I just can't think of how to do it. Anybody got any ideas. Seems like it shouldn't be too hard.
-
Use getstring and then distof.
-
Use the getdist function.
-
Thank you.
-
Hey Charles, try this --
(setvar "lunits" 2)
(getdist) [enter] 12' [enter]
*shladdap*, rake in the face. :(
Subtitle: Getdist's ability to accept keyed input is a function of the lunits sys var setting.
-
CAB, that is what I was looking for. I knew it was there, I just needed to try it. Of course, I'll have to take MP's above thought to test.
-
Hey Charles, try this --
(setvar "lunits" 2)
(getdist) [enter] 12' [enter]
*shladdap*, rake in the face. :(
Subtitle: Getdist's ability to accept keyed input is a function of the lunits sys var setting.
:?:
Why would you press [enter] before your 12'?
What happens with
(getstring) [enter] 12' [enter] :)
I was thinking getdist because it will allow many format options for user input.
-
Here's the solution to MP's problem:
(if (or (< (getvar 'lunits) 3) (> (getvar 'lunits) 4))
(setq lunitnum (getvar 'lunits))
(setvar 'lunits 4)
)
(setq height (getdist "\nHeight of Wall: "))
(setvar 'lunits lunitnum)
Note: Any value other than 3 or 4 will result in the inability to use the ft (') mark.
-
Oh, I see now. The fog is starting to lift.
Sorry Michael, as usual your reply went right over my pointy little head. :oops:
-
No worries Charles. You correctly pointed out the use of getdist; I just pointed out one mustn't make assumptions about its behavior. :)
And now for something completely different:
(defun distanceof ( x / result )
(vl-catch-all-apply
'(lambda ()
(vl-some
'(lambda (units) (setq result (distof x units)))
(list (getvar "lunits") 4 5 2 1)
)
)
)
result
)
:)
-
That's is a thing of beauty Michael.
-
Thank you Mark, meant to be (primarilly) demonstrative. :)