gS7 Posted February 23, 2017 Share Posted February 23, 2017 Hi Guys , I Need help again in DCL when I Click to Create button it not working and taking longtime Please help DCL pickpoint:dialog { label="Pickpoint"; :row { :popup_list { label="Create :"; key="crt"; edit_width=15; } :button { label="Pick Point"; key="pick"; width=5; height=1.5; } } :column { :edit_box { label="Easting"; key="e"; edit_width=15; } :edit_box { label="Northing"; key="n"; edit_width=15; } } :button { label="Create"; key="ok"; is_default=true; is_cancel=false; } } Autolisp (defun c:test() (setq e "") (setq n "") (setq crt "0") (setq flag 4) (setq lst (list "Circle" "Point")) (setq dcl (load_dialog "pickpoint.dcl")) (defun check(bb x y) (if (= bb "Circle") (command "circle" (list x y) 2.0) (command "point" (list x y)) ) ) (while (> flag 2) (if (not (new_dialog "pickpoint" dcl)) (exit) ) (set_tile "e" e) (set_tile "n" n) (set_tile "crt" crt) (start_list "crt") (mapcar 'add_list lst) (end_list) (action_tile "crt" "(setq ob $value)(setq crt (get_tile \"crt\"))") (action_tile "pick" "(done_dialog 4)") (action_tile "ok" "(check ob (atof e) (atof n)) (done_dialog 1)") (setq flag (start_dialog)) (if (= flag 4) (progn (setq pos (getpoint)) (setq e (rtos (car pos)) n (rtos (cadr pos)) ) ) ) ) (done_dialog dcl) (princ)) Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted February 23, 2017 Share Posted February 23, 2017 Check this once : (defun check(bb x y) (if [color="red"](= bb "0")[/color] (command "circle" (list x y) 2.0) (command "point" (list x y)) ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted February 23, 2017 Share Posted February 23, 2017 Check this once : (defun check(bb x y) (if [color="red"](= bb "0")[/color] (command "circle" (list x y) 2.0) (command "point" (list x y)) ) ) Command call does not work from action_tile so you must call that sub-function after unloading the dialog. Quote Link to comment Share on other sites More sharing options...
satishrajdev Posted February 23, 2017 Share Posted February 23, 2017 Thanks Tharwat, I never used any command function there so didnt have this idea Quote Link to comment Share on other sites More sharing options...
Grrr Posted February 23, 2017 Share Posted February 23, 2017 Heres my practice code, after learning from Lee Mac, about writing such DCLs: (defun C:test ( / *error* dcl des dch dcf e n ob p ) (defun *error* ( msg ) (and (< 0 dch) (unload_dialog dch)) (and (eq 'FILE (type des)) (close des)) (and (eq 'STR (type dcl)) (findfile dcl) (vl-file-delete dcl)) (and msg (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\nError: " msg)) ) (princ) ); defun *error* (cond ( (not (and (setq dcl (vl-filename-mktemp nil nil ".dcl")) (setq des (open dcl "w")) (princ (strcat "pickpoint : dialog" "{ label = \"Pickpoint\";" " : row" " { : popup_list { label = \"Create :\"; key = \"crt\"; edit_width = 15; }" " : button { label = \"Pick Point\"; key = \"pick\"; width = 5; height = 1.5; }" " }" " : column" " { : edit_box { label = \"Easting\"; key = \"e\"; edit_width = 15; }" " : edit_box { label = \"Northing\"; key = \"n\"; edit_width = 15; }" " }" " : button { label = \"Create\"; key = \"ok\"; is_default = true; is_cancel = false; }" "}" ); strcat des ); princ / write-line (not (setq des (close des))) (< 0 (setq dch (load_dialog dcl))) ); and ); not (princ "\nUnable to write or load the DCL file.") ) ( (progn (mapcar 'set '(e n ob) '("" "" "0")) (while (/= 1 dcf) (cond ( (not (new_dialog "pickpoint" dch)) (princ "\nUnable to display the dialog") (setq dcf 1) ) (T (set_tile "crt" ob) (mapcar 'set_tile '("e" "n") (list e n)) (start_list "crt") (mapcar 'add_list '("Circle" "Point")) (end_list) (mapcar '(lambda (x) (apply 'action_tile x)) '(("e" "(setq e $value)") ("n" "(setq n $value)") ("crt" "(setq ob $value)") ("pick" "(done_dialog 2)")) ) (action_tile "ok" (vl-prin1-to-string '(cond ( (= "" e) (alert "\nSpecify Easting value!") ) ( (= "" n) (alert "\nSpecify Northing value!") ) ( (not (numberp (read e))) (alert "\nInvalid Easting value!") ) ( (not (numberp (read n))) (alert "\nInvalid Northing value!") ) ( (done_dialog 1) ) ) ) ) (setq dcf (start_dialog)) ) ); cond (if (and (= 2 dcf) (setq p (getpoint "\nSpecify point: "))) (mapcar 'set '(e n) (mapcar 'rtos (list (car p) (cadr p)))) ); if ); while (if (setq p (list (read e) (read n) 0.)) (entmakex (cadr (assoc ob (list (list "0" (list (cons 0 "CIRCLE") (cons 10 p) (cons 40 2.0))) (list "1" (list (cons 0 "POINT") (cons 10 p))) ) ) ) ) ) (*error* nil) ); progn ) ); cond (princ) ); defun Quote Link to comment Share on other sites More sharing options...
gS7 Posted February 23, 2017 Author Share Posted February 23, 2017 wow. .! Grrr may be it takes many days to learn for me .. but pls guide me how to use those sub function like said by tharwat Sent from my SM-E700H using Tapatalk Quote Link to comment Share on other sites More sharing options...
gS7 Posted February 23, 2017 Author Share Posted February 23, 2017 I want learn from lower so Sent from my SM-E700H using Tapatalk Quote Link to comment Share on other sites More sharing options...
Grrr Posted February 23, 2017 Share Posted February 23, 2017 wow. .! Grrr may be it takes many days to learn for me .. but pls guide me how to use those sub function like said by tharwat Sent from my SM-E700H using Tapatalk To avoid command calls then you either have to use entmake/x (check this thread) or invoke the vla-add method (which requires activex). Quote Link to comment Share on other sites More sharing options...
BIGAL Posted February 24, 2017 Share Posted February 24, 2017 Like Tharwat the option "pick point" within a dcl has been raised here many times, you do need to close the dcl pick the point and pop the dcl open again. You can do within the dcl say "Pick" or enter X & Y in boxes next to the "pick" option, if you do "pick" then you can display the point xy values when you return to the dcl and continue on. Quote Link to comment Share on other sites More sharing options...
gS7 Posted February 24, 2017 Author Share Posted February 24, 2017 @bigal oh! that's why it takes so long and autocad closing itself I think revise my codes as per your instructions thank you Bigal Sent from my SM-E700H using Tapatalk Quote Link to comment Share on other sites More sharing options...
gS7 Posted February 24, 2017 Author Share Posted February 24, 2017 @grr thank you those codes are awesome I am going to learn with that codes thank you again @ satis thank you for trying to help me @ tharwat thank you for the hint Sent from my SM-E700H using Tapatalk Quote Link to comment Share on other sites More sharing options...
hanhphuc Posted February 24, 2017 Share Posted February 24, 2017 (edited) I want learn from lower so @grrr nice LM style Here's another lower version for novice (defun c:test (/ dcl dd en cp ob l pt) [color="green"];error handler try to code it by yourself[/color] (setq dcl (load_dialog "pickpoint.dcl") dd 2 en '("e" "n") cp '("Circle" "Point") pt (getvar 'viewctr) ) (while (>= dd 2) (if (null (new_dialog "pickpoint" dcl)) (exit) ) (set_tile "crt" (setq ob (cond (ob)("0"))) ) (start_list "crt") (mapcar 'add_list cp) (end_list) (action_tile "crt" "(setq ob $value)") (mapcar 'set_tile en (mapcar 'rtos pt '(2 2))) (action_tile "ok" "(setq pt (mapcar '(lambda (x)(atof(get_tile x))) en ))(done_dialog 1)" ) (action_tile "pick" "(done_dialog 2)") (setq dd (start_dialog)) (cond ((= dd 2) (setq pt (getpoint "\nSpecify point "))) ((= dd 1) (princ (mapcar ''((a b)(strcat " "(strcase a) "= "(rtos b 2)" ")) en pt))) ) ); While (setq l (list (cons 0 (nth (atoi ob) cp) )(cons 10 ([color="blue"]trans[/color] pt 1 0)))) (unload_dialog dcl) (entmakex (if (zerop (atoi ob)) (append l '((40 . 2)))l)) (princ) ) Edited February 24, 2017 by hanhphuc trans Quote Link to comment Share on other sites More sharing options...
gS7 Posted February 24, 2017 Author Share Posted February 24, 2017 wow it fantastic hanhphuc thank you so much Sent from my SM-E700H using Tapatalk 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.