SLW210 Posted May 8, 2023 Posted May 8, 2023 Is there a way to always have " (inches symbol) added to response and if added when typed in display only the default (i.e. only 1 ")? Quote
rlx Posted May 8, 2023 Posted May 8, 2023 like this? (haven't tested it because temp. out of acces to AutoCad so just pasted something together in notepad) ; independent simple dialog for getstring so no switching needed from dialog to command line (_ask "How are you?") (defun _ask ( $m / f p d r s) (if (and (setq f (vl-filename-mktemp ".dcl"))(setq p (open f "w"))) (progn (write-line (strcat "ask :dialog {label =\"" $m "\";:edit_box {key=\"eb\";}spacer;ok_cancel;}") p)(close p)(gc) (setq d (load_dialog f))(new_dialog "ask" d) (mapcar '(lambda(x y)(action_tile x y)) '("eb" "accept" "cancel") '("(chk_val $value)""(done_dialog 1)""(done_dialog 0)"))(setq r (start_dialog))(unload_dialog d)(vl-file-delete f))) (if (and (= r 1) (= 'STR (type s)) (/= s "")) s nil) ) (defun chk_val (v) (if (and (not (null v))(eq (type v) 'STR)(not (eq v ""))) ;;; if part of larger dialog write back to edit box ;;; (set_tile "eb" (setq s (strcat (vl-string-trim "\"" v) "\""))) ;;; else just return value (setq s (strcat (vl-string-trim "\"" v) "\"")) ) ) (defun c:t1 ( / r ) (if (setq r (_ask "how many inches ?"))(alert (strcat "result = " r))) (princ) ) 1 1 Quote
SLW210 Posted May 9, 2023 Author Posted May 9, 2023 I'll try to sort through it as soon as I can. Thanks! Quote
SLW210 Posted May 9, 2023 Author Posted May 9, 2023 It appears to do as I need, thanks a lot. Now to get time to get back to making the program. Quote
BIGAL Posted May 9, 2023 Posted May 9, 2023 This may be helpful, it converts Feet inches fractions "12 3 3/8" into decimal inches. eg 12 0 3/8, 1 3 1/2, 1, 1 3, 0 0 1/2. Space is the delimiter. Use in your dcl when inputting a value. (defun getfrac (lst / ) (setq len (+ (* 12.0 (atof (car lst)))(atof (cadr lst)))) (setq frac (caddr lst)) (setq pos (vl-string-search "/" frac)) (setq dec (atof (substr frac 1 pos))) (setq rem (atof (substr frac (+ pos 2)))) (setq len (+ len (/ dec rem))) (princ) ) ; thanks to Lee-mac for this defun ; 32 is space (defun csv->lst ( str / pos ) (if (setq pos (vl-string-position 32 str)) (cons (substr str 1 pos) (csv->lst (substr str (+ pos 2)))) (list str) ) ) (setq strlst (CSV->LST val)) (cond ((= (length strlst) 1)(setq ht (* (atof (car strlst)) 12.0))) ((= (length strlst) 2)(setq ht (+ (* (atof (car strlst)) 12.0) (atof (cadr strlst))))) ((= (length strlst) 3)(progn (getfrac strlst)(setq ht len))) ) 1 Quote
SLW210 Posted May 10, 2023 Author Posted May 10, 2023 Currently, the information will be input in inches and fractions, I just need to insure the .dwg shows the inch symbol, whether used in the edit box or not. I most likely will need the feet-inches > decimal inches convertor at some point, thanks! I'll look it over. 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.