Author Topic: Restore grdraw graphics after zoom?  (Read 1297 times)

0 Members and 1 Guest are viewing this topic.

roy_043

  • Water Moccasin
  • Posts: 1729
  • BricsCAD 18
Restore grdraw graphics after zoom?
« 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.  

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Restore grdraw graphics after zoom?
« Reply #1 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.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

roy_043

  • Water Moccasin
  • Posts: 1729
  • BricsCAD 18
Re: Restore grdraw graphics after zoom?
« Reply #2 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.

Peter2

  • Swamp Rat
  • Posts: 564
Re: Restore grdraw graphics after zoom?
« Reply #3 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...
Peter

AutoCAD Map 3D 2018 German (so some technical terms will be badly retranslated to English)
BricsCAD V19

roy_043

  • Water Moccasin
  • Posts: 1729
  • BricsCAD 18
Re: Restore grdraw graphics after zoom?
« Reply #4 on: November 04, 2019, 02:09:28 PM »

Peter2

  • Swamp Rat
  • Posts: 564
Re: Restore grdraw graphics after zoom?
« Reply #5 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 ..
« Last Edit: November 05, 2019, 05:45:11 AM by Peter2 »
Peter

AutoCAD Map 3D 2018 German (so some technical terms will be badly retranslated to English)
BricsCAD V19