OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: funkitect on January 09, 2018, 06:58:35 PM

Title: Problem suspending dialog for editor access
Post by: funkitect on January 09, 2018, 06:58:35 PM
Hi there,

I'm working on a project that I wrote a long time ago.  I recently added a button to my dialog and my program crashes when I use it.  The program has several buttons that do various things in AutoCAD.  Each button still works except the new one.  Each button calls the same function that:

--sets a global "flag" to true
--save some info on the form to a global variable
--closes the dialog
--does a variety of things based on the arguments passed by the calling function (the button events).[/li][/list]


  The function called by the bad button works to a point.  I removed the complicated code and replaced it with something simple so I could see if it's working:

   (alert "3")
   (command "zoom" "e" )

The alert works but the zoom does NOT.  Stepping through the program, it turns out the dialog returns immediately after the zoom.  If I push any buttons when the dialog returns it crashes with the message, "FATAL ERROR: Unhandled Access Violation Reading 0x0010 Exception at 8d7f3ab9h"

It seems like I'm forgetting something. I was looking in the documentation because I remembered the bit about setting the flag and closing the dialog...but I couldn't find anything about this topic.  Are commands not allowed when dialog is suspended? 
Title: Re: Problem suspending dialog for editor access
Post by: Fred Tomke on January 09, 2018, 09:12:06 PM
Hi, funkitect,

not sure if I'm right but be aware of modifying drawing database at runtime of a modal form with beginning of AutoCAD 2015 (fiber technology was removed from AutoCAD).
Since you can't give control back to AutoCAD at runtime of a modal form, you have to close it at first and call it again after doing your changes. In modeless forms you have to set the button's event invoke property to Allow Command to call your event asynchonously.

So in modal forms you do something like this:



(defun c:proj_form_OnZoomClicked()
  (dcl_form_close proj_form 3)
); c:proj_form_OnZoomClicked

(setq doCont T)
(while doCont
  (cond
    ((= doCont 0) nil)
    ((= doCont 1) (setq doCont nil)) ;; OK
    ((= doCont 2) (setq doCont nil)) ;; ESC was pressed
    ((= doCont 3) (command "_zoom" "_e")) ;; your command,  3 is the retValue of dcl_form_close
  ); cond
); while



I took the sample from this FAQ (http://opendcl.com/forum/index.php?topic=1080.0).

Hope it matches to your question.

Regards, Fred
Title: Re: Problem suspending dialog for editor access
Post by: Tharwat on January 09, 2018, 09:21:15 PM
Hi,

In AutoLISP, you can not use command calls in action_tile that controls or collect the info from the dialog so I think you are facing the same case if I am not mistaken.

Try to replace that command with the function vla-zoomextents and I think it should work as expected.

http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-B204BFAA-B774-4C87-86D8-37007F390B5A (http://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-B204BFAA-B774-4C87-86D8-37007F390B5A)

Good luck.
Title: Re: Problem suspending dialog for editor access
Post by: funkitect on January 10, 2018, 08:47:10 AM
vla-zoomextents fixed it.  Thanks.
Title: Re: Problem suspending dialog for editor access
Post by: Tharwat on January 10, 2018, 08:55:25 AM
Glad you got it working.

You're welcome anytime.