Author Topic: Problem suspending dialog for editor access  (Read 426 times)

funkitect

  • Member
  • *
  • Posts: 30
Problem suspending dialog for editor access
« 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? 

Fred Tomke

  • OpenDCL Technician
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2024
  • [ Mr. Bad Guy ]
    • Kommunale Entwicklungsplanung auf digitaler Basis - digital landscape and urban design
Re: Problem suspending dialog for editor access
« Reply #1 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:

Code: [Select]

(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.

Hope it matches to your question.

Regards, Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

Tharwat

  • Member
  • *
  • Posts: 28
Re: Problem suspending dialog for editor access
« Reply #2 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

Good luck.

funkitect

  • Member
  • *
  • Posts: 30
Re: Problem suspending dialog for editor access
« Reply #3 on: January 10, 2018, 08:47:10 AM »
vla-zoomextents fixed it.  Thanks.

Tharwat

  • Member
  • *
  • Posts: 28
Re: Problem suspending dialog for editor access
« Reply #4 on: January 10, 2018, 08:55:25 AM »
Glad you got it working.

You're welcome anytime.