GettinBetter Posted December 13, 2009 Posted December 13, 2009 Hi people , I have created my very first (draft version of course) DCL, and I am wondering how to show it, nothing fancy just appear, I then obviously want to move on to extracting the user inputs from the text boxes, etc to LISP variables. 1. Are the DCL 'key' a usable variable in LISP or do I have to port them over to a local/global LISP variable? 2. Looking at the tutorials with the LISP editor, its seems good prctice to modularise parts of the code, so should I do this from the absolute beginning or adapt to it later when I understand LISP a little more? 3. I also keep getting a "; error: no function definition: C:SWBDMAIN" but haven't managed to resolve it. (defun c:swbdmain() (load_dialog "swbddialog.dcl") (showdialog) (unload_dialog dcl_id) ) (princ) ; Exit Cleanly Quote
Lee Mac Posted December 13, 2009 Posted December 13, 2009 Hi, Have you created the program (showdialog)? And if so, could you post what you have? To make the dialog just appear without doing anything, something like this would work: (defun c:test (/ dcTag) (cond ( (<= 0 (setq dcTag (load_dialog "swbddialog.dcl"))) (if (new_dialog [color=Blue][b]"Dialog_Definition" [/b][/color]dcTag "(done_dialog)") ;; << will need to be changed to suit (start_dialog)) (unload_dialog dcTag))) (princ)) The above means that whatever the user presses, the dialog will quit. You can get a similar result using the DCL Preview in the Visual LISP Editor (under Interface Tools). The "Dialog_Definition" is just whatever your dialog is defined as within your DCL file. You can find a lot more information here> http://www.afralisp.net/ Quote
GettinBetter Posted December 13, 2009 Author Posted December 13, 2009 Have you created the program (showdialog)? And if so, could you post what you have? Errm.. No, it looks like I have used dot NET code by mistake instead of (start_dialog). Hope I said that correct, I do have a working DCL file, just not the LISP code to run it. Thanks for the link, that'll be very handy over the next few months Quote
Lee Mac Posted December 13, 2009 Posted December 13, 2009 Not a problem, This is another great DCL tutorial : http://www.jefferypsanders.com/autolisp_DCL.html This would be a good starter for your LISP to accompany the DCL: (defun c:test (/ dcTag) (cond ( (<= (setq dcTag (load_dialog "dialog_file.dcl")) 0) (princ "\n** Dialog File not Found **")) ( (not (new_dialog "dialog_definition" dcTag)) (princ "\n** Dialog could not be Loaded **")) (t (action_tile "accept" "(done_dialog)") (action_tile "cancel" "(done_dialog)") (start_dialog) (unload_dialog dcTag))) (princ)) Quote
GettinBetter Posted December 13, 2009 Author Posted December 13, 2009 Ah, progress, thanks, now that gives me the as expected error message....that's better than my total bewilderment before So moving on.... So what IS a definition file.......is it as I would expect, a list of all the default sizes and values for the 'form'? Quote
Lee Mac Posted December 13, 2009 Posted December 13, 2009 So what IS a definition file.......is it as I would expect, a list of all the default sizes and values for the 'form'? The DCL file contains the Dialog Definition - all the tiles that make up the Dialog with their relevant keys/sizes/labels etc. The Dialog Definition (used in the new_dialog function), as you might have guessed, is the symbol that precedes the ': dialog' syntax. Lee Quote
Lee Mac Posted December 13, 2009 Posted December 13, 2009 1. Are the DCL 'key' a usable variable in LISP or do I have to port them over to a local/global LISP variable? Answering your original question: The DCL keys can be viewed as pointers to the tiles in the Dialog Definition, they can be used in the LISP through functions such as set_tile, mode_tile, start_list, get_tile, etc. They are not variables, but strings, however the value of a tile can be set to a variable using a combination of "get_tile" and the DCL tile key. Hope this helps, Lee Quote
GettinBetter Posted December 13, 2009 Author Posted December 13, 2009 So....I already have the dialog file which I've named swbddialog.dcl But in the DCL they only seem to call everything a "key" with "values" Ok, so I'll have a browse to find some examples, thanks a ton you've been a great help I'll be back with my results when I've had a read up Quote
Lee Mac Posted December 13, 2009 Posted December 13, 2009 So....I already have the dialog file which I've named swbddialog.dcl Yes, and within it you should have your dialog definition, whatever you have named it. Quote
Lee Mac Posted December 13, 2009 Posted December 13, 2009 A very old example! addone : dialog { label = "Specify Increment Direction"; : text { label = ""; key = "sel_text"; alignment = centered; } : row { : button { label = "+1"; key = "sel_add"; fixed_width = true; mnemonic = "+"; } : button { label = "-1"; key = "sel_sub"; fixed_width = true; mnemonic = "-"; } } // row ok_only; } In example, the Dialog definition is called "addone", and it is this string you need to supply to the new_dialog function. Quote
Lee Mac Posted December 13, 2009 Posted December 13, 2009 With the accompanying LISP file: (defun c:Sums (/ selAdd selSub ss dcTag fSel i ent elst) (vl-load-com) (defun selAdd nil (setq fSel 1+) (set_tile "sel_text" "Plus One Selected")) (defun selSub nil (setq fSel 1-) (set_tile "sel_text" "Minus One Selected")) (cond ( (<= (setq dcTag (load_dialog "AddOne.dcl")) 0) (princ "\n** Dialog File not Found **")) ( (not (new_dialog "addone" dcTag)) (princ "\n** Dialog could not be Loaded **")) (t (action_tile "sel_add" "(selAdd)") (action_tile "sel_sub" "(selSub)") (action_tile "accept" "(done_dialog)") (start_dialog) (unload_dialog dcTag) (if (setq i -1 ss (ssget (list (cons 0 "TEXT,MTEXT")))) (while (setq ent (ssname ss (setq i (1+ i)))) (setq elst (entget ent)) (entmod (subst (cons 1 (itoa (apply (function fsel) (list (atoi (cdr (assoc 1 eLst))))))) (assoc 1 eLst) eLst)))))) (princ)) addone : dialog { label = "Specify Increment Direction"; : text { label = ""; key = "sel_text"; alignment = centered; } : row { : button { label = "+1"; key = "sel_add"; fixed_width = true; mnemonic = "+"; } : button { label = "-1"; key = "sel_sub"; fixed_width = true; mnemonic = "-"; } } // row ok_only; } The DCL file would need to be saved as addone.dcl, purely because that is what the LISP is looking for, not because that is the name of the dialog definition. This is quite an old example, and pretty much the first DCL I ever created - but hopefully it will give you some idea of how to format things. More links: http://www.cadtutor.net/forum/showthread.php?t=32658 Lee Quote
GettinBetter Posted December 13, 2009 Author Posted December 13, 2009 Ah, gutted. I probably had it running ages ago, but for the uppercase second 'D' in the DCL fileI'd spelt it 'swbdDialog', and in the LSP file spelt it 'swbddialog'. Anyway its up and running now...and here's the code I'm currently using to get my DCL 'form' showing. Very basic, but for a custom DCL & a beginner I'm chuffed (defun C:swbdmain (/ dcl_id) ;define function (setq dcl_id (load_dialog "swbddialog.dcl")) ;load dialog (if (not (new_dialog "swbddialog" dcl_id) ;test for dialog );not (exit) ;exit if no dialog ) (start_dialog) ;start dialog (unload_dialog dcl_id) ;unload (princ) );defun C:swbdmain (princ) Really appreciated your advice and links, & the 'tile' concept is becoming clearer now. Quote
Lee Mac Posted December 13, 2009 Posted December 13, 2009 You're welcome! A few things: Make sure that you include either action_tile statements with "(done_dialog)" to close the dialog, or include a "(done_dialog)" in the new_dialog function. Test the return of the load_dialog function call before moving on for better error trapping. (see my earlier example). Other than that - well done. Lee Quote
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.