TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: roy_043 on December 18, 2012, 06:22:32 AM

Title: Restore grdraw graphics after zoom?
Post by: roy_043 on December 18, 2012, 06:22:32 AM
I am trying to restore grdraw graphics after zoom, pan etc. The code below doesn't do the trick. After a zoom action the temp line is briefly visible but then disappears. My guess is that the CAD-program performs a redraw after the call-back. Tested on BricsCAD 13.

Is there a way to restore grdraw graphics? Or is the best course of action temporary xlines?

Code - Auto/Visual Lisp: [Select]
  1. ;;; Global list for testing, the list contains a point and an angle:
  2. (setq *TempGraphics_DataList* (list '(0.0 0.0 0.0)  (/ pi 4.0)))
  3.  
  4. (setq *TempGraphics_acdbReactor*
  5.     nil ; No data.
  6.     '((:vlr-objectModified . TempGraphics_CallBack_Acdb_ObjectModified))
  7.   )
  8. )
  9.  
  10. (defun TempGraphics_CallBack_Acdb_ObjectModified (rea lst / object)
  11.   (print "TempGraphics_CallBack_Acdb_ObjectModified")
  12.   (setq object (vlax-ename->vla-object (cadr lst)))
  13.   (if
  14.     (and
  15.       *TempGraphics_DataList*
  16.       (member
  17.         (strcase (vla-get-objectname object))
  18.         '("ACDBVIEWPORT" "ACDBVIEWPORTTABLERECORD")
  19.       )
  20.     )
  21.     (TempGraphics_Draw *TempGraphics_DataList*)
  22.   )
  23. )
  24.  
  25. (defun TempGraphics_Draw (lst / pt ang)
  26.   (print "TempGraphics_Draw")
  27.   (setq pt (car lst))
  28.   (setq ang (cadr lst))
  29.   (redraw)
  30.   (grdraw pt (polar pt ang 1.0e6) 1 1) ; (grdraw <point> <point> <color> [<highlight>])
  31. )
  32.  
Title: Re: Restore grdraw graphics after zoom?
Post by: irneb on December 18, 2012, 06:48:22 AM
What you've noticed is exactly correct: A zoom / pan causes a redraw. So all grdraw's / grvec's will be "erased".

If your grdraw is simply a line from one side to another, then you "could" go for a "temporary" XLine - though then you're left with "When should it be deleted?"

Unfortunately I'm not sure of a reactor noticing when something like a scroll zoom / pan happened. Otherwise you could have simply redrawn the grdraw.
Title: Re: Restore grdraw graphics after zoom?
Post by: roy_043 on December 18, 2012, 10:32:41 AM
Unfortunately I'm not sure of a reactor noticing when something like a scroll zoom / pan happened. Otherwise you could have simply redrawn the grdraw.
Actually my code does detect zoom and pan actions. That is not the issue. The problem is that there is an automatic redraw after the call-back.
The sequence seems to be:
- Zoom/scroll action is detected by the reactor.
- The call-back recreates the temp graphics.
- The CAD-program redraws the current view destroying the temp graphics.
Title: Re: Restore grdraw graphics after zoom?
Post by: Peter2 on November 04, 2019, 12:10:33 PM
Hi roy_043

could you solve this challenge? I'm also looking for an reactor, creating grdraw after zoom commands...
Title: Re: Restore grdraw graphics after zoom?
Post by: roy_043 on November 04, 2019, 02:09:28 PM
could you solve this challenge?
No.
Title: Re: Restore grdraw graphics after zoom?
Post by: Peter2 on November 05, 2019, 03:02:24 AM
I just started to experiment with "dcl-delayedInvoke" from Opendcl, and it looks fine:

http://www.opendcl.com/HelpFiles/index.php?lang=ENU&page=Reference/Function/DelayedInvoke.htm

Code - Auto/Visual Lisp: [Select]
  1. (defun TempGraphics_CallBack_Acdb_ObjectModified (rea lst / object)
  2.     (dcl-DelayedInvoke 100 "mima")    ; mima is a subroutine which "grdraws" a cross x in the middle of the screen
  3. )

Edit 1:
Actually the grdraw works fine, but the reactor fires 150 times for every "zoom extents". Have to take a look ..