'DraftSight Lisp - Blank/Empty Dialog Box Lock
I'm trying to create a Yes/No/Cancel dialog box in DraftSight by using a tutorial's solution (Link to site). However, when I try to add the first message to the dialog box, the program breaks, and the dialog box opens without any code to close the dialog box. Using task manager to stop DraftSight is the only way I can close the dialog box. Is there an issue with the AutoLisp code that I'm using?
References: DraftSight/Solidworks Lisp
Lisp code:
;; Source: https://www.afralisp.net/dialog-control-language/tutorials/the-autolisp-message-box.php
;; Lisp code from tutorial
(defun lspYesNoCancel (message1 message2 message3 main)
(setq msgboxPath "C:\\Users\\GarrettB\\Documents\\Visual Studio Code\\DraftSight LISP")
(princ (strcat msgboxPath "\n"))
(princ)
;; Loading the dialoge box file and returning the ID file
(princ "YesNoCancel 01\n")
(setq dcl_id (load_dialog (strcat msgboxPath "\\" "msgbox.dcl")))
(princ "YesNoCancel 02\n")
;; Creating the dialoge box
(if (not (new_dialog "lspYesNoCancel" dcl_id "(done_dialog)")) (exit))
(princ "YesNoCancel 03\n")
(princ dcl_id)(princ "\n")
;; Dialoge Message
(if (set_tile "message1" message1)(princ "Message added to message1\n")(exit))
(princ "YesNoCancel 04-1\n")
(if (set_tile "message2" message2)(princ "Message added to message2\n")(exit))
(if (set_tile "message3" message3)(princ "Message added to message3\n")(exit))
(if (set_tile "main" main)(princ "Message added to main\n")(exit))
(princ "YesNoCancel 04-4\n")
;; Command Buttons
(if (action_tile "no" "(done_dialog) (setq result \"F\")")(princ "No command added\n")(exit))
(if (action_tile "yes" "(done_dialog) (setq result T)")(princ "Yes command added\n")(exit))
(if (action_tile "cancel" "(done_dialog) (setq result nil)")(princ "Cancel command added\n")(exit))
(princ "YesNoCancel 05\n")
;; Interaction
(exit)
(quit)
;; (start_dialog) ;----; Show dialog box
(unload_dialog dcl_id) ; Closes the link to the .dcl file
(princ)
)
dcl code:
lspYesNoCancel : dialog {
key = "main";
: column {
: text {Key = "message1";}
: text {key = "message2";}
: text {key = "message3";}
}
: row {
: spacer {width = 1;}
: button {
label = "Yes";
key = "yes";
width = 12;
fixed_width = true;
mnemonic = "Y";
is_default = true;
}
: button {
label = "No";
key = "no";
width = 12;
fixed_width = true;
mnemonic = "N";
}
: button {
label = "Cancel";
key = "cancel";
width = 12;
fixed_width = true;
mnemonic = "C";
is_cancel = true;
}
: spacer {width = 1;}
}
}
Solution 1:[1]
In the line : text {Key = "message1";}
, Key needs to have a lowercase "k." Therefore this : text {key = "message1";}
is the right answer.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | G Beck |