(DEFUN C:dd ( / ent ce txt_old TXT )

(if *error* ; Set our new error handler
(setq nt_oe *error* *error* nt_er)
(setq *error* nt_er)
)

(setq ce (getvar "cmdecho"))
(setvar "cmdecho" 0)
(if (= "DIM" (setq cn (getvar "cmdnames"))) (command "" "EXIT"))
(command "undo" "g")
(while (not (SETQ ENT (CAR (ENTSEL "\nSelect Text or Dimmension: "))))
(prompt "\nInvalid selection. Try again..."))
(setq ent (entget ent);)
txt_old (cdr (assoc 1 ent)) )
(if (= txt_old "") (setq txt_old ""))

(nt_dlg);dialog

(if txt
(progn
(entmod (SUBST (CONS 1 TXT) (ASSOC 1 ENT) ENT))
)
(exit)
);if
(command "undo" "end")
(if cn (command cn))
(setvar "cmdecho" ce)
(redraw)
(princ) )

(defun nt_dlg ( / num )

(setq num (load_dialog "ddntext"))
(if (not (new_dialog "ddntext" num))
(exit))
(mode_tile "tname" 2)
(set_tile "tname" txt_old)
(action_tile "dfn" "(dsbl $value) (pick_txt $value)")
(action_tile "std" "(pick_txt $value) (dsbl $value)")
(action_tile "accept" "(do_txt) (done_dialog)")

(start_dialog)
(unload_dialog num)
);defun

(defun do_txt ( )
(setq txt (get_tile "tname"))
);defun

(defun dsbl (chto)
(setq bt_lst '( "df" "mn" "mx" "da" "rd" "un" "ds" "dg" "pm" "pr" ))
(foreach item bt_lst
(if (/= item chto)
(set_tile item "0")
)
)
)

(defun pick_txt (which)
(cond
((= which "df") (setq txt_dfn "") )
((= which "mn") (setq txt_dfn "MIN"))
((= which "mx") (setq txt_dfn "MAX"))
((= which "da") (setq txt_dfn "DIA"))
((= which "rd") (setq txt_dfn "RAD"))
((= which "un") (setq txt_dfn "%%u"))
((= which "ds") (setq txt_dfn "%%c"))
((= which "dg") (setq txt_dfn "%%d"))
((= which "pm") (setq txt_dfn "%%p"))
((= which "pr") (setq txt_dfn "%%%"))
)
(set_tile "tname" txt_dfn)
)

(defun nt_er (msg)
(if (/= msg "Function cancelled")
(if (= msg "quit / exit abort")
(princ)
(princ (strcat "Error: " msg))

)
;(princ)
)
(if nt_oe (setq *error* nt_oe nt_oe nil)
(setq *error* nil))
(command ".undo" "end")
(command "u")
(if ce (setvar "cmdecho" ce))
(setq ce nil)

(princ)
);defun

(princ)


****** ddntext.dcl ********
ddntext : dialog {
label = "Edit Dimension or Text";
: edit_box {
label = "Enter new text:";
key = "tname";
allow_accept = true;
width = 80;
}
:boxed_row {

:boxed_radio_column {
key = "std";
label = "Standard Symbols";
:radio_button {
key = "un";
label = "Underline";
}
:radio_button {
key = "ds";
label = "Diameter symbol";
}

}

spacer;
:boxed_radio_column {
label = "Standard Simbols";
key = "dfn";
:radio_button {
key = "dg";
label = "Degree symbol";
}
:radio_button {
key = "pr";
label = "Percentage symbol %";
}

}
}
ok_cancel;
}

Advertisements