Hi Friends, here I will explain about How to change the text
in DCL (Dialog Control Language) by clicking on radio buttons using AutoLISP.
- I explain this with small example.
- I have two radio buttons FPS and MKS. If I select FPS then the text have to show “HI you have selected FPS”. If I select MKS then the text have to show “HI you have selected MKS”.
- First Open the AutoLISP Editor write the below code or copy and paste the code and save it as TXT.dcl
chtxt:dialog{
label = "Welcome To
Autolisp-Roja";
:column {
:text{
key="txt";
}
:radio_column {
label = "Units";
key = "units";
:radio_button {
label = "FPS
";
key =
"fps";
}
:radio_button
{
label =
"MKS";
key =
"mks";
}
}
}
ok_cancel;
}
|
- Then we have to call this DCL file in LSP file.
- Write the below code or copy and paste the code in AutoLISP Editor and save it as TXT.lsp
(defun c:ch_txt()
(setq dcl_id
(load_dialog "txt.dcl"))
(if (not
(new_dialog "chtxt" dcl_id))(exit))
(action_tile
"fps" "(setq un_chk \"fps\")(txt)")
(action_tile
"mks" "(setq un_chk \"mks\")(txt)")
(action_tile
"accept" "")
(action_tile
"cancel" "(done_dialog)(exit)")
(start_dialog)
(unload_dialog
dcl_id)
)
;;;;change text
(defun txt()
(if (= un_chk
"fps")
(set_tile
"txt" (strcat "Hi You have selected FPS"))
(set_tile
"txt" (strcat "Hi You have selected MKS"))
)
)
|
- Now load and run your program,Open AutoCAD and type the below commands.
Command: (load "txt")
C:ch_txt
Command: ch_txt
|
- When we enter ch_txt then one dialog box will open like below and ask FPS or MKS.
- If I select FPS then the text have to show “HI you have selected FPS”
- The text will be changed according to the radio buttons because I write one function txt ,in this I put the condition for that.
No comments:
Post a Comment