Jump to content

Recommended Posts

Posted

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 ")?

Posted

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

 

  • Like 1
  • Thanks 1
Posted

I'll try to sort through it as soon as I can.

 

Thanks!

Posted

It appears to do as I need, thanks a lot. Now to get time to get back to making the program.

Posted

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

 

  • Thanks 1
Posted

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.

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