Anushka Posted October 23 Share Posted October 23 I have a question that has likely been answered before, but I couldn’t find it. I want to click a button, select an entity in the drawing, get the distance, and then return to the dialog box with the information written in the edit_box. What’s the best way to do this? Could someone provide an example? (defun c:OpenDCLDialog ( / dcl_id) (setq dcl_id (load_dialog "example_dialog.dcl")) (if (not (new_dialog "example_dialog" dcl_id)) (exit) ) (action_tile "select_btn" "(done_dialog 2)") (action_tile "ok_btn" "(done_dialog 1)") (setq dclflag (start_dialog)) (cond ( (eq dclflag 2) (:select) ) ((eq dclflag 2) (prompt "ok!") ) ) (unload_dialog dcl_id) ) (defun :select () (setq entity (car (entsel "\nSelect an entity: "))) (setq ponto (assoc 10 (entget entity))) (setq dist (getdist (cdr ponto) "Distance: ")) ;;vou fazer algo aqui ) ;;(c:OpenDCLDialog) example_dialog : dialog { label = "Entity Selection Example"; : row { : edit_box { key = "distance"; label = "Distance"; edit_width = 25; } } : row { : button { key = "select_btn"; label = "Select Entity"; } } : row { : button { key = "ok_btn"; label = "OK"; is_default = true; } : button { key = "cancel_btn"; label = "Cancel"; is_cancel = true; } } } Quote Link to comment Share on other sites More sharing options...
BIGAL Posted October 23 Share Posted October 23 (edited) You are correct you have to close the dcl and reopen it. the key is distance so (set_tile "distance" dist) the dist would be the object length as a string maybe need to check, when you start dcl the dist (if (= dist nil) (setq dist "0") (setq dist (rtos len 2 2)) ) ) (set_tile "distance" dist) (action_tile "select_btn" "(done_dialog 2)") Edited October 23 by BIGAL Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted October 24 Share Posted October 24 Hi Use a while loop to re-open the dialog if "Select" button is picked. Like this (defun c:OpenDCLDialog ( / dcl_id dclflag dst) (setq dclflag 2) (if (and (setq dcl_id (load_dialog "example_dialog.dcl")) (> dcl_id 0) ) (progn (while (> dclflag 1) (new_dialog "example_dialog" dcl_id) (if dst (set_tile "distance" dst)) (action_tile "distance" "(setq dst $value)") (action_tile "select_btn" "(done_dialog 2)") (action_tile "ok_btn" "(done_dialog 1)") (setq dclflag (start_dialog)) (if (and (= dclflag 2) (setq dst (:select)) ) (setq dst (rtos dst)) ) );while (unload_dialog dcl_id) (if (= dclflag 1) (distof dst) ) );progn ) ) (defun :select () (setq entity (car (entsel "\nSelect an entity: "))) (setq ponto (assoc 10 (entget entity))) (setq dist (getdist (cdr ponto) "Distance: ")) ;;vou fazer algo aqui ) 1 Quote Link to comment Share on other sites More sharing options...
Anushka Posted October 24 Author Share Posted October 24 @Stefan BMR Thank you, that's what I needed. Quote Link to comment Share on other sites More sharing options...
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.