Flickering Line (redraw / grread / grdraw)

Flickering Line (redraw / grread / grdraw)

dlbsurveysuk
Collaborator Collaborator
774 Views
8 Replies
Message 1 of 9

Flickering Line (redraw / grread / grdraw)

dlbsurveysuk
Collaborator
Collaborator

I found this routine on The Swamp that dynamically draws an irregular polygon (I've removed some extraneous following code, added the pickbox stuff and modified the grdraw line).

 

When the mouse is moved, the line flickers. I'm assuming this is due to the combination of redraw/grread/grdraw.

 

Can the code be modified to stop this flickering?

 

Thanks.

 

(defun c:DPOLY (/ PT PTLIST SS)

  ; Clone Select CP
  ; by ElpanovEvgeniy
  ; (2006-05-11 11:05:52)
  ; (lst-ent-wp)

(setq OPB (getvar "PICKBOX"))

(setq PTLIST (list (setq PT (getpoint "Specify first point : "))))

(princ "\nSpecify next point : ")
(princ)
(setvar "PICKBOX" 0)

  (while

     (setq PT (progn
                          (while (and (setq PT (grread 5)) (= (car PT) 5))
                                (redraw)

                                (mapcar
                                     (function
                                          (lambda (X1 X2)
                                              (grdraw X1 X2 255 0) ;;; (grdraw x1 x2 6 5) ;;;
                                          )
                                     )
                                  (cons (cadr PT) PTLIST)
                                  (append PTLIST (cdr PT))
                                )
                           )

                        (if (listp (cadr PT))
                            (cadr PT))
      )            )

      (setq PTLIST (cons PT PTLIST))

  )

(redraw)
(setvar "PICKBOX" OPB)
(princ)
)

 

0 Likes
775 Views
8 Replies
Replies (8)
Message 2 of 9

ronjonp
Mentor
Mentor

No flicker here. Perhaps it's your video card?

0 Likes
Message 3 of 9

dlbsurveysuk
Collaborator
Collaborator

Hmm interesting. I don't get any flickering with anything else. If I perform a polygonal crop of a point cloud, which this routine visually emulates, there is no flicker at all...

0 Likes
Message 4 of 9

dlbsurveysuk
Collaborator
Collaborator

I can see if I move the mouse a tiny bit and stop, the line has one fast flicker like it's a slow redraw?

0 Likes
Message 5 of 9

komondormrex
Mentor
Mentor

also no flickering.

and i would recommend you do not touch system variables. pickbox in that case. you'd better switch off pickbox with grread argument. see correction below.

(defun c:DPOLY (/ PT PTLIST SS)
	; Clone Select CP
	; by ElpanovEvgeniy
	; (2006-05-11 11:05:52)
	; (lst-ent-wp)
	(setq PTLIST (list (setq PT (getpoint "Specify first point : "))))
	(princ "\nSpecify next point : ")
	(princ)
	(while
		(setq PT (progn
		          (while (and (setq PT (grread t 5 0)) (= (car PT) 5))
		                (redraw)
		                (mapcar
		                     (function
		                          (lambda (X1 X2)
		                              (grdraw X1 X2 1 0) ;;; (grdraw x1 x2 6 5) ;;;
		                          )
		                     )
		                  (cons (cadr PT) PTLIST)
		                  (append PTLIST (cdr PT))
		                )
		           )
		           (if (listp (cadr PT))
		                    (cadr PT)
			   )
		      ) 
		)
		(setq PTLIST (cons PT PTLIST))
	)
	(redraw)
	(princ)
)
Message 6 of 9

komondormrex
Mentor
Mentor

that flickering may also be when grdraw draws slant lines due to pixel approximation.

0 Likes
Message 7 of 9

Kent1Cooper
Consultant
Consultant

I don't get any flicker, either from your original or @komondormrex 's edited version.  But what is it supposed to do?  I notice it has a localized variable SS that is never set or used.

Kent Cooper, AIA
0 Likes
Message 8 of 9

Sea-Haven
Mentor
Mentor

Just a comment may be helpful.

 

Have a client in last few days similar problem, used grread with brand new laptop, LT 2024, the mess of the boxes appearing was a problem, did not want to try to fix his laptop, graphics card or windows problem, so used (command "Rectang" "pause" "pause") then got boundingbox, min, max and erased the box. 

0 Likes
Message 9 of 9

dlbsurveysuk
Collaborator
Collaborator

Thanks for the reply. Yes I had considered something along the lines of your idea for a rectangular selection, and also a polyline for a polygonal selection.

 

I'm hoping to use this routine in another Lisp for cropping point clouds https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-to-crop-a-point-cloud-fails-to-... This would mean that sometimes the number of vertices could run into the teens.

 

The flicker is only slightly annoying and is something I can live with until hopefully a solution presents itself...

0 Likes