Author Topic: Code generates fatal error message  (Read 2222 times)

0 Members and 1 Guest are viewing this topic.

bemiller1

  • Guest
Code generates fatal error message
« on: May 09, 2011, 01:38:41 PM »
I cobbled together the following routine a while back. It basically works except for an annoyance that I would like to get some advice on.
(The routine rotates objects a chosen number of degrees, renders the view after each rotation).
The annoyance is that after the routine runs ACAD crashes with various related error messages e.g. :
AutoCAD Error Aborting
FATAL ERROR: Unhandled Access Violation Reading 0x20302e31 Exception at 20202e31h


Exception in C;\Program Files\AutoCAD 2002\acrender.arx ARX Command
Unhandled Exception C0000005 (Access Violation Reading 0xc96e7a6c) at address 773893E5h



Exception in C:\Program Files\AutoCAD 2002\acrender.arx ARX Command
Unhandled Exception C0000005 (Access Violation Reading 0xc0ef1eb8) at address 63DD8CB1h

Some times it crashs before the entered amount of rotation/renderings are completed. (the latter error message may have been generated after a mid-run crash)

So what I guess I am asking is might there be something missing in the code that is problematic? Or conversely something that should not be in there.

Any suggestions out there?

Thanx, this site is fabulous BTW (I managed to get this routine worked out and running with lots-o-help from theswanp in the first place.)
 







Code: [Select]
(defun c:animat (/ INLIST acadObject Arxlist strArx rtod cmdold ss p1 p2 num ang deg centr)
  (defun INLIST (lst str / cnt ret)
    (setq cnt -1
  ret nil
    )
    (repeat (length lst)
      (if (wcmatch (strcase (nth (setq cnt (1+ cnt)) lst))
   (strcat "*" (strcase str) "*")
  )
(setq ret 1)
      ) ;if
    ) ;repeat
    ret
  ) ;defun INLIST
  (vl-load-com)
  (setq acadObject (vlax-get-acad-object))
  (setq Arxlist (vla-listarx acadObject))
  (setq strArx (vlax-safearray->list (vlax-variant-value arxlist)))
  (defun rtod (a) (/ (* a 180) pi))
  (setq cmdold (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (setq osmold (getvar "osmode"))
  (setvar "osmode" 0)
  (if (not (INLIST (arx) "RENDER"))
    (if (not (arxload "acrender" nil))
      (progn (princ "\nError: unable to locate rendering extension")
     (exit)
      ) ;progn
    ) ;if nested
  ) ;if
  (if (= (member '"geom3d.arx" strArx) nil)
    (arxload "geom3d.arx")
  ) ;if
  (if (setq ss (ssget))
    (progn
      (command ".undo" "Mark")
      (setq p1 '(118.771 -131.865 23.562)
    p2 '(128.297 -119.672 23.562)
      ) ;setq pn
      (if (not (setq num (getint "\nEnter number of images:<15> ")))
(setq num 15)
      ) ;if
      (if (setq ang (getangle "\nEnter degrees of movement:<3> "))
(setq deg (rtod ang))
(setq deg 3)
      ) ;if
      (setq cntr 0)
      (c:rpref "DEST" "FILE")
      (c:rpref "TOGGLE" "CACHE" "OFF")
      (c:rpref "TOGGLE" "SKIPRDLG" "ON")
      (c:rpref "ROPT" "ASCAN" 2 NIL NIL 0 1 3)
      (c:rfileopt "BMP" 640 480 1.0 "C8")
      (repeat num
(c:render (strcat "C:\\TEMP\\TestImage-"
  (itoa (setq cntr (1+ cntr)))
  ".bmp"
  ) ;strcat
) ;render
(c:rotate3d ss  p1 p2 deg)
      ) ;repeat
      (c:rpref "TOGGLE" "SKIPRDLG" "OFF")
      (command ".undo" "Back")
    ) ;progn
  ) ;if
  (setvar "cmdecho" cmdold)
  (setvar "osmode" osmold)
  (princ)
) ;defun animat




CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Code generates fatal error message
« Reply #1 on: May 09, 2011, 02:45:06 PM »
Glad you are enjoying the site. :-)

I see nothing obviously wrong with the code, maybe in the subroutines you call?

What I do when faced with an elusive error is drop bread crumbs along the way to see where it stops working.

Code: [Select]
(prompt "\nYou made it to line 325.")
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

bemiller1

  • Guest
Re: Code generates fatal error message
« Reply #2 on: May 10, 2011, 08:02:47 AM »
Thanks CAB,
When I run the routine it crashes ACAD at the end of the routine i.e. after it renders the chosen number of images, usually 72. The odd time it crashes before reaching the number of images chosen. In this latter instance, where it crashes seems to be arbitrary. This condition is drawing specific. In other words only a certain few drawings will crash the program unpredictably. These drawings are not any more complex or a larger file size.

It sounds like the breadcrumb method of tracking down the conditions at point of crash might be very useful with the arbitrary crash examples. But here's where I display my complete novice status. Where in the code would you drop these code/crumbs and how are these bits of code written so that they display the line where it stopped working. Could you, as an example, drop one into my code and give it a colour to highlight it.
Hope that is not too much to ask. I sure would appreciate to see how a professional tracks a bug to its lair.

Lee Mac

  • Seagull
  • Posts: 12929
  • London, England
Re: Code generates fatal error message
« Reply #3 on: May 10, 2011, 08:05:05 AM »
Hi Bemiller,

Perhaps this tutorial will help you ascertain the source of the error:

http://lee-mac.com/debugvlide.html

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Code generates fatal error message
« Reply #4 on: May 10, 2011, 09:19:55 AM »
OK if the routine is complete then something you did is making ACAD unstable.
That would be an ACAD bug. 8-)  
So try adding (gc)(gc) to your routine. If you can determine the crash point add them there, if not add to the end.
Just a stab in the dark.

In you subroutines be sure and release any vlisp objects.
This may help:  (vlax-release-object obj)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.