ripuz Posted September 19, 2011 Share Posted September 19, 2011 (edited) Hello, i have a problem with dcl which i´m new at. This is just an example to see my problem. An easy DLC file called test.dlc : test : dialog { label = "test dialog" ; : button { label = "Ok" ; key = "accepted" ; height = 1 ; width = 13 ; is_default = true ; } } ;; The lisp file to run the dialog: (defun test ( / flag dcl_id) (setq dcl_id (load_dialog "test.dcl")) (setq flag (new_dialog "test" dcl_id)) (if (null flag) (exit)) (action_tile "accepted" "(test_accepted)(done_dialog)") (start_dialog) (unload_dialog dcl_id) ) (defun test_accepted () (load "SomeLispFile.lsp") (princ "hello") (alert "hello again") (command "snap" "on") ) When i run the test function everything works fine until it reaches an AutoCad command (in this case snap), then AutoCad stops responding. It seems to be when a command is runned within the dialog function. Anyone who know anything about this please help me! Thanks in advance / Thomas Edited September 19, 2011 by ripuz Didn´t follow the Code Posting Guidline Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 19, 2011 Share Posted September 19, 2011 Please use the Code Posting Guidline Quote Link to comment Share on other sites More sharing options...
ripuz Posted September 19, 2011 Author Share Posted September 19, 2011 I´m sorry.. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 19, 2011 Share Posted September 19, 2011 I´m sorry.. No worries Thomas . Welcome to the forum first . All the hanging comes from the command call of snap , so replace it with the system variable like this . (setvar 'snapmode 1) Besides that , your routine name which is SomeLispFile.lsp should be in the Acad support folder to be loaded and to let the routine running to end to put snap mode on also as well . Hope this help . Tharwat Quote Link to comment Share on other sites More sharing options...
ripuz Posted September 19, 2011 Author Share Posted September 19, 2011 Each time a drawing is opened a lisp file i loaded and that one loads another and so on. My goal is to reload this sequence when the ok button is pressed but that isn´t possible as long as there is command calls in the lisp files? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 19, 2011 Share Posted September 19, 2011 Each time a drawing is opened a lisp file i loaded and that one loads another and so on.My goal is to reload this sequence when the ok button is pressed but that isn´t possible as long as there is command calls in the lisp files? Yes this is what I meant in my last post . Anyway here it is completely . (defun c:test ( / flag dcl_id) (setq dcl_id (load_dialog "test.dcl")) (setq flag (new_dialog "test" dcl_id)) (if (null flag) (exit)) (action_tile "accepted" "(test_accepted)(done_dialog)") (start_dialog) (unload_dialog dcl_id) ) (defun test_accepted () (load "SomeLispFile.lsp") (princ "hello") (alert "hello again") (setvar 'snapmode 1) ) Tharwat Quote Link to comment Share on other sites More sharing options...
ripuz Posted September 19, 2011 Author Share Posted September 19, 2011 Thanks Tharwat for your answers! I rewrote all regular commands with setvar or with vl-commands so now it works just fine. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 19, 2011 Share Posted September 19, 2011 I am so glad to hear that Thomas . Tharwat Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 20, 2011 Share Posted September 20, 2011 I rewrote all regular commands with setvar or with vl-commands so now it works just fine. The issue is not with using command calls, but rather that the focus remains with the modal dialog when the command is called. Instead, consider this code: DCL: test : dialog { label = "test dialog" ; ok_only; } LISP: (defun test ( / id ) (cond ( (< 0 (setq id (load_dialog "test.dcl"))) (cond ( (new_dialog "test" id) (if (= 1 (start_dialog)) (test_accepted) ) ) ) (unload_dialog id) ) ) (princ) ) (defun test_accepted nil (load "SomeLispFile.lsp") (princ "hello") (alert "hello again") (setvar 'SNAPMODE 0) ) Quote Link to comment Share on other sites More sharing options...
ripuz Posted September 21, 2011 Author Share Posted September 21, 2011 Thank you Lee Mac! It took me a while to understand but now I see that I can use whatever I want if I just close the dialog first. Quite obvious when you know it... Nice to get an answer from a legend of this site! (I have seen your answers many times on this site before I registered myself.) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted September 21, 2011 Share Posted September 21, 2011 Thank you Lee Mac!It took me a while to understand but now I see that I can use whatever I want if I just close the dialog first. Quite obvious when you know it... Nice to get an answer from a legend of this site! (I have seen your answers many times on this site before I registered myself.) You're very welcome ripuz! I'm flattered that my reputation precedes me 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.