Author Topic: 2006 bug?: Dyn Input + Floating Command Line + Keyboard Input = Lisp Crash  (Read 2590 times)

0 Members and 1 Guest are viewing this topic.

sinc

  • Guest
I'm having trouble with the following Lisp routine.  It works fine in 2004, but has a problem in 2006.

Essentially, it tells you the current scale of a viewport, and lets you change it if you wish.  You can run it in floating model space, in which case it works on the current viewport, or in paper space, in which case you select one or more viewports, and it cycles through them.

The issue is on 2006, when multiple viewports are selected.  The routine works fine up until the user tries to enter a new viewport scale.  Then Autocad crashes hard, as soon as the first keystroke happens.  No need to hit return or anything; just hit any key, and Autocad will take a dump.

I tried debugging the routine, but I noticed that if I first start the VLISP editor, then load the Lisp while the VLISP editor is active, I have no issues.  The routine works fine.  The key is that the Lisp routine must be loaded while the VLISP editor is open.  I can open the VLISP editor, load VPS.LISP, and close the VLISP editor, and the routine will work fine.  However, if the VLISP editor is not open when the routine is loaded, Autocad crashes on an unhandled exception error during user input.

This gave me an idea, so I tried turning off Dynamic Input.  Sure enough, the routine works without a problem.  So, running this Lisp in 2006 with Dynamic Input enabled causes Autocad to crash hard on an unhandled exception error.  I have no idea why - I think it's a bug inside Autocad somewhere.  It could have something to do with the way the Lisp routine shifts the active viewport, interacting badly with Dynamic Input.

I'm planning on submitting a bug report to Autodesk.  Can anyone verify this bug, or maybe provide some insight as to why the crash is occurring, or any other input that I can also pass on to Autodesk in the bug report?


Code: [Select]
; vps.lsp v1.01
 ; Richard Sincovec  Sep-18-2004
 ; Displays currently-active paperspace viewport scale in decimal/metric
 ; form, and lets user specify a new one.  If user is in paperspace
 ; instead of floating modelspace, multiple viewports can be selected.
 ; (Command does nothing in modelspace.)

(vl-load-com)
(defun vps:scaleViewport (doc vp / cscale sctxt inp)
  (vla-highlight vp :vlax-true)
  (setq cscale (vla-get-customScale vp)
sctxt  (cond
((> cscale 1)
  (strcat (cond
    ((equal cscale (fix cscale) 0.01)
     (rtos cscale 2 0)
    )
    ((rtos cscale 2 2))
  ) ;_ cond
  ":1"
  ) ;_ strcat
)
((setq cscale (/ 1 cscale))
  (strcat
    "1:"
    (cond
      ((equal cscale (fix cscale) 0.01)
       (rtos cscale 2 0)
      )
      ((rtos cscale 2 2))
    ) ;_ cond
  ) ;_ strcat
)
       ) ;_ cond
inp    (getreal
(strcat "\nCurrent scale "
sctxt
"; new scale? "
) ;_ strcat
       ) ;_ getreal
  ) ;_ setq
  (vla-highlight vp :vlax-false)
  (if inp
    (vla-put-customScale vp inp)
    (vla-put-activePViewport doc vp)
  ) ;_ if
) ;_ defun

(defun c:vps (/ ss err index count doc vp)
  (if (= (getvar "tilemode") 1)
    (princ "VPS only works in paperspace!")
    (if (= (getvar "cvport") 1)
      ;; in paperspace
      (progn
(setq err
       (vl-catch-all-apply
(function
   (lambda ()
     (setq ss (ssget '((0 . "VIEWPORT")))
   count (sslength ss)
   index -1
     ) ;_ setq
     (while (< (setq index (1+ index)) count)
       (setq vp (vlax-ename->vla-object (ssname ss index))
     doc (vla-get-document vp)
       ) ;_ setq
       (vla-display vp :vlax-true)
       (vla-put-mspace doc :vlax-true)
       (vla-put-activePViewport doc vp)
       (vps:scaleViewport doc vp)
     ) ;_ while
   ) ;_ lambda
) ;_ function
       ) ;_ vl-catch-all-apply
) ;_ setq
(vla-put-mspace doc :vlax-false)
      ) ;_ progn
      ;; in floating modelspace
      (setq err
     (vl-catch-all-apply
       (function
(lambda ()
   (setq doc (vla-get-activeDocument (vlax-get-acad-object))
vp  (vla-get-activePViewport doc)
   ) ;_ setq
   (vps:scaleViewport doc vp)
   (vla-regen doc acActiveViewport)
) ;_ lambda
       ) ;_ function
     ) ;_ vl-catch-all-apply
      ) ;_ setq
    ) ;_ if
  ) ;_ if
  (if (vl-catch-all-error-p err)
    (princ (vl-catch-all-error-message err))
  ) ;_ if
  (princ)
) ;_ defun
« Last Edit: February 20, 2006, 11:48:49 AM by sinc »

sinc

  • Guest
Re: Possible 2006 bug? - Dynamic Input causes Lisp Crash
« Reply #1 on: February 20, 2006, 11:46:57 AM »
OK, I've narrowed down the problem.

Going through the code, there were some extra lines in there.  I couldn't remember why I had put them in, and they seem unnecessary, so I took them out.  The revised routine is posted below.

This seems like a definite problem with Dynamic Input in 2006.  I've since run into this exact same problem with built-in Autodesk commands, but I haven't yet figured out any other way to reliably trigger the problem.  This script seems to trigger it every time, at least on the two different installations of 2006 I've tried it on.

In order to trigger the bug, you must have Dynamic Input enabled, and the command line must be floating.  If Dynamic Input is disabled or the command line is docked, the bug will not occur.  Also, you must not have the VLISP editor up and running - this also prevents the bug from occurring.

The bug occurs in paper space.  Start the VPS routine.  You should see the prompt "Select objects?".  Select one or more viewports.  Now, hit return without touching the mouse.

The prompt should change to something like "Current scale: 1:100; new scale?".  In fact, if you look at the command window, you will see this prompt.  However, the Dynamic Input prompt will still say "Select objects?".  If you move the mouse at this point, you will see the Dynamic Input prompt change to the expected "Current scale: 1:100; new scale?" prompt.  You may now enter values, and the program will run without a problem.  If you type anything on the keyboard while the Dynamic Input prompt still says "Select objects?", Autocad will crash on an "Unhandled Exception" error.

sinc

  • Guest
Re: 2006 bug?: Dyn Input + Floating Command Line + Keyboard Input = Lisp Crash
« Reply #2 on: February 20, 2006, 11:51:12 AM »
Oops, forgot to repost the code:
Code: [Select]
; vps.lsp v1.01
 ; Richard Sincovec  Sep-18-2004
 ; Displays currently-active paperspace viewport scale in decimal/metric
 ; form, and lets user specify a new one.  If user is in paperspace
 ; instead of floating modelspace, multiple viewports can be selected.
 ; (Command does nothing in modelspace.)

(vl-load-com)
(defun vps:scaleViewport (doc vp / cscale sctxt inp)
  (vla-highlight vp :vlax-true)
  (setq cscale (vla-get-customScale vp)
sctxt  (cond
((> cscale 1)
  (strcat (cond
    ((equal cscale (fix cscale) 0.01)
     (rtos cscale 2 0)
    )
    ((rtos cscale 2 2))
  ) ;_ cond
  ":1"
  ) ;_ strcat
)
((setq cscale (/ 1 cscale))
  (strcat
    "1:"
    (cond
      ((equal cscale (fix cscale) 0.01)
       (rtos cscale 2 0)
      )
      ((rtos cscale 2 2))
    ) ;_ cond
  ) ;_ strcat
)
       ) ;_ cond
inp    (getreal
(strcat "\nCurrent scale "
sctxt
"; new scale? "
) ;_ strcat
       ) ;_ getreal
  ) ;_ setq
  (vla-highlight vp :vlax-false)
  (if inp
    (vla-put-customScale vp inp)
  ) ;_ if
) ;_ defun

(defun c:vps (/ ss err index count doc vp)
  (if (= (getvar "tilemode") 1)
    (princ "VPS only works in paperspace!")
    (if (= (getvar "cvport") 1)
      ;; in paperspace
      (progn
(setq err
       (vl-catch-all-apply
(function
   (lambda ()
     (setq ss (ssget '((0 . "VIEWPORT")))
   count (sslength ss)
   index -1
     ) ;_ setq
     (while (< (setq index (1+ index)) count)
       (setq vp (vlax-ename->vla-object (ssname ss index))
     doc (vla-get-document vp)
       ) ;_ setq
       (vps:scaleViewport doc vp)
     ) ;_ while
   ) ;_ lambda
) ;_ function
       ) ;_ vl-catch-all-apply
) ;_ setq
(vla-put-mspace doc :vlax-false)
      ) ;_ progn
      ;; in floating modelspace
      (setq err
     (vl-catch-all-apply
       (function
(lambda ()
   (setq doc (vla-get-activeDocument (vlax-get-acad-object))
vp  (vla-get-activePViewport doc)
   ) ;_ setq
   (vps:scaleViewport doc vp)
   (vla-regen doc acActiveViewport)
) ;_ lambda
       ) ;_ function
     ) ;_ vl-catch-all-apply
      ) ;_ setq
    ) ;_ if
  ) ;_ if
  (if (vl-catch-all-error-p err)
    (princ (vl-catch-all-error-message err))
  ) ;_ if
  (princ)
) ;_ defun

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: 2006 bug?: Dyn Input + Floating Command Line + Keyboard Input = Lisp Crash
« Reply #3 on: February 20, 2006, 03:49:23 PM »
Just for the record, do you have ServicePack 1 Installed.

< not suggesting that will rectify the issue >
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.

sinc

  • Guest
Re: 2006 bug?: Dyn Input + Floating Command Line + Keyboard Input = Lisp Crash
« Reply #4 on: February 21, 2006, 04:51:49 PM »
Just for the record, do you have ServicePack 1 Installed.

< not suggesting that will rectify the issue >

Yes.  Why, have you tried unsuccessfully to duplicate the bug?  Or were you just asking?