Author Topic: experimenting with gread  (Read 8770 times)

0 Members and 1 Guest are viewing this topic.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
experimenting with gread
« on: October 03, 2012, 08:18:48 AM »
Code: [Select]
(if (setq pt (getpoint "\nSelect a point "))
  (while (car (setq gr (grread T 15 0)))
    (grdraw pt (cadr gr) 1 -1)
    )
  (redraw)
  )

My question is, can I have only one flag. I don´t need a flag to every mouse-moving-point

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: experimenting with gread
« Reply #1 on: October 03, 2012, 08:29:03 AM »
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.


cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: experimenting with gread
« Reply #3 on: October 03, 2012, 09:17:05 AM »
Thanks both

I mean with flag the red line that draws under INSERT TEXT or MTEXT.
Can I have only one line not a line to every mouse-moving-point... :ugly:

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: experimenting with gread
« Reply #4 on: October 03, 2012, 09:42:58 AM »
Maybe:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / pt gr )
  2.     ;; Prompt user for initial base point
  3.     (if (setq pt (getpoint "\nSelect a point: "))
  4.         ;; Wrap the following expressions as a single 'then' expression
  5.         (progn
  6.             ;; Prompt the user for the next point
  7.             (princ "\nPick next point: ")
  8.             ;; While the mouse is being dragged
  9.             (while (= 5 (car (setq gr (grread t 13 0))))
  10.                 ;; Clear the previous vector graphics
  11.                 (redraw)
  12.                 ;; Display a vector from the base point to the cursor
  13.                 (grdraw pt (cadr gr) 1 -1)
  14.             )
  15.             ;; Clear the graphics
  16.             (redraw)
  17.         )
  18.     )
  19.     ;; Suppress the return of the last expression
  20.     (princ)
  21. )

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: experimenting with gread
« Reply #5 on: October 03, 2012, 10:15:33 AM »
Yes Lee very nice, thats good example to come in grread :wink:

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: experimenting with gread
« Reply #6 on: October 03, 2012, 12:23:42 PM »
The redraw is quite nice yes. Previously (prior to 2000 sometime) the redraw would just take too long, causing (at best) the screen to flicker as you move the mouse. At that time you could use grdraw's XOR setting: i.e. setting the color to -1.

That way, you'd save the previous point to a variable, so you can grdraw over the old line to "erase" it. Something like this:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:TestGRDraw  (/ pt1 pt2 gr)
  2.   (if (setq pt1 (getpoint "\nSelect point: "))
  3.     (progn (princ "\nPick next point: ")
  4.            (setq pt2 pt1)
  5.            (grdraw pt1 pt2 -1 -1)
  6.            (while (= 5 (car (setq gr (grread t 13 0))))
  7.              (grdraw pt1 pt2 -1 -1)
  8.              (grdraw pt1 (setq pt2 (cadr gr)) -1 -1))
  9.            (redraw)))
  10.   (princ))
Unfortunately though, that then means you can't pick a colour of your own - it would invert the colour which is already on the screen for each pixel it crosses.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: experimenting with gread
« Reply #7 on: October 04, 2012, 02:15:53 AM »
Thanks for explanation, I get very good ideas to use grread-function... I´ve to studying

duotu007

  • Guest
Re: experimenting with gread
« Reply #8 on: October 04, 2012, 02:47:15 AM »
(while (print (grread 1)))

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: experimenting with gread
« Reply #9 on: October 26, 2012, 04:19:35 AM »
I´ve done a function some draw a vektor with grread. At the same time I want display the distance from start point of polyline to sectionPoint. But I don´t want entmake text to all cursor points. What I have to do

Code: [Select]
(defun c:test ( /
              )
  (setvar "OSMODE" 0)
  (while
    (not
      (if (setq ent (entsel "\nSelect Curve: "))
        (setq vl-ent (vlax-ename->vla-object (car ent)))
        )
      )
    )
  (princ "\nMove Cursor on line: ")
  (while (= 5 (car (setq gr (grread t 13 0))))
    (redraw)
    (grdraw pt1 (cadr gr) 1 -1)
    (setq pt1 (vlax-curve-getClosestPointTo vl-ent (setq pt2 (trans (cadr gr) 1 0))))
    (_disText pt1)
    )
  (redraw)
  )
     

(defun _disText ( x )
  (entmake (list
            '(0 . "TEXT")
    (cons 10 x)
            '(40 . 2.5)
    (cons 1 (strcat "Dis=" (rtos (vlax-curve-getdistatpoint vl-ent x) 2 3)))
    '(50 . 0.0)
            '(71 . 0)
    '(72 . 0)
    '(11 0.0 0.0 0.0)
    '(210 0.0 0.0 1.0)
    '(73 . 0))
       )
  )

 






Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: experimenting with gread
« Reply #10 on: October 26, 2012, 05:22:46 AM »
Things like this ... ?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test (/ _disText e p gr)
  2.   (defun _disText (x)
  3.     (entmake
  4.       (list
  5.         '(0 . "TEXT")
  6.         (cons 10 x)
  7.         (cons 11 x)
  8.         '(40 . 2.5)
  9.         (cons 1
  10.               (strcat "Dis="
  11.                       (rtos (distance x (cadr gr))
  12.                             2
  13.                             3
  14.                       )
  15.               )
  16.         )
  17.         '(50 . 0.0)
  18.         '(71 . 0)
  19.         '(72 . 0)
  20.         '(210 0.0 0.0 1.0)
  21.         '(73 . 0)
  22.       )
  23.     )
  24.   )
  25.  
  26.   (if (setq e (entsel "\n Select Curve: "))
  27.     (progn
  28.       (while (= 5 (car (setq gr (grread t 13 0))))
  29.         (redraw)
  30.         (grdraw (setq p (vlax-curve-getClosestPointTo (car e) (cadr e)))
  31.                 (cadr gr)
  32.                 1
  33.                 -1
  34.         )
  35.       )
  36.       (if (eq (car gr) 3)
  37.         (_disText p)
  38.       )
  39.     )
  40.   )
  41.   (redraw)
  42.   (princ)
  43. )
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: experimenting with gread
« Reply #11 on: October 26, 2012, 05:52:19 AM »
nice variant Tharwat  ^-^

Do you know there is a gr-function which can display text on cursor as like grdraw shows a vector ?
So finally I have the distance displayed on cursor so long I moving them.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: experimenting with gread
« Reply #12 on: October 26, 2012, 08:57:47 AM »
There are quite a few examples of grtext around. Here is one.
http://www.theswamp.org/index.php?topic=33671.msg452156#msg452156
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.

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: experimenting with gread
« Reply #13 on: October 26, 2012, 09:20:16 AM »
http://www.theswamp.org/index.php?topic=37553.0
http://lee-mac.com/grtext.html

This was actually the first link in my above post...

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: experimenting with gread
« Reply #14 on: October 26, 2012, 09:37:33 AM »
An alternative approach:
Code - Auto/Visual Lisp: [Select]
  1. (defun c:cpt ( / cp el en ht pt )
  2.     (if (setq en (car (entsel)))
  3.         (progn
  4.             (setq pt (cadr (grread t 13))
  5.                   el (entget (entmakex (list '(0 . "TEXT") (cons 10 pt) '(1 . "") '(40 . 1.0))))
  6.             )
  7.             (while (= 5 (car (setq pt (grread t 13 0))))
  8.                 (redraw)
  9.                 (setq pt (cadr pt)
  10.                       ht (/ (getvar 'viewsize) 30.0)
  11.                       cp (vlax-curve-getclosestpointto en pt)
  12.                 )
  13.                 (grdraw pt cp 1 1)
  14.                 (entmod
  15.                     (subst (cons 40 ht) (assoc 40 el)
  16.                         (subst (cons 10 (mapcar '+ pt (list ht ht))) (assoc 10 el)
  17.                             (subst (cons 01 (strcat "Dis=" (rtos (vlax-curve-getdistatpoint en cp) 2 3)))
  18.                                 (assoc 01 el)
  19.                                 el
  20.                             )
  21.                         )
  22.                     )
  23.                 )
  24.             )
  25.             (redraw)
  26.         )
  27.     )
  28.     (princ)
  29. )

cadplayer

  • Bull Frog
  • Posts: 390
  • Autocad Civil3d, OpenDCL.Runtime, LISP, .NET (C#)
Re: experimenting with gread
« Reply #15 on: October 27, 2012, 03:02:33 AM »
Lee, a dream your solution - fantastic work - thanks a lot :-o

Lee Mac

  • Seagull
  • Posts: 12926
  • London, England
Re: experimenting with gread
« Reply #16 on: October 27, 2012, 07:17:40 AM »
Lee, a dream your solution - fantastic work - thanks a lot :-o

You're very welcome cadplayer, thanks  :-)