Author Topic: Cancel in DCL file  (Read 3077 times)

0 Members and 1 Guest are viewing this topic.

chrisha

  • Guest
Cancel in DCL file
« on: November 19, 2004, 01:45:44 AM »
Hi,

I am updating a Steel Member Lisp drawing routine that calls up a DCL dialog box from where you pick what you want to have drawn, Eg select UC and a DCL dialoge box pops up with the member selction sizes and orientation variants available. It all works well except for the CANCEL button. You can cancel from the first dialogue box no problems but cancelling from the specific Steel Member dialoge box causes Autocad to freeze then crash. I have fiddled and got it not to crash but it draws the member anyway or you Esc Esc and get back to the command linr that way OK. Could have something to do with a hierachy of DCL pop up windows ie have to cancel back to the first selection windoe then reselsct or cancel from there.
Also there is no author credits, anyone know who wrote it?
All advice happly received.

thanks

Code from the Steel Member LISP file to cancel the routine  which still draws the member,

(defun TFB( / dcl_id)
(initerr)
    (setq os(getvar "osmode"))
    (setvar "cmdecho" 0)
    (setq dcl_id (load_dialog "stl_sect"))
    (setq TFB_pt (if TFB_pt TFB_pt '(-1 -1)))
    (if (not (new_dialog "stl_sect" dcl_id "" TFB_pt)) (exit))
    (setq size 0)
    (setq view "sect")
    (setq cl "T")
    (mode_tile "mirror" 1)
    (mode_tile "near" 1)
    (mode_tile "far" 1)
    (set_tile "top" "1")
    (set_tile "sect" "1")
    (sect)
;-------------------------------------------------------------------  
   (setq TFB_list (list
"100 x 45 TFB"
"125 x 65 TFB"
   )
   )
   (start_list "size")
   (mapcar 'add_list TFB_list)
   (end_list)
   (set_tile "size" "0")
   (c_list)
;-------------------------------------------------------------------    
    (action_tile "plan" "(plan)")
    (action_tile "elev" "(elev)")
    (action_tile "sect" "(sect)")
    (action_tile "top"  "(progn  (setq cl \"T\")) (elevt)")
    (action_tile "cen"  "(progn  (setq cl \"C\")) (elevc)")
    (action_tile "size" "(progn (setq size (atoi $value))) (c_list)")
    (action_tile "accept" "(setq TFB_pt (done_dialog 1))")
    (action_tile "cancel" "(progn (done_dialog 0))")
    (start_dialog)
    (unload_dialog dcl_id)
    (cond
    ((= view "plan") (TFBplan))
    ((= view "sect") (TFBsect))
    ((= view "elev") (TFBelev))
    )
)

Also tried
 (action_tile "accept" "(setq TFB_pt (done_dialog )")
  (action_tile "cancel" "(progn (done_dialog) (setq usercheck 1)")
with the same result

This was the original code
   (action_tile "accept" "(setq TFB_pt (done_dialog))")
    (action_tile "cancel" "(progn (done_dialog) (quit))")

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Cancel in DCL file
« Reply #1 on: November 19, 2004, 02:27:30 AM »
Hi chrisha,

The start_dialog function actually returns the done_dialog value,

so, .. Have a play with this

Code: [Select]
;-------------------------------------------------------------------
    ( ... action stuff .. )
    (action_tile "size" "(progn (setq size (atoi $value))) (c_list)")
    (action_tile "accept" "(setq TFB_pt (done_dialog 1))")
    (action_tile "cancel" "(progn (done_dialog 0))")
    (setq do_what (start_dialog))
         
    (unload_dialog dcl_id)
    (if (= do_what 1)
      (progn
   (cond ((= view "plan") (TFBplan))
         ((= view "sect") (TFBsect))
         ((= view "elev") (TFBelev))
   )
        (... do other accept stuff .. )
      )
      ;; else was 0, so
      (progn
      ( .. do cancel stuff )
      )
    )
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Cancel in DCL file
« Reply #2 on: November 19, 2004, 04:42:51 AM »
chrisha -

please see this thread http://theswamp.org/phpBB2/viewtopic.php?t=3173
TheSwamp.org  (serving the CAD community since 2003)

chrisha

  • Guest
Cancel in DCL file
« Reply #3 on: November 21, 2004, 10:04:41 PM »
Kerry,

Thanks for reply, still won't work,

regards

Chris.

You let Adelaide win!!!!!!!!!

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Cancel in DCL file
« Reply #4 on: November 21, 2004, 10:32:57 PM »
Quote from: chrisha
Kerry,

Thanks for reply, still won't work,



Thats 'cause I'm an idiot ...  should be

(if (= do_what 1)
NOT
(if (= (do_what 1))

kwb
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

chrisha

  • Guest
Cancel in DCL file
« Reply #5 on: November 23, 2004, 07:54:19 PM »
Kerry,

Works this time

thanks again

Chris
 :D  :D  :D