Author Topic: How do I make a dcl button pick an object then return to the main dialog box?  (Read 2101 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
I would like to know how to code dcl button to pick an object in autocad then return to the main dcl dialog box.
I have tried to code it with
Code: [Select]
(action_tile "function_key" "(function)(done_dialog)")I have tried to code it with
Code: [Select]
(action_tile "function_key" "(function)(done_dialog 1)")Am I supposed to unload_dialog then start_dialog?
Please advise.

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Am I supposed to unload_dialog then start_dialog?
no need to unload
just done_dialog and then start_dialog again, it all must be wrapped in a while loop

dubb

  • Swamp Rat
  • Posts: 1105
Am I supposed to unload_dialog then start_dialog?
no need to unload
just done_dialog and then start_dialog again, it all must be wrapped in a while loop
Which part needs to be in a while loop? Is it (function) in the (action_tile "function_key" "(function)(done_dialog)")?
How would I write the the while loop with (start_dialog) and (done_dialog)?


rayakmal

  • Newt
  • Posts: 49
Here's a sample to create dialog which allow us to pick something in the drawing (points, entity etc)
Code: [Select]
   (defun ddmkv_main ()
      (setq dh (load_dialog "ddmkview.dcl"))
      (while (and loop dh (new_dialog "ddmkv_dlg" dh))
         (ddmkv_init_tiles)
         (ddmkv_get_actions)
         (setq whatnext (start_dialog))
         (cond ( (= whatnext 0)
                 (setq loop nil)
               )
               ( (= whatnext 4)
                 (while (= (setq pt1 (getpoint "\nFirst  corner: ")) nil))
                 (while (= (setq pt2 (getcorner pt1 "\nSecond corner: ")) nil))
                 (setq ddmkv_pt1pt2 (list pt1 pt2))
               )
         ); end of cond
      ); end of while
      (unload_dialog dh)
      (command "undo" "mark")
      (if (= 1 whatnext) (ddmkv_startcommand))
   )


Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Here's a quick example:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / *error* dcf dch dcl des ent )
  2.  
  3.     (defun *error* ( msg )
  4.         (if (< 0 dch) (unload_dialog dch))
  5.         (if (= 'file (type des)) (close des))
  6.         (if (and (= 'str (type dcl)) (findfile dcl)) (vl-file-delete dcl))
  7.         (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")))
  8.             (princ (strcat "\nError: " msg))
  9.         )
  10.         (princ)
  11.     )
  12.  
  13.     (if
  14.         (and
  15.             (setq dcl (vl-filename-mktemp nil nil ".dcl"))
  16.             (setq des (open dcl "w"))
  17.             (foreach str
  18.                '(
  19.                     "test : dialog"
  20.                     "{"
  21.                     "    label = \"Example\";"
  22.                     "    spacer;"
  23.                     "    : button"
  24.                     "    {"
  25.                     "        key = \"obj\";"
  26.                     "        label = \"Select object\";"
  27.                     "    }"
  28.                     "    spacer;"
  29.                     "    ok_only;"
  30.                     "}"
  31.                 )
  32.                 (write-line str des)
  33.             )
  34.             (not (setq des (close des)))
  35.             (< 0 (setq dch (load_dialog dcl)))
  36.         )
  37.         (while (not (member dcf '(0 1)))
  38.             (cond
  39.                 (   (= 2 dcf)
  40.                     (setq ent (car (entsel))
  41.                           dcf nil
  42.                     )
  43.                 )
  44.                 (   (new_dialog "test" dch)
  45.                     (action_tile "obj" "(done_dialog 2)")
  46.                     (setq dcf (start_dialog))
  47.                 )
  48.                 (   (princ "\nUnable to display dialog.")
  49.                     (setq dcf 0)
  50.                 )
  51.             )
  52.         )
  53.         (princ "\nUnable to write & load DCL file.")
  54.     )
  55.     (*error* nil)
  56.     (princ)
  57. )