dialog help

Discussion in 'AutoCAD' started by Phil, Apr 1, 2004.

  1. Phil

    Phil Guest

    I seem to have a time with dialog boxes.

    I recently modified code to place my simple error routine within my main
    function and the dialog routine broke??

    I think it was broke all along just didn't manifest itself. Anyway I
    have

    action_tile for "ok" :
    "(done_dialog 1)(dosomething)"

    action_tile for "cancel":
    "(done_dialog 0)(dosomethingelse)"

    when I hit my ok button the main program proceeds but it gives the
    familiar "function canceled" blurb anyway
    and when I hit cancel it freezes autocad.

    also any good tutorial sites for dialog box programming.
     
    Phil, Apr 1, 2004
    #1
  2. Phil

    Rudy Tovar Guest

    First of all, the value being passed for done_dialog is referenced to it's
    position, which can be assigned to a value, that you can later assign were
    you'd like the dialog to appear the next time.

    Next, simply do the following to a custom button I design for executing the
    close dialog.

    (defun C:test (/ dcl_id)
    ;gather defaults, or calcs.

    (setq dcl_id (load_dialog "C:\\test.dcl"))
    (if (not (new_dialog "main0" dcl_id)) (exit))

    ;set your tiles or add more actions.

    (action_tile "button0" "(setq close 1)(done_dialog)")

    (start_dialog)
    (unload_dialog dcl_id)
    (if (= close 1)(call_next_dialog))
    (princ)
    )

    ;This allows you to branch dialogs, but each dialog assigned variable must
    be a different name.
    (defun call_next_dialog (/)
    ;do it over or what ever, but use a different dcl_id#
    (princ)
    )
    --

    AUTODESK
    Authorized Developer
    www.Cadentity.com
    MASi
     
    Rudy Tovar, Apr 1, 2004
    #2
  3. Phil

    Phil Guest

    ok so to use your example I should do this for my situation:

    (action_tile "Cancel" "(setq close 1)(done_dialog)")
    (action_tile "OK" "(setq close 2)(done_dialog)")

    (start_dialog)
    (unload_dialog dcl_id)
    (cond
    ((= close 1)(dosomethingonCancel)(errRoutine))
    ((= close 2)(dosomethingorjustcontinue))
    )
    (princ)
     
    Phil, Apr 1, 2004
    #3
  4. Phil

    cwanless Guest

    Hi as far as good sites for dialog box programming, check out www.objectdcl.com

    Thanks Chad
     
    cwanless, Apr 1, 2004
    #4
  5. To add to this:

    Cancel will automatically returns a (done_dialog 0) to start_dialog,
    and OK returns a (done_dialog 1). So with this you really don't need
    to have an action_tile for OK or Cancel. The example below
    demenstrates this.

    (defun C:listbox (/ LST ind dcl_id job_name phase)
    (setq Lst (list "A" "B" "C" "D" "E" "F" "G"
    "H" "I" "J" "K" "L" "M" "N"))
    (setq dcl_id (load_dialog "listboxsample.dcl"))
    (if (null (new_dialog "listbox" dcl_id))
    (exit)
    )
    (start_list "lb1")
    (mapcar 'add_list lst)
    (end_list)
    (action_tile "tile_name" "(setq val (action))")
    (setq done (start_dialog))
    (unload_dialog dcl_id)
    (cond
    ((= done 0)
    (princ "\nCancel Pressed"))
    ((= done 1)
    (princ "\nOK Pressed")
    )
    ((= done 2)
    (next_dialog val)
    )
    )
    )

    (defun action ()
    (setq val (get_tile "tile_name"))
    ;;;postition of dialog when closed and
    ;;;set value of start_dialog to 2.
    (setq position (done_dialog 2))
    val
    )

    ;;;Use value of val in next dialog
    (defun next_dialog (val)
    (princ (strcat val " was entered"))
    )

    --
    Ken Alexander

    "We can't solve problems by using the same kind
    of thinking we used when we created them."
    --Albert Einstein
     
    Ken Alexander, Apr 1, 2004
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.